-
-
Notifications
You must be signed in to change notification settings - Fork 34
✨ add support for deferred foreign keys via -D/--defer-foreign-keys #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
WalkthroughA new CLI flag Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant CLI as CLI
participant Transporter as MySQLtoSQLite
participant SQLite as SQLite DB
User->>CLI: Run with --defer-foreign-keys
CLI->>Transporter: Instantiate with defer_foreign_keys=True
Transporter->>SQLite: Create tables (DEFERRABLE INITIALLY DEFERRED)
Transporter->>SQLite: Transfer data
Transporter->>SQLite: PRAGMA foreign_keys=ON
Transporter->>SQLite: PRAGMA foreign_key_check
SQLite-->>Transporter: Return violations (if any)
Transporter->>CLI: Log warnings/info about violations
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🧰 Additional context used🧬 Code Graph Analysis (1)tests/unit/test_transporter.py (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (9)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #101 +/- ##
==========================================
- Coverage 94.40% 93.82% -0.58%
==========================================
Files 8 8
Lines 643 664 +21
==========================================
+ Hits 607 623 +16
- Misses 36 41 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ng of MariaDB-specific default translations (`curtime()`, `curdate()`, `current_timestamp()`, and `now()`)
…_sqlite` to improve readability
This pull request introduces a new feature to defer foreign key constraints during the transfer process from MySQL to SQLite, along with validation for foreign key constraints after the transfer. It also includes related updates to the CLI, transporter logic, and type definitions. Below is a summary of the most important changes:
New Feature: Deferred Foreign Key Constraints
Added a new CLI option
-D/--defer-foreign-keys
to allow deferring foreign key constraints until the end of the transfer. This ensures better handling of foreign key dependencies during the transfer process. (src/mysql_to_sqlite3/cli.py
, [1] [2] [3]Updated the transporter logic to support the
defer_foreign_keys
option. If enabled, foreign keys are marked asDEFERRABLE INITIALLY DEFERRED
in the generated SQLite schema, provided the SQLite version supports it. (src/mysql_to_sqlite3/transporter.py
, [1] [2]Validation of Foreign Key Constraints
src/mysql_to_sqlite3/transporter.py
, src/mysql_to_sqlite3/transporter.pyR770-R795)Type Definitions and Tests
Updated type definitions in
MySQLtoSQLiteParams
andMySQLtoSQLiteAttributes
to include the newdefer_foreign_keys
attribute. (src/mysql_to_sqlite3/types.py
, [1] [2]Updated unit tests to verify the behavior of foreign key validation by replacing the call to
PRAGMA foreign_keys=ON
withPRAGMA foreign_key_check
. (tests/unit/test_transporter.py
, tests/unit/test_transporter.pyL153-R153)