On Thursday, April 20, 2017 at 6:49:06 AM UTC-4, Áureo Dias Neto wrote:
>
> Yes, I'm working with legacy tables that were already existing in MySql 
> before you hooked your application to that databases, and I added fields to 
> my models, and this not reflect on the db
>

If you never used web2py to do any migrations, then web2py doesn't know 
about the current state of your database -- you have to run fake_migrate to 
let it know that your model definitions reflect the current database 
schema. From that point on, you can enable migrations, and model changes 
will be propagated to the database schema (for the most part -- changes to 
things like "notnull" and "unique" will not affect the database, as those 
attributes can only be specified when web2py first creates the table).

If you changed your Bank model without changing its database schema and 
then run fake_migrate, web2py will not update the schema in the database. 
That is the point of fake_migrate -- you are only telling web2py to update 
its metadata about the database state -- it assumes the database is already 
in that state. If you want web2py to actually change the database, run 
fake_migrate with the *old* Bank model. Then turn on migrations and change 
the Bank model, and web2py will make the change in the database schema.

Also, note that there is no difference in how web2py treats SQLite or MySQL 
with regard to migrations being automatic. If you use web2py to create the 
tables to begin with, web2py will handle everything automatically from the 
start, whichever database you use. On the other hand, if you start with an 
existing database, you must start with a set of models that reflect the 
current database schema and run fake_migrate so web2py knows the state of 
the database. From that point, web2py can manage migrations.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to