1 | """ |
---|
2 | Migration script to add columns for tracking whether pages are deleted and |
---|
3 | publicly accessible. |
---|
4 | """ |
---|
5 | |
---|
6 | from sqlalchemy import * |
---|
7 | from migrate import * |
---|
8 | from migrate.changeset import * |
---|
9 | |
---|
10 | import logging |
---|
11 | log = logging.getLogger( __name__ ) |
---|
12 | |
---|
13 | metadata = MetaData( migrate_engine ) |
---|
14 | |
---|
15 | def upgrade(): |
---|
16 | |
---|
17 | print __doc__ |
---|
18 | metadata.reflect() |
---|
19 | |
---|
20 | Page_table = Table( "page", metadata, autoload=True ) |
---|
21 | |
---|
22 | c = Column( "published", Boolean, index=True, default=False ) |
---|
23 | c.create( Page_table ) |
---|
24 | assert c is Page_table.c.published |
---|
25 | |
---|
26 | c = Column( "deleted", Boolean, index=True, default=False ) |
---|
27 | c.create( Page_table ) |
---|
28 | assert c is Page_table.c.deleted |
---|
29 | |
---|
30 | def downgrade(): |
---|
31 | metadata.reflect() |
---|
32 | |
---|
33 | Page_table = Table( "page", metadata, autoload=True ) |
---|
34 | Page_table.c.published.drop() |
---|
35 | Page_table.c.deleted.drop() |
---|