Skip to content
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

Bug: Migrations do not support hyphens #9177

Closed
wrongecho opened this issue Sep 7, 2024 · 2 comments
Closed

Bug: Migrations do not support hyphens #9177

wrongecho opened this issue Sep 7, 2024 · 2 comments

Comments

@wrongecho
Copy link

wrongecho commented Sep 7, 2024

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 :)

@wrongecho wrongecho added the bug Verified issues on the current code behavior or pull requests that will fix them label Sep 7, 2024
@kenjis kenjis removed the bug Verified issues on the current code behavior or pull requests that will fix them label Sep 8, 2024
@kenjis
Copy link
Member

kenjis commented Sep 8, 2024

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

@kenjis
Copy link
Member

kenjis commented Sep 8, 2024

I sent PR #9179

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants