Refactor constraint deferral to derive table from FK metadata#21
Refactor constraint deferral to derive table from FK metadata#21
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors how self-referencing FK constraints are temporarily deferred during table copy operations by introducing a general-purpose ConstraintDeferrer that operates directly on MForeignKey metadata, while also centralizing schema-qualified quoting helpers in SlickProfile.
Changes:
- Replace per-table
SelfRefConstraintswith a reusableConstraintDeferrerthat defers/restores constraints derived fromMForeignKeymetadata. - Move schema-qualified quoting logic into
SlickProfile.quoteQualified, including anMQNameoverload. - Update
TableCopierto select self-referencing FKs from cachedDbContext.allForeignKeysand delegate deferral toConstraintDeferrer.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| simple-anonymizer/src/scala/simpleanonymizer/TableCopier.scala | Switches self-ref FK selection/deferral to ConstraintDeferrer and refactors sequence reset quoting. |
| simple-anonymizer/src/scala/simpleanonymizer/SlickProfile.scala | Adds quoteQualified helpers (including MQName overload) under SlickProfile. |
| simple-anonymizer/src/scala/simpleanonymizer/SelfRefConstraints.scala | Removes the old table-specific self-ref constraint deferral implementation. |
| simple-anonymizer/src/scala/simpleanonymizer/CopyAction.scala | Uses SlickProfile.quoteQualified instead of CopyAction.qualifiedTable. |
| simple-anonymizer/src/scala/simpleanonymizer/ConstraintDeferrer.scala | Introduces a reusable FK deferral/restoration utility based on MForeignKey metadata. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7640b8a to
b42c7d9
Compare
b42c7d9 to
737effd
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
737effd to
b2598da
Compare
…etadata Replace SelfRefConstraints with ConstraintDeferrer, a general-purpose utility that takes MForeignKey objects directly and derives table names from fkTable (MQName) instead of accepting explicit tableName parameters. Move qualifiedTable from CopyAction to SlickProfile as quoteQualified, with an MQName overload that extracts schema from the metadata object. The caller (TableCopier) now filters allForeignKeys for self-referencing FKs and passes them to ConstraintDeferrer, separating constraint selection from deferral mechanics. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
deferAll and restoreDeferrability now return DBIO instead of Future, using DBIO.traverse to run all ALTERs in a single db.run call (one connection checkout) and asTry for error recovery at the DBIO level. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
b2598da to
e87d16a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
If the by-name body parameter throws synchronously instead of returning a failed Future, restoreDeferrability would never run. Future.delegate safely wraps the evaluation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
SelfRefConstraintswithConstraintDeferrer, a general-purpose utility that takesMForeignKeyobjects directly and derives table names fromfkTable(MQName) instead of accepting explicittableNameparametersqualifiedTablefromCopyActiontoSlickProfileasquoteQualified, with anMQNameoverload that schema-qualifies using the metadata objectTableCopiernow filtersallForeignKeysfor self-referencing FKs and passes them toConstraintDeferrer, separating constraint selection from deferral mechanicsTest plan
bleep test tests— all 7 suites)bleep test integration-tests— requires Docker)🤖 Generated with Claude Code