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

Use Schema methods instead of SQL #10

Closed
schoren opened this issue Nov 14, 2011 · 1 comment
Closed

Use Schema methods instead of SQL #10

schoren opened this issue Nov 14, 2011 · 1 comment

Comments

@schoren
Copy link

schoren commented Nov 14, 2011

I've noticed the generated migrations are using SQL instead of the Schema class methods. I think the most logic thing to do is to use those methods. Right now it generates a SQL command for the RDBM in use (in my case, mysql), but if i want to change to Postgres for example, i have to rebuild all my migrations.

@stof
Copy link
Member

stof commented Nov 14, 2011

This bundles simply integrates the Doctrine DataFixtures library. It does nothing about generating the code of the migrations, which is why I close this issue.

And the reason why DataFixtures uses SQL is that it gives the developer full power about adding additional queries at any state of the migration whereas the Schema does not. A good example where it is needed is the addition of a unique field in a table. If you do the full schema migration, it will fail as soon as there is at least 2 rows in the table because both are set to the same default value => not unique. DataFixtures generates 2 queries to do this migration: adding the field and then adding the unique constraint. This makes it possible to add a third query between them that populate the new field with some unique data (copying the primary key for instance)

@stof stof closed this as completed Nov 14, 2011
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