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: The same migration name can be created in multiple directories. #1054

Closed
rquadling opened this issue Mar 6, 2017 · 3 comments
Closed
Labels

Comments

@rquadling
Copy link
Collaborator

If using multiple migration paths, only the chosen path at migration creation time is verified for the class name being unique, not all the other migration paths.

As such, the duplication is only realised when all the migrations are interacted with, say via a phinx status call.

Possibly/probably also true for using multiple seed paths.

With a phinx.yml of

paths:
    migrations:
      - %%PHINX_CONFIG_DIR%%/db/migrations/1-Tables
      - %%PHINX_CONFIG_DIR%%/db/migrations/2-Views
    seeds: %%PHINX_CONFIG_DIR%%/db/seeds
...

And the following steps.

$ bin/phinx create Number1
Phinx by Rob Morgan - https://phinx.org. 0.8.0

using config file ./phinx.yml
using config parser yaml
using migration paths 
 - /Users/richardquadling/dev/php/robmorgan/db/migrations/1-Tables
 - /Users/richardquadling/dev/php/robmorgan/db/migrations/2-Views
using seed paths 
Which migrations path would you like to use?
  [0] /Users/richardquadling/dev/php/robmorgan/db/migrations/1-Tables
  [1] /Users/richardquadling/dev/php/robmorgan/db/migrations/2-Views
 > 0
using migration base class Phinx\Migration\AbstractMigration
using default template
created /db/migrations/1-Tables/20170306121851_number1.php

$ bin/phinx create Number1
Phinx by Rob Morgan - https://phinx.org. 0.8.0

using config file ./phinx.yml
using config parser yaml
using migration paths 
 - /Users/richardquadling/dev/php/robmorgan/db/migrations/1-Tables
 - /Users/richardquadling/dev/php/robmorgan/db/migrations/2-Views
using seed paths 
Which migrations path would you like to use?
  [0] /Users/richardquadling/dev/php/robmorgan/db/migrations/1-Tables
  [1] /Users/richardquadling/dev/php/robmorgan/db/migrations/2-Views
 > 1
using migration base class Phinx\Migration\AbstractMigration
using default template
created /db/migrations/2-Views/20170306121857_number1.php

$ bin/phinx status
Phinx by Rob Morgan - https://phinx.org. 0.8.0

using config file ./phinx.yml
using config parser yaml
using migration paths 
 - /Users/richardquadling/dev/php/robmorgan/db/migrations/1-Tables
 - /Users/richardquadling/dev/php/robmorgan/db/migrations/2-Views
using seed paths 
warning no environment specified, defaulting to: development
ordering by creation time

                                                                                            
  [InvalidArgumentException]                                                                
  Migration "20170306121857_number1.php" has the same name as "20170306121851_number1.php"  
                                                                                            

status [-c|--configuration CONFIGURATION] [-p|--parser PARSER] [-e|--environment ENVIRONMENT] [-f|--format FORMAT]
@tariquesani
Copy link

#1070 Pull request solves this issue, is mergeable and passes all tests

@rquadling
Copy link
Collaborator Author

I think independently of namespaces, even with multiple directories, the class name must be unique across all paths. Currently, the isUniqueMigrationClassName() call supplies a class and a path and only verifies that the class is unique in that path. All paths should be examined.

@othercorey
Copy link
Member

Added in #1070. If there are changes requested please open a PR.

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

No branches or pull requests

3 participants