mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Set CRDB options to avoid inconsistencies between vendors (#11193)
* Set correct CRDB options * Add missing SETs to pool config for e2e * How about now * Better solution for the same problem
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { knex, Knex } from 'knex';
|
||||
import path from 'path';
|
||||
import { promisify } from 'util';
|
||||
|
||||
export type Credentials = {
|
||||
filename?: string;
|
||||
@@ -55,12 +56,24 @@ export default function createDBConnection(
|
||||
extension: 'js',
|
||||
directory: path.resolve(__dirname, '../../database/seeds/'),
|
||||
},
|
||||
pool: {},
|
||||
};
|
||||
|
||||
if (client === 'sqlite3') {
|
||||
knexConfig.useNullAsDefault = true;
|
||||
}
|
||||
|
||||
if (client === 'cockroachdb') {
|
||||
knexConfig.pool!.afterCreate = async (conn: any, callback: any) => {
|
||||
const run = promisify(conn.query.bind(conn));
|
||||
|
||||
await run('SET serial_normalization = "sql_sequence"');
|
||||
await run('SET default_int_size = 4');
|
||||
|
||||
callback(null, conn);
|
||||
};
|
||||
}
|
||||
|
||||
const db = knex(knexConfig);
|
||||
return db;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user