books/backend/Books.Api/Database/Migrations/022_DropPeriodNameUniqueConstraint.sql
Nicolaj Hartmann 1f75c5d791 Add all backend domain, commands, repositories, and tests
This commit includes all previously untracked backend files:

Domain:
- Accounts, Attachments, BankConnections, Customers
- FiscalYears, Invoices, JournalEntryDrafts
- Orders, Products, UserAccess

Commands & Handlers:
- Full CQRS command structure for all domains

Repositories:
- PostgreSQL repositories for all read models
- Bank transaction and ledger repositories

GraphQL:
- Input types, scalars, and types for all entities
- Mutations and queries

Infrastructure:
- Banking integration (Enable Banking client)
- File storage, Invoicing, Reporting, SAF-T export
- Database migrations (003-029)

Tests:
- Integration tests for GraphQL endpoints
- Domain tests
- Invoicing and reporting tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:19:42 +01:00

11 lines
516 B
SQL

-- 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 $$;