Update migration script for linting.
This commit is contained in:
parent
4b6c52dce6
commit
f5415c3d66
@ -6,15 +6,22 @@ Create Date: 2015-08-31 10:24:40.578432
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1232daf66ac' # flake8: noqa
|
||||
down_revision = '144929e0f5f' # flake8: noqa
|
||||
# pylint: disable=no-member
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
# revision identifiers, used by Alembic.
|
||||
# pylint: disable=invalid-name
|
||||
revision = '1232daf66ac'
|
||||
down_revision = '144929e0f5f'
|
||||
# pylint: enable=invalid-name
|
||||
|
||||
# pylint: disable=wrong-import-position
|
||||
from alembic import op # noqa
|
||||
import sqlalchemy as sa # noqa
|
||||
# pylint: enable=wrong-import-position
|
||||
|
||||
|
||||
def upgrade():
|
||||
"""Upgrades for revision 1232daf66ac"""
|
||||
op.create_table(
|
||||
'user',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
@ -28,5 +35,6 @@ def upgrade():
|
||||
|
||||
|
||||
def downgrade():
|
||||
"""Downgrades for revision 1232daf66ac"""
|
||||
op.drop_index(op.f('ix_user_email'), table_name='user')
|
||||
op.drop_table('user')
|
||||
|
@ -6,17 +6,24 @@ Create Date: 2015-07-17 15:04:01.002581
|
||||
|
||||
"""
|
||||
|
||||
# pylint: disable=no-member
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '144929e0f5f' # flake8: noqa
|
||||
down_revision = None # flake8: noqa
|
||||
# pylint: disable=invalid-name
|
||||
revision = '144929e0f5f'
|
||||
down_revision = None
|
||||
# pylint: enable=invalid-name
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
# pylint: disable=wrong-import-position
|
||||
from alembic import op # noqa
|
||||
import sqlalchemy as sa # noqa
|
||||
|
||||
from accountant.models.scheduled_operations import ScheduledOperation
|
||||
from accountant.models.scheduled_operations import ScheduledOperation # noqa
|
||||
# pylint: enable=wrong-import-position
|
||||
|
||||
|
||||
def upgrade():
|
||||
"""Upgrades for revision 144929e0f5f"""
|
||||
op.get_bind().execute("DROP VIEW operation")
|
||||
op.rename_table('entry', 'operation')
|
||||
|
||||
@ -51,18 +58,15 @@ def upgrade():
|
||||
"alter sequence entry_id_seq rename to operation_id_seq"
|
||||
)
|
||||
|
||||
connection = op.get_bind()
|
||||
Session = sa.orm.sessionmaker()
|
||||
session = Session(bind=connection)
|
||||
|
||||
# Get all scheduled operations
|
||||
scheduled_operations = ScheduledOperation.query(session).all()
|
||||
scheduled_operations = ScheduledOperation.query().all()
|
||||
|
||||
for scheduled_operation in scheduled_operations:
|
||||
scheduled_operation.reschedule(session)
|
||||
scheduled_operation.reschedule()
|
||||
|
||||
|
||||
def downgrade():
|
||||
"""Downgrades for revision 144929e0f5f"""
|
||||
|
||||
op.create_table(
|
||||
"canceled_operation",
|
||||
@ -81,6 +85,7 @@ def downgrade():
|
||||
)
|
||||
op.rename_table('operation', 'entry')
|
||||
|
||||
# pylint: disable=line-too-long
|
||||
op.get_bind().execute(
|
||||
"""
|
||||
CREATE VIEW operation AS
|
||||
@ -138,5 +143,6 @@ SELECT NULL::bigint AS id,
|
||||
true AS canceled
|
||||
FROM scheduled_operation
|
||||
JOIN canceled_operation ON canceled_operation.scheduled_operation_id = scheduled_operation.id;
|
||||
""" # flake8: noqa
|
||||
""" # noqa
|
||||
)
|
||||
# pylint: enable=line-too-long
|
||||
|
Loading…
Reference in New Issue
Block a user