// Per-project processing filter chains from project.json "default_filters".
// Each row is one filter step within a named target pipeline (audioonly, talkinghead, etc.).
// Filter-specific parameters (LUFS targets, chroma key colours, mask boundaries) live in params (jsonb).
exports.up = (pgm) => {
  pgm.createTable('filter_chains', {
    id:          'id',
    project_id:  { type: 'integer', notNull: true, references: 'videos', onDelete: 'CASCADE' },
    target:      { type: 'varchar(50)', notNull: true },  // audioonly | talkinghead
    sort_order:  { type: 'integer',     notNull: true },
    filter_type: { type: 'varchar(50)', notNull: true },  // audio_normalize | color_grade | gnommokey | mask
    params:      { type: 'jsonb' },
    created_at:  { type: 'timestamptz', notNull: true, default: pgm.func('NOW()') },
    updated_at:  { type: 'timestamptz', notNull: true, default: pgm.func('NOW()') },
  });
  pgm.createIndex('filter_chains', ['project_id', 'target', 'sort_order'], {
    name: 'idx_filter_chains_project_target_order',
  });
};

exports.down = (pgm) => { pgm.dropTable('filter_chains'); };
