mirror of
https://github.com/directus/directus.git
synced 2026-02-12 04:04:54 -05:00
Merge branch 'main' into aggregation
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Knex } from 'knex';
|
||||
import logger from '../../logger';
|
||||
import SchemaInspector from 'knex-schema-inspector';
|
||||
|
||||
/**
|
||||
* Things to keep in mind:
|
||||
@@ -80,11 +81,23 @@ const updates = [
|
||||
];
|
||||
|
||||
export async function up(knex: Knex): Promise<void> {
|
||||
const inspector = SchemaInspector(knex);
|
||||
|
||||
const foreignKeys = await inspector.foreignKeys();
|
||||
|
||||
for (const update of updates) {
|
||||
for (const constraint of update.constraints) {
|
||||
const existingForeignKey = foreignKeys.find(
|
||||
(fk) =>
|
||||
fk.table === update.table &&
|
||||
fk.column === constraint.column &&
|
||||
fk.foreign_key_table === constraint.references.split('.')[0] &&
|
||||
fk.foreign_key_column === constraint.references.split('.')[1]
|
||||
);
|
||||
|
||||
try {
|
||||
await knex.schema.alterTable(update.table, (table) => {
|
||||
table.dropForeign([constraint.column]);
|
||||
table.dropForeign([constraint.column], existingForeignKey?.constraint_name || undefined);
|
||||
});
|
||||
} catch (err) {
|
||||
logger.warn(`Couldn't drop foreign key ${update.table}.${constraint.column}->${constraint.references}`);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Knex } from 'knex';
|
||||
|
||||
export async function up(knex: Knex): Promise<void> {
|
||||
await knex.schema.alterTable('directus_files', (table) => {
|
||||
table.bigInteger('filesize').nullable().defaultTo(null).alter();
|
||||
});
|
||||
}
|
||||
|
||||
export async function down(knex: Knex): Promise<void> {
|
||||
await knex.schema.alterTable('directus_files', (table) => {
|
||||
table.integer('filesize').nullable().defaultTo(null).alter();
|
||||
});
|
||||
}
|
||||
@@ -81,6 +81,7 @@
|
||||
- id
|
||||
- first_name
|
||||
- last_name
|
||||
- last_page
|
||||
- email
|
||||
- password
|
||||
- location
|
||||
|
||||
Reference in New Issue
Block a user