Changes between Version 2 and Version 3 of Recipes/SQLAlchemySchemaMigration

Show
Ignore:
Timestamp:
12/05/10 01:13:51 (2 years ago)
Author:
guest (IP: 78.232.186.148)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Recipes/SQLAlchemySchemaMigration

    v2 v3  
    5858options_defaults["tablename"] = lambda cls: "my_prefix_%s" % cls.__name__.lower() 
    5959}}} 
     60 
     61== With migrate v0.6 == 
     62 
     63Since v0.6, upgrade and downgrade functions receive the engine as a parameter. 
     64 
     65{{{ 
     66from sqlalchemy import * 
     67from migrate import * 
     68from elixir import * 
     69 
     70__metadata__ = MetaData() 
     71 
     72 
     73class Foo(Entity): 
     74    using_options(tablename='foo') 
     75 
     76setup_all() 
     77     
     78 
     79def upgrade(migrate_engine): 
     80    # Upgrade operations go here. Don't create your own engine; use the engine 
     81    # named 'migrate_engine' imported from migrate. 
     82    __metadata__.bind = migrate_engine 
     83    Foo.table.create() 
     84def downgrade(migrate_engine): 
     85    # Operations to reverse the above upgrade go here. 
     86    __metadata__.bind = migrate_engine 
     87    Foo.table.drop() 
     88}}}