// Global shared asset library from shared_assets/ directory (shared_assets/videos.json,
// plus square/, landscape/, pexels/, models/ subfolders).
// This is the future MinIO object catalogue — minio_object_key is null until migration.
exports.up = (pgm) => {
  pgm.createTable('shared_assets', {
    id:               'id',
    asset_key:        { type: 'varchar(200)', notNull: true, unique: true },
    asset_type:       { type: 'varchar(20)', notNull: true },  // video | image | audio | model
    subfolder:        { type: 'varchar(100)' },                // pexels | square | landscape | models
    filename:         { type: 'varchar(500)', notNull: true },
    minio_object_key: { type: 'varchar(500)' },
    description:      { type: 'text' },
    duration_seconds: { type: 'numeric' },
    has_audio:        { type: 'boolean', notNull: true, default: false },
    file_size_bytes:  { type: 'bigint' },
    created_at:       { type: 'timestamptz', notNull: true, default: pgm.func('NOW()') },
    updated_at:       { type: 'timestamptz', notNull: true, default: pgm.func('NOW()') },
  });
  pgm.createIndex('shared_assets', 'asset_type',  { name: 'idx_shared_assets_type' });
  pgm.createIndex('shared_assets', 'subfolder',   { name: 'idx_shared_assets_subfolder' });
};

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