mysql-to-sqlite3
mysql-to-sqlite3 copied to clipboard
:sparkles: add table creation order computation with FK constraints
This pull request introduces enhancements to the MySQL-to-SQLite data transfer process, focusing on foreign key handling, schema metadata extraction, and table creation order computation. Additionally, unit tests have been expanded to ensure robust functionality and edge case coverage.
Enhancements to MySQL-to-SQLite data transfer:
-
Foreign key handling during transfer:
- Added computation of table creation order to respect foreign key constraints using the new
compute_creation_orderfunction. Tables are processed in a dependency-safe order, and cyclic dependencies are logged as warnings. - Implemented a post-transfer check for foreign key constraint violations in SQLite using
PRAGMA foreign_key_check. Violations are logged for debugging purposes.
- Added computation of table creation order to respect foreign key constraints using the new
-
Schema metadata extraction:
- Introduced the
fetch_schema_metadatafunction to retrieve table names and foreign key relationships from the MySQL schema. This ensures robust handling of various row formats and edge cases.
- Introduced the
Codebase improvements:
- Topological sorting for table creation:
- Added the
topo_sort_tablesfunction to perform topological sorting of tables based on foreign key dependencies. This ensures tables are created in a foreign key-safe order. Cyclic dependencies are identified and returned for further analysis.
- Added the
Unit test enhancements:
- Expanded test coverage for new functionality:
- Added tests for
topo_sort_tablesto verify behavior with acyclic, cyclic, and empty dependency graphs. - Added tests for
fetch_schema_metadatato ensure robust handling of diverse row formats, including tuples, lists, objects, dictionaries, and invalid types. - Added tests for
compute_creation_orderto validate table ordering and cycle detection in schemas with and without circular dependencies. - Enhanced
transfermethod tests to verify foreign key checks and exception handling during SQLite operations.
- Added tests for