diff --git a/src/integrations/supabase/types.ts b/src/integrations/supabase/types.ts index d9721845..badeb0ac 100644 --- a/src/integrations/supabase/types.ts +++ b/src/integrations/supabase/types.ts @@ -543,44 +543,6 @@ export type Database = { } Relationships: [] } - entity_field_history: { - Row: { - change_type: string - created_at: string - field_name: string - id: string - new_value: Json | null - old_value: Json | null - version_id: string - } - Insert: { - change_type: string - created_at?: string - field_name: string - id?: string - new_value?: Json | null - old_value?: Json | null - version_id: string - } - Update: { - change_type?: string - created_at?: string - field_name?: string - id?: string - new_value?: Json | null - old_value?: Json | null - version_id?: string - } - Relationships: [ - { - foreignKeyName: "entity_field_history_version_id_fkey" - columns: ["version_id"] - isOneToOne: false - referencedRelation: "entity_versions" - referencedColumns: ["id"] - }, - ] - } entity_page_views: { Row: { created_at: string | null @@ -608,103 +570,6 @@ export type Database = { } Relationships: [] } - entity_relationships_history: { - Row: { - change_type: string - created_at: string - id: string - old_related_entity_id: string | null - related_entity_id: string | null - related_entity_type: string - relationship_type: string - version_id: string - } - Insert: { - change_type: string - created_at?: string - id?: string - old_related_entity_id?: string | null - related_entity_id?: string | null - related_entity_type: string - relationship_type: string - version_id: string - } - Update: { - change_type?: string - created_at?: string - id?: string - old_related_entity_id?: string | null - related_entity_id?: string | null - related_entity_type?: string - relationship_type?: string - version_id?: string - } - Relationships: [ - { - foreignKeyName: "entity_relationships_history_version_id_fkey" - columns: ["version_id"] - isOneToOne: false - referencedRelation: "entity_versions" - referencedColumns: ["id"] - }, - ] - } - entity_versions: { - 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: [ - { - foreignKeyName: "entity_versions_submission_id_fkey" - columns: ["submission_id"] - isOneToOne: false - referencedRelation: "content_submissions" - referencedColumns: ["id"] - }, - ] - } entity_versions_archive: { Row: { change_reason: string | null @@ -3301,45 +3166,6 @@ export type Database = { } Relationships: [] } - version_diffs: { - Row: { - created_at: string - diff_data: Json - from_version_id: string - id: string - to_version_id: string - } - Insert: { - created_at?: string - diff_data: Json - from_version_id: string - id?: string - to_version_id: string - } - Update: { - created_at?: string - diff_data?: Json - from_version_id?: string - id?: string - to_version_id?: string - } - Relationships: [ - { - foreignKeyName: "version_diffs_from_version_id_fkey" - columns: ["from_version_id"] - isOneToOne: false - referencedRelation: "entity_versions" - referencedColumns: ["id"] - }, - { - foreignKeyName: "version_diffs_to_version_id_fkey" - columns: ["to_version_id"] - isOneToOne: false - referencedRelation: "entity_versions" - referencedColumns: ["id"] - }, - ] - } } Views: { filtered_profiles: { @@ -3505,26 +3331,6 @@ export type Database = { Args: Record Returns: undefined } - compare_versions: { - Args: { p_from_version_id: string; p_to_version_id: string } - Returns: Json - } - create_entity_version: { - Args: { - p_change_reason?: string - p_change_type?: Database["public"]["Enums"]["version_change_type"] - p_changed_by: string - p_entity_id: string - p_entity_type: string - p_submission_id?: string - p_version_data: Json - } - Returns: string - } - create_field_history_entries: { - Args: { p_new_data: Json; p_old_data: Json; p_version_id: string } - Returns: undefined - } extend_submission_lock: { Args: { extension_duration?: unknown diff --git a/supabase/migrations/20251015181531_d918bea7-1cda-4950-a877-632b608b992c.sql b/supabase/migrations/20251015181531_d918bea7-1cda-4950-a877-632b608b992c.sql new file mode 100644 index 00000000..992c8a52 --- /dev/null +++ b/supabase/migrations/20251015181531_d918bea7-1cda-4950-a877-632b608b992c.sql @@ -0,0 +1,21 @@ +-- Drop old JSONB versioning system completely +-- This removes all deprecated tables and functions + +-- Drop dependent tables first +DROP TABLE IF EXISTS public.version_diffs CASCADE; +DROP TABLE IF EXISTS public.entity_relationships_history CASCADE; +DROP TABLE IF EXISTS public.entity_field_history CASCADE; + +-- Drop main legacy table (archive remains) +DROP TABLE IF EXISTS public.entity_versions CASCADE; + +-- Drop old RPC functions +DROP FUNCTION IF EXISTS public.create_entity_version( + text, uuid, jsonb, uuid, text, uuid, version_change_type +) CASCADE; + +DROP FUNCTION IF EXISTS public.compare_versions(uuid, uuid) CASCADE; + +DROP FUNCTION IF EXISTS public.create_field_history_entries(uuid, jsonb, jsonb) CASCADE; + +-- Note: We keep rollback_to_version as it's been updated for relational system \ No newline at end of file