Summary
After the fix for #52 (bare 500 on db apply's real-commit step), rayfin up db apply --force now returns a specific error instead of the old opaque one — but the error points at a foreign key that no longer exists anywhere in the live database, and the suggested remediation isn't actionable.
Environment
Repro
- Have an entity with a
@one(() => Target) relationship field, generating an FK column/constraint.
- Refactor that field to a plain scalar (a legitimate schema change — in our case,
@one(() => Product) became a denormalized @text() part-number field).
rayfin up db apply (no force) — fails cleanly with an unrelated destructive-change 400 guard on other pending drops. Expected.
rayfin up db apply --force.
Expected
Migration reconciles current entity state against actual live DB state, and applies cleanly (or fails referencing objects that actually exist).
Actual
❌ Failed to apply configuration to remote endpoint
DAB server responded with error: 409 Conflict
Details: The migration expected a database object that no longer exists — the database may have been changed outside Rayfin. Database reported: "'FK_DqExceptionProducts_product_id' is not a constraint.
Could not drop constraint. See previous errors.".
RootActivityId: b0fc839e-6afc-4eb7-9e9f-1e6bcf08b0f0
Queried the live warehouse directly (sys.foreign_keys, sys.columns): no product_id column exists on the table, no FK_DqExceptionProducts_product_id constraint exists under any name — only FK_DqExceptionProducts_rule_id is real. The error's own suggested fix ("Restore the object, then re-apply") isn't actionable: there's no product_id column left in the current entity model to restore a matching FK to.
This looks like Rayfin's server-side tracked deployment/migration history for this item still references a relationship removed from the entity definitions a while ago, and reconciliation assumes that object still exists rather than diffing against the DB's actual current state.
Additional context
Summary
After the fix for #52 (bare
500ondb apply's real-commit step),rayfin up db apply --forcenow returns a specific error instead of the old opaque one — but the error points at a foreign key that no longer exists anywhere in the live database, and the suggested remediation isn't actionable.Environment
db applycycles since — same item referenced in up db apply: 500 Internal Server Error on every existing/pre-deployed item — new deploys succeed #52)Repro
@one(() => Target)relationship field, generating an FK column/constraint.@one(() => Product)became a denormalized@text()part-number field).rayfin up db apply(no force) — fails cleanly with an unrelated destructive-change 400 guard on other pending drops. Expected.rayfin up db apply --force.Expected
Migration reconciles current entity state against actual live DB state, and applies cleanly (or fails referencing objects that actually exist).
Actual
Queried the live warehouse directly (
sys.foreign_keys,sys.columns): noproduct_idcolumn exists on the table, noFK_DqExceptionProducts_product_idconstraint exists under any name — onlyFK_DqExceptionProducts_rule_idis real. The error's own suggested fix ("Restore the object, then re-apply") isn't actionable: there's noproduct_idcolumn left in the current entity model to restore a matching FK to.This looks like Rayfin's server-side tracked deployment/migration history for this item still references a relationship removed from the entity definitions a while ago, and reconciliation assumes that object still exists rather than diffing against the DB's actual current state.
Additional context
db applyimmediately after, got the same baseline 400 as before the force attempt — DB left consistent.500on every attempt regardless of schema content; this is a specific, correctly-surfaced409pointing at genuinely stale tracked state — a different failure mode.