Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

Commit

Permalink
Migration with type creation
Browse files Browse the repository at this point in the history
  • Loading branch information
moschlar committed Oct 30, 2013
1 parent 67462b9 commit 6315b7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion migration/versions/3a8c537e6090_test_visibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@
from sqlalchemy.orm import sessionmaker
from sauce.model import Test

test_visibility = sa.Enum('invisible', 'result_only', 'data_only', 'visible', name='test_visibility')


def upgrade():
cntxt = context.get_context()
Session = sessionmaker(bind=cntxt.bind)

op.alter_column('tests', 'visible', existing_type=sa.Boolean(), nullable=True)

test_visibility = sa.Enum('invisible', 'result_only', 'data_only', 'visible', name='test_visibility')
test_visibility.create(op.get_bind(), checkfirst=False)

op.add_column('tests',
sa.Column('visibility',
test_visibility,
Expand All @@ -62,4 +64,6 @@ def upgrade():
def downgrade():
op.drop_column('tests', 'visibility')

test_visibility.drop(op.get_bind(), checkfirst=False)

op.alter_column('tests', 'visible', existing_type=sa.Boolean(), nullable=False, default=False, server_default='False')
6 changes: 5 additions & 1 deletion migration/versions/425be68ff414_event_enroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@
#from alembic.operations import Operations as op
import sqlalchemy as sa

event_enroll = sa.Enum('event', 'lesson', 'lesson_team', 'team', 'team_new', name='event_enroll')


def upgrade():
op.add_column('events', sa.Column('enroll', sa.Enum('event', 'lesson', 'lesson_team', 'team', 'team_new', name='event_enroll'), nullable=True))
event_enroll.create(op.get_bind(), checkfirst=False)
op.add_column('events', sa.Column('enroll', event_enroll, nullable=True))


def downgrade():
event_enroll.drop(op.get_bind(), checkfirst=False)
op.drop_column('events', 'enroll')

0 comments on commit 6315b7c

Please sign in to comment.