perhaps i'm a bit old-fashioned, but i don't allow automatic SQL migrations 
on production.  what i tend to do:
 - use automatic migrations in develop
 - record the SQL executed.
 - create a script that combines the migration SQL web2py generates with my 
data migration.
 - put production into maintenance mode
 - run SQL migration script
 - update source code
 - turn production back on

so in your case my SQL migration script would:
 - create the new table
 - copy phone numbers into the new table from the existing table
 - drop the phone number column from the existing table.

that's my perspective on the problem, good luck!

christian

On Sunday, March 24, 2013 4:29:19 AM UTC-7, Loïc wrote:
>
> Hello all,
>
> let's imagine I have an app with the following model : 
>
> db.define_table('contact',
>     Field('name'),
>     Field('phone_number')
> )
>
> I have already deployed my app, and I have several contacts with a name 
> and a phone number.
>
> Then I realise that a contact can have multiple phone numbers. So I add a 
> table :
>
> db.define_table('phone number',
>     Field('type'), #mobile phone number, home phone number, business 
> phone number ,...
>     Field('phone_number'),
>     Field('contact', 'reference contact'),
> )
>
> The first time I launch my app with the new model, I want to move existing 
> phone numbers from *contact *table to *phone_number *table.
> Then I want to remove 'phone_number' field from contact table to avoid 
> using it in the future
>
> What is the best way to do this automatically, and without breaking 
> backward compatibility?
>
> Thank you
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to