Fix/236 unique index before self fk#705
Conversation
Summary
Background / MotivationWhen a resource uses:
the migration generator previously produced migrations where the foreign key on Fixes issue: #236 Implementation
How to testFrom the Run the focused regression testmix test test/migration_generator_test.exs --only issue_236 Run the full test suitemix test Static analysis (as per project conventions)mix credo |
Made-with: Cursor
| identity: identity, | ||
| schema: snapshot.schema, | ||
| table: snapshot.table, | ||
| insert_after_attribute_order: max(0, length(snapshot.attributes) - 1), |
There was a problem hiding this comment.
Doesn't this just end up placing them at the end if its using the max order?
There was a problem hiding this comment.
If its being used to sort after a given attribute then it would make sense to track the name instead I think.
There was a problem hiding this comment.
You’re right, the original code effectively used the last attribute order. I’ll update it so insert_after_attribute_order is computed from the identity keys’ attribute names, and so it tracks the highest attribute order among those keys instead of length(attributes) - 1.
|
Updated |
| identity: identity, | ||
| schema: snapshot.schema, | ||
| table: snapshot.table, | ||
| insert_after_attribute_order: insert_after_attribute_order, |
There was a problem hiding this comment.
Could we not just store the attribute name here as opposed to the order?
There was a problem hiding this comment.
Yes we can. Submitting a fix right now!
|
Updated to track attribute source (name) instead of numeric order. |
|
Awesome, lets pull |
|
So, what's happening with the checks is a bit strange, because locally mix format --check-formatted, mix credo --strict, and mix test all pass. The REUSE check is failing on two generated files:
These aren’t part of the repo and are created by the test/migration generator step in CI (the filenames are timestamped). I didn’t commit them or add headers since they change every run; happy to adjust if you’d prefer a change in how/where those are generated or in REUSE config. |
|
That file does indeed appear to be committed. But yeah the |
|
🚀 Thank you for your contribution! 🚀 |
Contributor checklist
Leave anything that you believe does not apply unchecked.