Your steps for the migration :

   - Create the new table with your DocumentState class
   - Add a new column "state_id" for your foreign key
   - Foreach instance, find/create a state object and associate it.
   - Delete your state_ columns

Is it OK ?


2009/12/26 Dave <[email protected]>

> Thanks, but updating the structure is not the issue (the tools work
> pretty well for that).
>
> The problem is migrating the data.  The model for the "Document" table
> has changed in this example, thus the old columns are not in the model
> any more (and new columns are in the model that are not in the old
> table structure).
>
>
> Dave
> --
>
> On Dec 26, 2:54 am, Alexandre Salomé <[email protected]>
> wrote:
> > Migration in Doctrine offers you some "tools methods" : add column,
> create
> > table, delete table, delete column, create FK... methods to alter the
> > structure (see documentation<
> http://www.doctrine-project.org/documentation/manual/1_2/en/migrations>).
> > Model-stuff is still available.
> >
> > See this sample :
> http://www.doctrine-project.org/documentation/cookbook/1_0/en/symfony...
> >
> > Good luck, Alexandre
> >
> > 2009/12/24 Dave <[email protected]>
> >
> >
> >
> > > I am trying to determine the "proper" way to update data when using
> > > doctrine migrations.
> >
> > > Having a legacy table similar to
> >
> > >  Document -> id (PK), state (string, nn), state_code (string, nn),
> > > title (string, nn)
> >
> > > and changing it to be two tables similar to
> >
> > >  State -> id (PK), state (string, nn), state_code (string, nn), slug
> > > (string, nn, based on state_code)
> > >  Document -> id (PK), state_id (FK), title (string, nn), slug
> > > (string, nn, based on FK's state_code and title)
> >
> > > Adding the tables and adjusting the columns works fine, but so far it
> > > looks like I have to use Doctrine_Manager::connection()->getDbh() and
> > > perform the data changes via PDO since the models have changed enough
> > > that they cannot be used with the existing table.
> >
> > > Is there a more proper way to do the changes using Doctrine, or is
> > > bypassing Doctrine using PDO the best way (especially since there are
> > > many rows in the Document table).
> >
> > > --
> >
> > > You received this message because you are subscribed to the Google
> Groups
> > > "symfony users" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]<symfony-users%[email protected]>
> <symfony-users%[email protected]<symfony-users%[email protected]>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/symfony-users?hl=en.
> >
> > --
> > Alexandre Saloméhttp://alexandre-salome.fr
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "symfony users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<symfony-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en.
>
>
>


-- 
Alexandre Salomé
http://alexandre-salome.fr

--

You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.


Reply via email to