12 lines
516 B
MySQL
12 lines
516 B
MySQL
|
|
-- 022_DropPeriodNameUniqueConstraint.sql
|
||
|
|
-- Fixes multi-tenant issue where multiple companies can have periods with same name.
|
||
|
|
-- The Ledger's accounting_periods table had a global unique constraint on 'name',
|
||
|
|
-- but in a multi-tenant system each company needs their own "2025", "2026" etc. periods.
|
||
|
|
|
||
|
|
DO $$
|
||
|
|
BEGIN
|
||
|
|
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'accounting_periods') THEN
|
||
|
|
ALTER TABLE accounting_periods DROP CONSTRAINT IF EXISTS uq_period_name;
|
||
|
|
END IF;
|
||
|
|
END $$;
|