Skip to content

Commit

Permalink
Squash migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
redshiftzero committed Dec 10, 2017
1 parent 46c1cc1 commit d11d449
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 52 deletions.
19 changes: 18 additions & 1 deletion OpenOversight/app/db_repository/versions/006_migration.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
from sqlalchemy import *
from migrate import *


from migrate.changeset import schema
from migrate.changeset.constraint import ForeignKeyConstraint

pre_meta = MetaData()
post_meta = MetaData()


departments = Table('departments', post_meta,
Column('id', Integer, primary_key=True, nullable=False),
Column('name', String(length=255), index=True, nullable=False),
Column('short_name', String(length=100), nullable=False),
)

unit_types = Table('unit_types', post_meta,
Column('id', Integer, primary_key=True, nullable=False),
Column('descrip', String(length=120)),
Expand Down Expand Up @@ -35,6 +44,9 @@
Column('department_id', Integer),
)

cons1 = ForeignKeyConstraint([officers.c.department_id], [departments.c.id])
cons2 = ForeignKeyConstraint([unit_types.c.department_id], [departments.c.id])


def upgrade(migrate_engine):
# Upgrade operations go here. Don't create your own engine; bind
Expand All @@ -45,6 +57,8 @@ def upgrade(migrate_engine):
pre_meta.tables['officers'].columns['pd_id'].drop()
post_meta.tables['officers'].columns['department_id'].create()

cons1.create()
cons2.create()

def downgrade(migrate_engine):
# Operations to reverse the above upgrade go here.
Expand All @@ -53,3 +67,6 @@ def downgrade(migrate_engine):
post_meta.tables['unit_types'].columns['department_id'].drop()
pre_meta.tables['officers'].columns['pd_id'].create()
post_meta.tables['officers'].columns['department_id'].drop()

cons1.drop()
cons2.drop()
51 changes: 0 additions & 51 deletions OpenOversight/app/db_repository/versions/007_migration.py

This file was deleted.

0 comments on commit d11d449

Please sign in to comment.