Bug: Migrations do not support hyphens
Closed this issue · 2 comments
PHP Version
8.2
CodeIgniter4 Version
4.5.5
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter
)
Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
MariaDB 11.3.2
What happened?
Migration files created with php spark make:migration
fail to be detected by migrate:status
if hyphens (-
) are used in the name.
Steps to Reproduce
PS C:\wamp64\www\codeigniter> php spark make:migration my-first-migration
CodeIgniter v4.5.5 Command Line Tool - Server Time: 2024-09-07 16:58:44 UTC+00:00
File created: APPPATH\Database\Migrations\2024-09-07-165844_My-first-migration.php
PS C:\wamp64\www\codeigniter> php spark migrate:status
CodeIgniter v4.5.5 Command Line Tool - Server Time: 2024-09-07 16:58:46 UTC+00:00
+----------------------+-------------------+---------------------+---------+---------------------+-------+
| Namespace | Version | Filename | Group | Migrated On | Batch |
+----------------------+-------------------+---------------------+---------+---------------------+-------+
| CodeIgniter\Shield | 2020-12-28-223112 | create_auth_tables | default | 2024-09-07 16:36:09 | 1 |
| CodeIgniter\Settings | 2021-07-04-041948 | CreateSettingsTable | default | 2024-09-07 16:36:09 | 1 |
| CodeIgniter\Settings | 2021-11-14-143905 | AddContextColumn | default | 2024-09-07 16:36:09 | 1 |
+----------------------+-------------------+---------------------+---------+---------------------+-------+
Expected Output
PS C:\wamp64\www\codeigniter> php spark make:migration my_first_migration
CodeIgniter v4.5.5 Command Line Tool - Server Time: 2024-09-07 16:59:00 UTC+00:00
File created: APPPATH\Database\Migrations\2024-09-07-165900_MyFirstMigration.php
PS C:\wamp64\www\codeigniter> php spark migrate:status
CodeIgniter v4.5.5 Command Line Tool - Server Time: 2024-09-07 16:59:02 UTC+00:00
+----------------------+-------------------+---------------------+---------+---------------------+-------+
| Namespace | Version | Filename | Group | Migrated On | Batch |
+----------------------+-------------------+---------------------+---------+---------------------+-------+
------------> **_| App | 2024-09-07-165900 | MyFirstMigration | --- | --- | --- |_** <------------
| CodeIgniter\Shield | 2020-12-28-223112 | create_auth_tables | default | 2024-09-07 16:36:09 | 1 |
| CodeIgniter\Settings | 2021-07-04-041948 | CreateSettingsTable | default | 2024-09-07 16:36:09 | 1 |
| CodeIgniter\Settings | 2021-11-14-143905 | AddContextColumn | default | 2024-09-07 16:36:09 | 1 |
+----------------------+-------------------+---------------------+---------+---------------------+-------+
Anything else?
Please accept my apologies if this was previously reported, or if I am doing something incorrectly. I am new to CodeIgniter and this caused me a lot of grief when following the docs at https://codeigniter.com/user_guide/dbmgmt/forge.html
Thank you for your time :)
You cannot use hyphens, because My-first-migration
is an invalid classname.
See https://codeigniter4.github.io/CodeIgniter4/dbmgmt/migration.html#migration-file-names
The following command is invalid. Because the usage is php spark make:migration <class> [options]
.
my-first-migration
is not a valid classname.
PS C:\wamp64\www\codeigniter> php spark make:migration my-first-migration
See https://codeigniter4.github.io/CodeIgniter4/dbmgmt/migration.html#make-migration