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

Fix docs example for migrate create #2284

Merged
merged 1 commit into from
Jun 4, 2024
Merged

Conversation

MasterOdin
Copy link
Member

@MasterOdin MasterOdin commented Jun 4, 2024

This reverts commit 1187a5b.

From #2263 (comment):

When you provide a class name, then we hit this line to get the filename:

$fileName = Util::mapClassNameToFileName($className);

which per the comment:

* Turn migration names like 'CreateUserTable' into file names like
* '12345678901234_create_user_table.php' or 'LimitResourceNamesTo30Chars' into
* '12345678901234_limit_resource_names_to_30_chars.php'.

The tests for this function also back up the behavior here:

public function providerMapClassNameToFileName(): array
{
return [
['CamelCase87afterSomeBooze', '/^\d{14}_camel_case_87after_some_booze\.php$/'],
['CreateUserTable', '/^\d{14}_create_user_table\.php$/'],
['LimitResourceNamesTo30Chars', '/^\d{14}_limit_resource_names_to_30_chars\.php$/'],
];
}
/**
* @dataProvider providerMapClassNameToFileName
*/
public function testMapClassNameToFileName(string $name, string $pattern): void
{
$this->assertMatchesRegularExpression($pattern, Util::mapClassNameToFileName($name));
}

I think the capitalization that the docs was changed to might be a cakephp/migrations thing and not what phinx itself does?

@dereuromark
Copy link
Member

Interesting. Might be then yeah
While it makes sense to have the name closer to the class name I guess this is a breaking change.
Feel free to merge

@MasterOdin
Copy link
Member Author

We could certainly make this a feature flag if it's desired behavior, though at that point, might be better to just go for filenames that adhere to PSR-4.

@MasterOdin MasterOdin merged commit a31003d into 0.x Jun 4, 2024
12 checks passed
@MasterOdin MasterOdin deleted the docs-migration-create branch June 4, 2024 14:08
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

Successfully merging this pull request may close these issues.

2 participants