-- +goose Up
-- +goose StatementBegin
ALTER TABLE media_assets
    ADD COLUMN IF NOT EXISTS source_asset_id bigint;

COMMENT ON COLUMN media_assets.source_asset_id IS '派生来源资源ID：preview 产物可指向对应 main 资源；用于建立 preview/main 的 1:1 追溯关系';

CREATE INDEX IF NOT EXISTS ix_media_assets_tenant_source_asset_id ON media_assets (tenant_id, source_asset_id);
-- +goose StatementEnd

-- +goose Down
-- +goose StatementBegin
DROP INDEX IF EXISTS ix_media_assets_tenant_source_asset_id;
ALTER TABLE media_assets DROP COLUMN IF EXISTS source_asset_id;
-- +goose StatementEnd

