SQL to Migration for CodeIgniter 4 - Release Notes
v1.0.0 - 2025-09-08
Overview
We are excited to announce the initial release of SQL to Migration, a Spark command for CodeIgniter 4 that converts SQL dump files (e.g., from phpMyAdmin) into migration files. This release marks the foundation of a tool designed to streamline database migration workflows for CodeIgniter developers.
Key Features
- Table Creation: Generates migration files from
CREATE TABLEstatements, supporting column types (INT,VARCHAR, etc.),UNSIGNED,NOT NULL,AUTO_INCREMENT, andPRIMARY KEY. - Foreign Key Support: Parses
ALTER TABLEforeign key definitions, includingON DELETEandON UPDATEactions (SET NULL,NO ACTION,CASCADE,RESTRICT,SET DEFAULT). - Trigger Handling: Creates migration files for
CREATE TRIGGERstatements (BEFORE/AFTER,INSERT/UPDATE/DELETE). - Prefix Management: Automatically strips database prefixes (e.g.,
ci4ms_) based ondatabase.default.DBPrefixin.env. - CLI Debugging: Provides detailed logs for troubleshooting via the command line.
Installation
Install via Composer:
composer require yourvendor/sql-to-migrationAdd to app/Config/Autoload.php:
public $psr4 = [
APP_NAMESPACE => APPPATH,
'Config' => APPPATH . 'Config',
'YourVendor\SqlToMigration' => VENDORPATH . 'yourvendor/sql-to-migration/src',
];Run the command:
php spark sql2migration /path/to/your/database.sqlKnown Issues
- Limited support for complex SQL constraints (e.g., multi-column foreign keys). Future releases will address this.
- Trigger parsing assumes standard MySQL syntax; non-standard formats may require adjustments.
Fixed Issues
- Resolved issue where
SET NULLandNO ACTIONin foreign keys were partially parsed (only first word captured).
Next Steps
- Plan to add support for additional SQL features (e.g., indexes, multi-column keys) in v1.1.0.
- Improve documentation with advanced usage examples.
Changelog
- v1.0.1 (2025-09-08): Updated README with detailed usage examples and troubleshooting guide.
- v1.0.0 (Initial Release): Initial release with SQL to migration conversion support.
Contributions
We welcome feedback and contributions! Report issues or submit pull requests at github.com/yourusername/sql-to-migration. Thank you for trying out this release!