15 lines
724 B
SQL
15 lines
724 B
SQL
SET search_path TO atlas, public;
|
|
|
|
-- `workspace_id` is the tenant boundary and is never nullable. PostgreSQL's
|
|
-- unqualified ON DELETE SET NULL on a composite FK clears every referencing
|
|
-- column, including workspace_id. Only the optional variant pointer may be
|
|
-- cleared when a re-collected source snapshot replaces its variants.
|
|
ALTER TABLE collection_asset_transfers
|
|
DROP CONSTRAINT collection_asset_transfers_workspace_id_source_variant_id_fkey;
|
|
|
|
ALTER TABLE collection_asset_transfers
|
|
ADD CONSTRAINT collection_asset_transfers_workspace_id_source_variant_id_fkey
|
|
FOREIGN KEY (workspace_id, source_variant_id)
|
|
REFERENCES product_variants(workspace_id, id)
|
|
ON DELETE SET NULL (source_variant_id);
|