14 lines
914 B
SQL
14 lines
914 B
SQL
-- ImageHub: link a dataset to a research project (the "workspace" superstructure). Nullable,
|
|
-- so existing datasets stay unlinked and a dataset can still exist standalone. A dataset created
|
|
-- from a project cockpit attaches to that project. ON DELETE SET NULL so deleting a project
|
|
-- orphans its datasets rather than dropping the imaging data. Idempotent. Apply after 023
|
|
-- (no semicolons inside comments or string literals — the runner splitter is naive):
|
|
-- docker exec -i initiative-postgres psql -U initiative -d initiatives < be0/migrations/024_imagehub_dataset_project_link.sql
|
|
|
|
ALTER TABLE imagehub_datasets
|
|
ADD COLUMN IF NOT EXISTS research_project_id UUID REFERENCES research_projects(id) ON DELETE SET NULL;
|
|
|
|
-- "Datasets in this project" lookup (the project-scoped dataset list).
|
|
CREATE INDEX IF NOT EXISTS idx_imagehub_datasets_research_project
|
|
ON imagehub_datasets (research_project_id);
|