exports.up = (pgm) => {
  pgm.createTable('citations', {
    id:         'id',
    project_id: { type: 'integer', notNull: true, references: 'videos', onDelete: 'CASCADE' },
    reference:  { type: 'text', notNull: true },
    context:    { type: 'text' },
    sort_order: { type: 'integer', notNull: true, default: 0 },
    created_at: { type: 'timestamptz', notNull: true, default: pgm.func('NOW()') },
  });
  pgm.createIndex('citations', 'project_id', { name: 'idx_citations_project_id' });
};

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