Reputation: 7337
I use the following code to build my tables from my models:
Doctrine::createTablesFromModels();
I'm just starting out on a new project and it is the first time I've used Doctrine in an application. So far, since I'm just getting started and don't have any data, I've just been dropping the tables in phpMyAdmin and running the code above every time I make a change to my models. Obviously, this won't be an option in a production environment.
Does Doctrine have a method or chunk of methods I can call that will drop and rebuild the tables without losing the existing data? Perhaps by saving it off to some temporary tables first? If not, what are my other options for accomplishing the same thing?
Or, am I going the totally wrong direction in letting Doctrine generate my tables? Should I just maintain them myself and keep my relationships and columns up to date in my models?
I'm using Doctrine 1.2 with the CodeIgniter framework.
Upvotes: 0
Views: 878
Reputation: 5317
I am using Doctrine2, here's what I've done in the past:
Note:: this could get hairy if you have triggers defined. Also is not a good idea for a production site unless its "Down for maintenance" type of situation.
see INSERT SELECT
Upvotes: 0
Reputation: 52372
Look into Doctrine Migrations, which are ways to script the changes between versions of your models/schema.
http://www.doctrine-project.org/projects/orm/1.2/docs/manual/migrations/en
Personally, I just make the changes to my schema then generate models from that.
Upvotes: 1