Fix group migration on MySQL (#8404)

* Remove groupsInUse check

* Fix group migration on MySQL

Fixes #8369
This commit is contained in:
Rijk van Zanten
2021-09-28 18:46:26 -04:00
committed by GitHub
parent c6c126f755
commit ec32c9e0fe

View File

@@ -4,8 +4,6 @@ import { uniq } from 'lodash';
export async function up(knex: Knex): Promise<void> {
const groupsInUse = await knex.select('id', 'group').from('directus_fields').whereNotNull('group');
if (groupsInUse.length === 0) return;
const groupIDs: number[] = uniq(groupsInUse.map(({ group }) => group));
const groupFields = await knex.select('id', 'field').from('directus_fields').whereIn('id', groupIDs);
@@ -16,6 +14,10 @@ export async function up(knex: Knex): Promise<void> {
groupMap.set(id, field);
}
await knex.schema.alterTable('directus_fields', (table) => {
table.dropForeign('group');
});
await knex.schema.alterTable('directus_fields', (table) => {
table.dropColumn('group');
});