@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / cc50d40
Fork 0

سامانه صدور فاکتور و حسابداری

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 3, 20:45 UTC

Prepare Iran enterprise persistence migration

davoodmehraban89 committed Sep 30, 2026 at 01:43 UTC cc50d40605dde64404fedaca373cc33fd973b7d4
1 file changed +21
supabase/migrations/20260930222500_iran_enterprise_control_collections.sql new
+21
@@ -0,0 +1,21 @@
1 +-- Prepared 2026-09-30. DO NOT APPLY without explicit schema approval under AGENTS.md.
2 +-- Iran enterprise control collections for HR/leave/treasury/compliance registry.
3 +alter table public.records drop constraint if exists records_collection_check;
4 +alter table public.records add constraint records_collection_check check (collection = any (array[
5 +'companies','contacts','products','invoices','cheques','expenses','settings','purchases','payments',
6 +'fiscalYears','accounts','dimensionTypes','dimensionValues','accountDimensionRules','branches','projects','projectLinks',
7 +'postingProfiles','journalVouchers','journalLines','journalLineDimensions',
8 +'contracts','contractAmendments','contractParties','contractDeductions','guarantees','guaranteeEvents','contractStatements','phase4Audit',
9 +'warehouses','stockMovements','inventoryCounts','fixedAssets','assetDepreciations','currencies','exchangeRates','costCenters',
10 +'importBatches','integrationConnections','integrationOutbox','phase5Audit',
11 +'employees','employmentContracts','employeeLeave','cashboxes','pettyCashFunds','complianceRules'
12 +]::text[]));
13 +
14 +create unique index if not exists ux_finora_employee_personnel_no
15 +on public.records(owner_id,(data->>'companyId'),upper(data->>'personnelNo')) where collection='employees';
16 +
17 +create unique index if not exists ux_finora_employee_leave_year
18 +on public.records(owner_id,(data->>'companyId'),(data->>'employeeId'),(data->>'year')) where collection='employeeLeave';
19 +
20 +create unique index if not exists ux_finora_cashbox_code
21 +on public.records(owner_id,(data->>'companyId'),upper(data->>'code')) where collection='cashboxes';