@directus/api
Version:
Directus is a real-time API and App dashboard for managing SQL database content
28 lines (27 loc) • 1.18 kB
JavaScript
import { getHelpers } from '../helpers/index.js';
export async function up(knex) {
const helper = getHelpers(knex);
await knex.schema.alterTable('directus_relations', (table) => {
table.dropColumns('many_primary', 'one_primary');
table.string('one_deselect_action').defaultTo('nullify');
});
await knex('directus_relations').update({ one_deselect_action: 'nullify' });
await helper.schema.changeToType('directus_relations', 'sort_field', 'string', {
length: helper.schema.getColumnNameMaxLength(),
});
await helper.schema.changeToType('directus_relations', 'one_deselect_action', 'string', {
nullable: false,
default: 'nullify',
});
}
export async function down(knex) {
const helper = getHelpers(knex);
await helper.schema.changeToType('directus_relations', 'sort_field', 'string', {
length: 255,
});
await knex.schema.alterTable('directus_relations', (table) => {
table.dropColumn('one_deselect_action');
table.string('many_primary', helper.schema.getColumnNameMaxLength());
table.string('one_primary', helper.schema.getColumnNameMaxLength());
});
}