fix: align local migrations with deployed Supabase state

Rename migration files (039-052) from sequential to real deployed
timestamps, add 11 missing migration files that were applied directly
to production, apply invoice_delivery_note_sequences migration, and
rename placeholder files for clarity.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-03-06 10:16:22 +01:00
co-authored by Claude Opus 4.6
parent 55e8cc1a88
commit b0de46790a
28 changed files with 70 additions and 13 deletions
@@ -0,0 +1,4 @@
-- Migration: create_extension_data
-- No-op: extension_data table is created by migration 020 (extension_data)
-- in this consolidated migration set.
-- Originally applied to production as a separate migration.
@@ -0,0 +1,4 @@
-- Migration: add_missing_dimension_columns
-- No-op: cost_center and project text columns on journal_entry_lines
-- are created by migration 011 (alter_existing_tables) in this consolidated set.
-- Originally applied to production as a separate migration.
@@ -0,0 +1,4 @@
-- Migration: add_tax_code_column
-- No-op: tax_code column on journal_entry_lines
-- is created by migration 011 (alter_existing_tables) in this consolidated set.
-- Originally applied to production as a separate migration.
@@ -0,0 +1,5 @@
-- Migration: document_inbox_expansion
-- No-op: all document inbox columns (matched_transaction_id, match_confidence,
-- match_method, suggested_template_id, etc.) are included in the
-- invoice_inbox migration (20260223150836) in this consolidated set.
-- Originally applied to production as a separate migration.
@@ -0,0 +1,10 @@
-- Migration: supplier_invoice_transaction_match
-- Adds potential_supplier_invoice_id to transactions for supplier invoice matching.
-- Note: supplier_invoice_id on transactions is already added by migration 025 (payroll).
ALTER TABLE public.transactions
ADD COLUMN IF NOT EXISTS potential_supplier_invoice_id UUID
REFERENCES public.supplier_invoices(id) ON DELETE SET NULL;
CREATE INDEX IF NOT EXISTS idx_transactions_potential_supplier_invoice
ON public.transactions(potential_supplier_invoice_id);
@@ -0,0 +1,4 @@
-- Migration: document_matching
-- No-op: match_documents function and knowledge_documents table
-- are created by migration 033 (ai_chat_schema) in this consolidated set.
-- Originally applied to production as a separate migration.
@@ -0,0 +1,5 @@
-- Migration: add_journal_entry_reversal_columns
-- No-op: reversed_by_id, reverses_id, correction_of_id, and committed_at columns
-- on journal_entries are created by migration 011 (alter_existing_tables)
-- in this consolidated set.
-- Originally applied to production as a separate migration.
@@ -0,0 +1,5 @@
-- Migration: recreate_supplier_invoices_schema
-- No-op: suppliers, supplier_invoices, supplier_invoice_items, and
-- supplier_invoice_payments tables are created by migration 025 (supplier_invoices)
-- in this consolidated set with the final schema.
-- Originally applied to production as a separate migration.
@@ -0,0 +1,5 @@
-- Migration: align_suppliers_schema
-- No-op: supplier schema alignment (supplier_type, address_line2,
-- bank_account, default_expense_account, default_currency columns)
-- is included in migration 025 (supplier_invoices) in this consolidated set.
-- Originally applied to production as a separate migration.
@@ -0,0 +1,4 @@
-- Migration: add_supplier_invoice_items_vat_code
-- No-op: vat_code column on supplier_invoice_items is included in
-- migration 025 (supplier_invoices) in this consolidated set.
-- Originally applied to production as a separate migration.
@@ -0,0 +1,4 @@
-- Migration: fix_audit_triggers_child_tables
-- No-op: audit triggers on suppliers and supplier_invoices are included
-- in migration 025 (supplier_invoices) in this consolidated set.
-- Originally applied to production as a separate migration.
@@ -17,6 +17,7 @@ CREATE OR REPLACE FUNCTION public.generate_invoice_number(p_user_id UUID)
RETURNS TEXT
LANGUAGE plpgsql
SECURITY DEFINER
SET search_path = public
AS $$
DECLARE
v_prefix TEXT;
@@ -51,6 +52,7 @@ CREATE OR REPLACE FUNCTION public.generate_delivery_note_number(p_user_id UUID)
RETURNS TEXT
LANGUAGE plpgsql
SECURITY DEFINER
SET search_path = public
AS $$
DECLARE
v_number INTEGER;