Upgrade to Pylons 1.0. #283
[zzz-spline-users.git] / migration / versions / 004_Add_user_stash.py
1 from sqlalchemy import *
2 from migrate import *
3 import migrate.changeset # monkeypatches Column
4
5 import json
6
7 from sqlalchemy import orm
8 from sqlalchemy.ext.declarative import declarative_base
9 TableBase = declarative_base()
10
11
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={})
18
19
20 def upgrade(migrate_engine):
21 TableBase.metadata.bind = migrate_engine
22
23 User.__table__.c.stash.create(table=User.__table__)
24 User.__table__.c.stash.alter(nullable=False)
25
26 def downgrade(migrate_engine):
27 TableBase.metadata.bind = migrate_engine
28
29 User.__table__.c.stash.drop()