Skip to content

fix(db): define clan_members before applying data migrations (#82) - #99

Open
angelTomo9 wants to merge 2 commits into
Bitcoindefi:mainfrom
angelTomo9:fix/schema-clan-members-order-82
Open

fix(db): define clan_members before applying data migrations (#82)#99
angelTomo9 wants to merge 2 commits into
Bitcoindefi:mainfrom
angelTomo9:fix/schema-clan-members-order-82

Conversation

@angelTomo9

Copy link
Copy Markdown

Resumen de cambios

Resuelve #82 reordenando api/schema.sql para que la tabla clan_members, sus columnas referenciadas (characters.clan_id), constraints e indices se definan antes de las consultas de migracion de datos que referencian clan_members.

Puntos clave

  • Definicion previa de tablas: clan_members y clan_requests se crean antes de los CTEs de limpieza de miembros incompatibles.
  • Fail-Fast: Anadido \set ON_ERROR_STOP on al inicio de schema.sql para garantizar que cualquier error aborte el proceso en CI.
  • Idempotencia: Todas las sentencias mantienen IF NOT EXISTS.

Closes #82

Comment thread api/schema.sql Outdated
@angelTomo9

Copy link
Copy Markdown
Author

Fixed! Removed the \set ON_ERROR_STOP on meta-command in 86bd0d6 to ensure pure SQL compatibility with node-postgres pool.query() inside migrate.ts.

@gitar-bot

gitar-bot Bot commented Aug 19, 2026

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

Reorders schema.sql to define clan_members before data migration queries and removes the psql meta-command, addressing the migration runner startup failure. No issues found.

✅ 1 resolved
Bug: psql meta-command \set breaks pg-based migration at startup

📄 api/schema.sql:1
\set ON_ERROR_STOP on is a psql client meta-command, not SQL. migrate.ts applies the file via node-postgres pool.query(schemaSql), which sends it over the wire protocol where the server rejects the leading backslash with syntax error at or near "". Since the container's CMD ["pnpm", "start"] runs pnpm run migrate (node dist/migrate.js) before the server, every app startup will now fail. Remove line 1 — the pg simple-query protocol already wraps the multi-statement string in an implicit transaction that aborts and rolls back on the first error, so the desired fail-fast behavior is preserved without the psql directive.

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         

Was this helpful? React with 👍 / 👎 | Gitar

@angelTomo9

Copy link
Copy Markdown
Author

All feedback from code review has been resolved and approved by CI/review bots. @Bitcoindefi maintainers, ready for merge when convenient! Thank you.

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