سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 20:45 UTC
Archive exact production enterprise migration version
davoodmehraban89 committed
Sep 30, 2026 at 01:43 UTC
4f7ad39e59c9a3057a6f801762f8ee21c4a30211
1 file changed
+15
supabase/migrations/20260929221252_iran_enterprise_foundation_collections.sql
new
+15
@@ -0,0 +1,15 @@
1
+-- Iran enterprise foundation collections. Non-destructive expansion of generic owner-scoped record store.
2
+alter table public.records drop constraint if exists records_collection_check;
3
+alter table public.records add constraint records_collection_check check (collection = any (array[
4
+'companies','contacts','products','invoices','cheques','expenses','settings','purchases','payments',
5
+'fiscalYears','accounts','dimensionTypes','dimensionValues','accountDimensionRules','branches','projects','projectLinks',
6
+'postingProfiles','journalVouchers','journalLines','journalLineDimensions',
7
+'contracts','contractAmendments','contractParties','contractDeductions','guarantees','guaranteeEvents','contractStatements','phase4Audit',
8
+'warehouses','stockMovements','inventoryCounts','fixedAssets','assetDepreciations','currencies','exchangeRates','costCenters',
9
+'importBatches','integrationConnections','integrationOutbox','phase5Audit',
10
+'employees','employmentContracts','employeeLeave','cashboxes','pettyCashFunds','complianceRules'
11
+]::text[]));
12
+create unique index if not exists ux_finora_employee_personnel_no on public.records(owner_id,(data->>'companyId'),upper(data->>'personnelNo')) where collection='employees';
13
+create unique index if not exists ux_finora_employee_national_id on public.records(owner_id,(data->>'companyId'),(data->>'nationalId')) where collection='employees' and coalesce(data->>'nationalId','')<>'';
14
+create unique index if not exists ux_finora_employee_leave_year on public.records(owner_id,(data->>'companyId'),(data->>'employeeId'),(data->>'year')) where collection='employeeLeave';
15
+create unique index if not exists ux_finora_cashbox_code on public.records(owner_id,(data->>'companyId'),upper(data->>'code')) where collection='cashboxes';