Skip to content

feat: add core database schema migrations#18

Merged
Lewiskunta merged 2 commits into
mainfrom
feat/core-migrations
Jun 3, 2026
Merged

feat: add core database schema migrations#18
Lewiskunta merged 2 commits into
mainfrom
feat/core-migrations

Conversation

@Lewiskunta

Copy link
Copy Markdown
Contributor

Implements: complete database schema for Ratify.

Creates 16 tables in dependency order:
organizations, teams, users, team_members, api_keys,
database_connections, contracts, contract_versions,
contract_columns, consumer_registrations, proposals,
proposal_changes, consumer_responses, breaches,
audit_events, notification_logs

Design decisions:

  • All primary keys: UUID with gen_random_uuid()
  • All timestamps: TIMESTAMPTZ (UTC, timezone-aware)
  • All foreign keys: explicit REFERENCES constraints
  • Indexes on all FK columns to prevent slow JOIN queries
  • audit_events has no updated_at , append-only by design
  • Partial unique index on contracts enforces one active contract per table per connection
  • Encrypted fields stored as TEXT (AES-256-GCM output)
  • JSONB for schema snapshots, constraint definitions, change values, structured but schema-flexible

Verified:

  • Both migrations apply cleanly on docker compose up
  • Down migration drops all 16 tables cleanly
  • Re-applying up migration restores everything

@Lewiskunta Lewiskunta merged commit d7c7bb3 into main Jun 3, 2026
4 checks passed
@Lewiskunta Lewiskunta deleted the feat/core-migrations branch June 3, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant