// Allows an asset to declare that it is a processed derivative of another asset.
// Example lineage: raw .mov → chroma-keyed .mp4 (parent_id → raw asset)
// A raw asset has parent_id = NULL.
// Multiple processed versions can share the same parent_id.

exports.up = (pgm) => {
  pgm.addColumn('shared_assets', {
    parent_id: {
      type: 'integer',
      references: 'shared_assets',
      onDelete: 'SET NULL',
    },
  });
  pgm.createIndex('shared_assets', 'parent_id', { name: 'idx_shared_assets_parent' });
};

exports.down = (pgm) => {
  pgm.dropIndex('shared_assets', 'parent_id', { name: 'idx_shared_assets_parent' });
  pgm.dropColumn('shared_assets', 'parent_id');
};
