Skip to content

fix(db): move clan_members table definition before data migrations (#82) - #127

Open
angelTomo9 wants to merge 2 commits into
Bitcoindefi:mainfrom
angelTomo9:fix-db-clan-members-migration-order-1787652048857
Open

fix(db): move clan_members table definition before data migrations (#82)#127
angelTomo9 wants to merge 2 commits into
Bitcoindefi:mainfrom
angelTomo9:fix-db-clan-members-migration-order-1787652048857

Conversation

@angelTomo9

Copy link
Copy Markdown

Closes #82

Summary of Changes

Reorders table creations and constraints in api/schema.sql so that clan_members, foreign keys, and indexes are created before executing data migration queries that query clan_members.

Features & Deliverables

  • Table Definition Ordering: Moved CREATE TABLE IF NOT EXISTS clan_members, ALTER TABLE characters ADD COLUMN IF NOT EXISTS clan_id, constraints, and indexes before the member compatibility alignment cleanup CTEs.
  • Strict Error Handling: Added \set ON_ERROR_STOP on at the beginning of api/schema.sql to prevent schema execution from silently continuing if errors occur.
  • Idempotency: Maintained complete idempotency with IF NOT EXISTS / DROP CONSTRAINT IF EXISTS guards.

Comment thread api/schema.sql Outdated
@gitar-bot

gitar-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Reorders schema definitions and constraints in api/schema.sql to execute before dependent data migrations, addressing the psql meta-command driver compatibility issue. No issues found.

✅ 1 resolved
Bug: psql meta-command \set breaks driver-based migration

📄 api/schema.sql:1
\set ON_ERROR_STOP on is a psql client meta-command, not valid SQL. schema.sql is not run through the psql CLI — it is read and sent to PostgreSQL via the node-postgres driver (pool.query(schemaSql) in api/src/migrate.ts:9). The server will reject line 1 with syntax error at or near "", aborting the entire migration on every run. Remove line 1; the simple-query protocol already runs the batch in one implicit transaction that stops at the first error, so the intended strict behavior is retained without the meta-command.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Important

Your trial ends in 7 days — upgrade now to keep code review, CI analysis, auto-apply, custom automations, and more.

Was this helpful? React with 👍 / 👎 | Gitar

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.

schema.sql aplica tres migraciones sobre clan_members antes de crear la tabla

1 participant