Skip to content

Doctrine Migrations #62

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

Closed
wants to merge 4 commits into from
Closed

Doctrine Migrations #62

wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented May 11, 2017

This recipe adds doctrine migrations to the official Symfony recipes repository.

@ghost ghost mentioned this pull request May 11, 2017
@ghost ghost changed the title Added DoctrineMigrationsBundle. Doctrine Migrations May 11, 2017
javiereguiluz
javiereguiluz previously approved these changes May 11, 2017
dir_name: '%kernel.project_dir%/DoctrineMigrations'
namespace: App\Migrations
table_name: migration_versions
name: Application Migrations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the table_name and the name from this config, as requested in #57. We don't need to configure them explicitly in the project.

I would even remove the explicit configuration of the namespace here, keeping the default one. I don't see any reason to change it here (one could argue that you want to make the namespace fit your app, but your config will not make it compatible with PSR-4 anyway so this is a bad argument. And when using advanced feature to organize files per date instead of having a single folder with hundred of migrations, you cannot make code inside this folder fit PSR-4 at all, so I would not even try it).
This would then leave only the dir_name config (which is the one we really need due to the new Flex structure)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree! Changed in 5bace25.

@stof
Copy link
Member

stof commented May 11, 2017

@fabpot there was some discussion in the past about forcing bundles to use their DI alias for the naming of the YAML config file they add in packages (which is not the case here, due to migrations.yaml vs doctrine_migrations). Is it something we want to enforce ?

@@ -0,0 +1,2 @@
doctrine_migrations:
dir_name: '%kernel.project_dir%/DoctrineMigrations'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All directory names are using the underscore notation, having a DoctrineMigrations directory at the root of the project looks weird. What about something like '%kernel.project_dir%/etc/migrations' instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also add etc/migrations/.gitkeep to the PR so that the directory is automatically created when installing the bundle.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabpot Should src/migrations not be src/Migrations. Because the Entity folder has a capital letter to in the directory. Let me know, I've added it with a Capital letter for now.

@@ -0,0 +1,2 @@
doctrine_migrations:
dir_name: '%kernel.project_dir%/DoctrineMigrations'
Copy link
Member

@stof stof May 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in #57, we said that migrations should live inside src (as they are code), not at the root

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabpot do you think migration classes should go in src or etc ? Your previous comment suggests etc, but migrations are code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, that should be src/, not etc/.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense to use singular Migration instead of Migrations for the namespace?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rybakit We only changed the default directory for now. If you want to customize the namespace or another setting of the bundle I suggest you take a look at the options at http://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html#configuration

/cc @fabpot @stof @javiereguiluz Might be a idea to add "env": {} to the manifest file with a link to doc/current/bundles/DoctrineMigrationsBundle/?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ricknox Sorry, I meant if singular src/Migration as the default directory would be more appropriate here (as the migrations are php classes, and most of the libraries use singular names in their namespace to describe the domain, fe https://github.com/symfony/recipes/blob/master/doctrine/doctrine-bundle/1.6/etc/packages/doctrine.yaml#L12)

@fabpot
Copy link
Member

fabpot commented May 11, 2017

@stof is right, you rename migrations.yaml to doctrine_migrations.yaml

@fabpot
Copy link
Member

fabpot commented May 11, 2017

Thank you @Ricknox.

@fabpot fabpot closed this in 0c15942 May 11, 2017
@ghost ghost deleted the feature/doctrine-migrations branch May 11, 2017 20:13
VolCh pushed a commit to VolCh/recipes that referenced this pull request Nov 30, 2017
This PR was merged into the master branch.

Discussion
----------

Move etc/ to config/ and web/ to public/

| Q             | A
| ------------- | ---
| License       | MIT

Must be merged just after symfony/flex#122

Commits
-------

11c3e5e moved etc/ to config/ and web/ to public/
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.

5 participants