Remove deprecated snapshot system
The register/document model has fully replaced the snapshot system. Delete every snapshot-scoped row and strip the application code that referenced them: SnapshotID/SourceID struct fields, snapshot_id IS NULL filters, snapshot columns from SELECT/INSERT statements and named args, and the eight migrate-*-snapshots-to-documents one-shot tools. The remaining snapshot_id / source_id columns, the snapshots and controls_snapshots tables, the snapshots_type enum, and the snapshot-scoped indexes are now unused; they are dropped in a follow-up schema migration so this change can roll back cleanly without leaving orphaned data. Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
30
pkg/coredata/migrations/20260506T150405Z.sql
Normal file
30
pkg/coredata/migrations/20260506T150405Z.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
-- Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
|
||||
--
|
||||
-- Permission to use, copy, modify, and/or distribute this software for any
|
||||
-- purpose with or without fee is hereby granted, provided that the above
|
||||
-- copyright notice and this permission notice appear in all copies.
|
||||
--
|
||||
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
-- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
-- PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
-- The register/document model has fully replaced the snapshot system. Delete the
|
||||
-- snapshot-scoped data; the schema (snapshot_id / source_id columns, snapshots
|
||||
-- table, controls_snapshots, snapshots_type enum, snapshot-scoped indexes) is
|
||||
-- dropped in a follow-up migration.
|
||||
|
||||
-- processing_activity_vendors stores snapshot_id without an FK to snapshots, so
|
||||
-- the cascade delete below would not reach it. Clean it up explicitly first.
|
||||
DELETE FROM processing_activity_vendors WHERE snapshot_id IS NOT NULL;
|
||||
|
||||
-- Every other table with a snapshot_id has a FOREIGN KEY (snapshot_id) REFERENCES
|
||||
-- snapshots(id) ON DELETE CASCADE, so deleting all snapshots removes every
|
||||
-- snapshot-scoped row across data, vendors, assets, risks, findings, obligations,
|
||||
-- processing_activities, statements_of_applicability, applicability_statements,
|
||||
-- the vendor_* sub-tables, the processing_activity DPIA/TIA tables, and the
|
||||
-- controls_snapshots junction.
|
||||
DELETE FROM snapshots;
|
||||
Reference in New Issue
Block a user