From d428670e4e23aeb1345865f15273b3ec39e9e4bc Mon Sep 17 00:00:00 2001 From: Protogon Date: Thu, 11 Jul 2024 18:23:59 +0100 Subject: [PATCH] Ignore default DB_FILENAME option when using MySQL/MariaDB (#22970) Co-authored-by: Pascal Jufer --- .changeset/ten-beds-pretend.md | 5 +++++ api/src/database/index.ts | 4 ++++ contributors.yml | 1 + 3 files changed, 10 insertions(+) create mode 100644 .changeset/ten-beds-pretend.md diff --git a/.changeset/ten-beds-pretend.md b/.changeset/ten-beds-pretend.md new file mode 100644 index 0000000000..750c0c9c20 --- /dev/null +++ b/.changeset/ten-beds-pretend.md @@ -0,0 +1,5 @@ +--- +"@directus/api": patch +--- + +Ensured the default `DB_FILENAME` option from the Docker Image is not applied when using MySQL/MariaDB, fixing a corresponding warning diff --git a/api/src/database/index.ts b/api/src/database/index.ts index f8d5bca4d3..ce7706233f 100644 --- a/api/src/database/index.ts +++ b/api/src/database/index.ts @@ -1,6 +1,7 @@ import { useEnv } from '@directus/env'; import type { SchemaInspector } from '@directus/schema'; import { createInspector } from '@directus/schema'; +import { isObject } from '@directus/utils'; import fse from 'fs-extra'; import type { Knex } from 'knex'; import knex from 'knex'; @@ -136,6 +137,9 @@ export function getDatabase(): Knex { } if (client === 'mysql') { + // Remove the conflicting `filename` option, defined by default in the Docker Image + if (isObject(knexConfig.connection)) delete knexConfig.connection['filename']; + Object.assign(knexConfig, { client: 'mysql2' }); poolConfig.afterCreate = async (conn: any, callback: any) => { diff --git a/contributors.yml b/contributors.yml index a1d024498a..f97eedaf29 100644 --- a/contributors.yml +++ b/contributors.yml @@ -141,3 +141,4 @@ - Dominic-Preap - brandondrew - alantiller +- cliqer