// which scene receives actors, tags or duration from the other when a relation is shared: 'source' (the derivation or compilation), 'target' (the original or compilation part) or 'both', omitted fields are not shared by default // sharing is a one-time copy through revisions, these only preselect the options in the relation dialog const shareDefaults = { rerelease: { actors: 'both', tags: 'both', duration: 'source' }, remaster: { actors: 'source', tags: 'source' }, reedit: { actors: 'source', tags: 'source' }, bts: { actors: 'source' }, compilation: { actors: 'source' }, // variant shares nothing by default }; exports.up = async function(knex) { await knex.schema.alterTable('relations_types', (table) => { table.jsonb('share_defaults') .notNullable() .defaultTo('{}'); }); await Object.entries(shareDefaults).reduce(async (chain, [type, defaults]) => { await chain; await knex('relations_types') .where('type', type) .update('share_defaults', JSON.stringify(defaults)); }, Promise.resolve()); }; exports.down = async function(knex) { await knex.schema.alterTable('relations_types', (table) => { table.dropColumn('share_defaults'); }); };