the code can definitely check for the "requirements" and activate some kind
of migration of data, but I'd manage it outside the web process (i.e., I'll
prepare a script meant to be run as webp2y.py -M -S appname -R
upgradescript.py)
On Monday, March 25, 2013 9:10:58 AM UTC+1, Loïc wrote:
>
> Thanks Mika,
>
> But my question was more about the model :
> If I delete phone_number field from my 'contact' table, I won't be able to
> access it and dump previous data.
> I could keep phone_number in 'contact' table and comment something like "#
> depreceated field, do not use anymore" but I think this is messy
>
> So is it possible do do something like :
>
> *if db.myTable.myField.exists():
> #move the content of myField to another table
> db.myTable.myField.remove()*
>
> Thank you
>
>
> Le dimanche 24 mars 2013 16:01:57 UTC+1, Mika Sjöman a écrit :
>>
>> Hi
>>
>> Maybe you could dump it to a phone numbers to a csv file or a python dict
>> with dump_data = { phone_number : contact.id,....}
>>
>> Then when you created the second table, just run a for loop to populate
>> that table with the dumped data with contact_id as a reference to the old
>> table.
>>
>> Thats what I would do....
>>
>> // web2py rookie
>>
>> cheers
>>
>>
>> Den söndagen den 24:e mars 2013 kl. 19:29:19 UTC+8 skrev Loïc:
>>>
>>> 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.