سامانه صدور فاکتور و حسابداری
Add Iran enterprise foundation collections
davoodmehraban89 committed
Sep 30, 2026 at 01:42 UTC
97c7d61af60feb8b15224a10cbb2e48875582632
1 file changed
+15
supabase/migrations/20260929222000_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';