asxpio/db/migrations
Sergei Poljanski 969101600d
db: scope invoices to owner, add void + snapshot columns
- owner_id (FK users, ON DELETE RESTRICT) + index on (owner_id, created_at DESC)
- client_id (nullable FK clients, ON DELETE RESTRICT) for client back-references
- issuer_snapshot jsonb + snapshot_version: invoices freeze the issuer's
  legal-entity fields at issue time so historical PDFs render unchanged when
  the user later edits their profile
- voided_at + voided_reason: soft-void instead of delete, since invoices
  are retained indefinitely
- swap unique(number) for unique(owner_id, number): numbers are now per-user,
  not global

DROP CONSTRAINT uses IF EXISTS so the migration is resilient to the
auto-generated constraint name differing across Postgres versions.
2026-05-26 19:09:33 +03:00
..
001_invoices.rb db: connection helper and invoices migration 2026-05-26 17:43:18 +03:00
002_users_and_password_tokens.rb db: users + password_tokens migration 2026-05-26 19:07:55 +03:00
003_issuer_profiles_and_clients.rb db: issuer_profiles + clients migration 2026-05-26 19:08:55 +03:00
004_scope_invoices_to_owner.rb db: scope invoices to owner, add void + snapshot columns 2026-05-26 19:09:33 +03:00