1 from sqlalchemy
import *
3 import migrate
.changeset
# monkeypatches Column
7 from sqlalchemy
import orm
8 from sqlalchemy
.ext
.declarative
import declarative_base
9 TableBase
= declarative_base()
12 class User(TableBase
):
13 __tablename__
= 'users'
14 id = Column(Integer
, primary_key
=True)
15 name
= Column(Unicode(length
=20), nullable
=False)
16 unique_identifier
= Column(Unicode(length
=32), nullable
=False)
17 stash
= Column(PickleType(pickler
=json
), nullable
=True, default
={})
20 def upgrade(migrate_engine
):
21 TableBase
.metadata
.bind
= migrate_engine
23 User
.__table__
.c
.stash
.create(table
=User
.__table__
)
24 User
.__table__
.c
.stash
.alter(nullable
=False)
26 def downgrade(migrate_engine
):
27 TableBase
.metadata
.bind
= migrate_engine
29 User
.__table__
.c
.stash
.drop()