Fix: Remove versioning helpers

This commit is contained in:
gpt-engineer-app[bot]
2025-10-15 18:14:08 +00:00
parent 84238bc40e
commit 8f56f608f7
2 changed files with 75 additions and 0 deletions

View File

@@ -705,6 +705,54 @@ export type Database = {
}, },
] ]
} }
entity_versions_archive: {
Row: {
change_reason: string | null
change_type: Database["public"]["Enums"]["version_change_type"]
changed_at: string
changed_by: string | null
entity_id: string
entity_type: string
id: string
ip_address_hash: string | null
is_current: boolean
metadata: Json | null
submission_id: string | null
version_data: Json
version_number: number
}
Insert: {
change_reason?: string | null
change_type?: Database["public"]["Enums"]["version_change_type"]
changed_at?: string
changed_by?: string | null
entity_id: string
entity_type: string
id?: string
ip_address_hash?: string | null
is_current?: boolean
metadata?: Json | null
submission_id?: string | null
version_data: Json
version_number: number
}
Update: {
change_reason?: string | null
change_type?: Database["public"]["Enums"]["version_change_type"]
changed_at?: string
changed_by?: string | null
entity_id?: string
entity_type?: string
id?: string
ip_address_hash?: string | null
is_current?: boolean
metadata?: Json | null
submission_id?: string | null
version_data?: Json
version_number?: number
}
Relationships: []
}
historical_parks: { historical_parks: {
Row: { Row: {
closure_reason: string | null closure_reason: string | null

View File

@@ -0,0 +1,27 @@
-- Archive old JSONB versions table before dropping
-- This preserves historical data while allowing us to move forward
CREATE TABLE IF NOT EXISTS public.entity_versions_archive (
LIKE public.entity_versions INCLUDING ALL
);
-- Copy all old versions to archive
INSERT INTO public.entity_versions_archive
SELECT * FROM public.entity_versions
ON CONFLICT DO NOTHING;
-- Verify counts match
DO $$
DECLARE
original_count INTEGER;
archive_count INTEGER;
BEGIN
SELECT COUNT(*) INTO original_count FROM public.entity_versions;
SELECT COUNT(*) INTO archive_count FROM public.entity_versions_archive;
IF original_count != archive_count THEN
RAISE EXCEPTION 'Archive verification failed: original=%, archive=%', original_count, archive_count;
END IF;
RAISE NOTICE 'Successfully archived % versions to entity_versions_archive', archive_count;
END $$;