diff --git a/api/src/database/migrations/20210805A-update-groups.ts b/api/src/database/migrations/20210805A-update-groups.ts new file mode 100644 index 0000000000..350268a52f --- /dev/null +++ b/api/src/database/migrations/20210805A-update-groups.ts @@ -0,0 +1,35 @@ +import { Knex } from 'knex'; + +export async function up(knex: Knex): Promise { + const groups = await knex.select('*').from('directus_fields').where({ interface: 'group-standard' }); + + const raw = []; + const detail = []; + + for (const group of groups) { + const options = typeof group.options === 'string' ? JSON.parse(group.options) : group.options || {}; + + if (options.showHeader === true) { + detail.push(group); + } else { + raw.push(group); + } + } + + for (const field of raw) { + await knex('directus_fields').update({ interface: 'group-raw' }).where({ id: field.id }); + } + + for (const field of detail) { + await knex('directus_fields').update({ interface: 'group-detail' }).where({ id: field.id }); + } +} + +export async function down(knex: Knex): Promise { + await knex('directus_fields') + .update({ + interface: 'group-standard', + }) + .where({ interface: 'group-detail' }) + .orWhere({ interface: 'group-raw' }); +} diff --git a/app/src/interfaces/group-accordion/group-accordion.vue b/app/src/interfaces/group-accordion/group-accordion.vue index dfdb893c97..87a43e0d90 100644 --- a/app/src/interfaces/group-accordion/group-accordion.vue +++ b/app/src/interfaces/group-accordion/group-accordion.vue @@ -1,5 +1,5 @@