Skip to content

Commit

Permalink
feat(black):
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikstranneheim committed Aug 28, 2020
1 parent e7a2dd7 commit 4213f0d
Show file tree
Hide file tree
Showing 36 changed files with 474 additions and 442 deletions.
15 changes: 6 additions & 9 deletions alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
from trailblazer.store import Model

target_metadata = Model.metadata

# other values from the config, defined by the needs of env.py,
Expand All @@ -37,8 +38,7 @@ def run_migrations_offline():
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url, target_metadata=target_metadata, literal_binds=True)
context.configure(url=url, target_metadata=target_metadata, literal_binds=True)

with context.begin_transaction():
context.run_migrations()
Expand All @@ -52,19 +52,16 @@ def run_migrations_online():
"""
connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
config.get_section(config.config_ini_section), prefix="sqlalchemy.", poolclass=pool.NullPool
)

with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata
)
context.configure(connection=connection, target_metadata=target_metadata)

with context.begin_transaction():
context.run_migrations()


if context.is_offline_mode():
run_migrations_offline()
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"""

# revision identifiers, used by Alembic.
revision = '0829dd9c54d7'
down_revision = 'fcc3ed539387'
revision = "0829dd9c54d7"
down_revision = "fcc3ed539387"
branch_labels = None
depends_on = None

Expand All @@ -18,11 +18,13 @@

def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('analysis', sa.Column('priority', sa.Enum('low', 'normal', 'high'), nullable=True))
op.add_column(
"analysis", sa.Column("priority", sa.Enum("low", "normal", "high"), nullable=True)
)
### end Alembic commands ###


def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_column('analysis', 'priority')
op.drop_column("analysis", "priority")
### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"""

# revision identifiers, used by Alembic.
revision = '2029c2789209'
down_revision = '79f5f7602ba5'
revision = "2029c2789209"
down_revision = "79f5f7602ba5"
branch_labels = None
depends_on = None

Expand All @@ -18,11 +18,11 @@

def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('analysis', sa.Column('logged_at', sa.DateTime(), nullable=True))
op.add_column("analysis", sa.Column("logged_at", sa.DateTime(), nullable=True))
### end Alembic commands ###


def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_column('analysis', 'logged_at')
op.drop_column("analysis", "logged_at")
### end Alembic commands ###
18 changes: 12 additions & 6 deletions alembic/versions/3140747f399a_remove_step_from_unique_contraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"""

# revision identifiers, used by Alembic.
revision = '3140747f399a'
down_revision = '84079287ee2f'
revision = "3140747f399a"
down_revision = "84079287ee2f"
branch_labels = None
depends_on = None

Expand All @@ -18,13 +18,19 @@

def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(u'_uc_case_start_status_step', 'analysis', type_='unique')
op.create_unique_constraint('_uc_case_start_status_step', 'analysis', ['case_id', 'started_at', 'status'])
op.drop_constraint(u"_uc_case_start_status_step", "analysis", type_="unique")
op.create_unique_constraint(
"_uc_case_start_status_step", "analysis", ["case_id", "started_at", "status"]
)
### end Alembic commands ###


def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_constraint('_uc_case_start_status_step', 'analysis', type_='unique')
op.create_unique_constraint(u'_uc_case_start_status_step', 'analysis', ['case_id', 'started_at', 'status', 'failed_step'])
op.drop_constraint("_uc_case_start_status_step", "analysis", type_="unique")
op.create_unique_constraint(
u"_uc_case_start_status_step",
"analysis",
["case_id", "started_at", "status", "failed_step"],
)
### end Alembic commands ###
4 changes: 2 additions & 2 deletions alembic/versions/4f4098ada28f_add_user_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"""

# revision identifiers, used by Alembic.
revision = '4f4098ada28f'
down_revision = '8786470f3a1b'
revision = "4f4098ada28f"
down_revision = "8786470f3a1b"
branch_labels = None
depends_on = None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"""

# revision identifiers, used by Alembic.
revision = '61df280b0af6'
down_revision = '65a2be59adb1'
revision = "61df280b0af6"
down_revision = "65a2be59adb1"
branch_labels = None
depends_on = None

Expand All @@ -24,25 +24,30 @@

def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('analysis', sa.Column('is_visible', sa.Boolean(), nullable=True))
op.add_column("analysis", sa.Column("is_visible", sa.Boolean(), nullable=True))
### end Alembic commands ###
bind = op.get_bind()
session = Session(bind=bind)

op.execute("""
op.execute(
"""
UPDATE trailblazer.analysis
SET is_visible=1;
""")
"""
)
with bind.begin() as transaction:
for run in session.query(Analysis).filter_by(status='failed'):
case_runs = (session.query(Analysis).filter_by(case_id=run.case_id)
.order_by(Analysis.logged_at.desc()))
if case_runs.first().status == 'completed':
for run in session.query(Analysis).filter_by(status="failed"):
case_runs = (
session.query(Analysis)
.filter_by(case_id=run.case_id)
.order_by(Analysis.logged_at.desc())
)
if case_runs.first().status == "completed":
run.is_visible = False
transaction.commit()


def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_column('analysis', 'is_visible')
op.drop_column("analysis", "is_visible")
### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"""

# revision identifiers, used by Alembic.
revision = '65a2be59adb1'
down_revision = 'afffbd40f0c3'
revision = "65a2be59adb1"
down_revision = "afffbd40f0c3"
branch_labels = None
depends_on = None

Expand Down
17 changes: 9 additions & 8 deletions alembic/versions/79f5f7602ba5_add_metadata_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"""

# revision identifiers, used by Alembic.
revision = '79f5f7602ba5'
down_revision = '92599c4afa62'
revision = "79f5f7602ba5"
down_revision = "92599c4afa62"
branch_labels = None
depends_on = None

Expand All @@ -18,16 +18,17 @@

def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('metadata',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id')
op.create_table(
"metadata",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("updated_at", sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
### end Alembic commands ###


def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_table('metadata')
op.drop_table("metadata")
### end Alembic commands ###
2 changes: 1 addition & 1 deletion alembic/versions/84079287ee2f_initial_revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

# revision identifiers, used by Alembic.
revision = '84079287ee2f'
revision = "84079287ee2f"
down_revision = None
branch_labels = None
depends_on = None
Expand Down
20 changes: 10 additions & 10 deletions alembic/versions/8786470f3a1b_add_new_status_option_canceled.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@
"""

# revision identifiers, used by Alembic.
revision = '8786470f3a1b'
down_revision = '61df280b0af6'
revision = "8786470f3a1b"
down_revision = "61df280b0af6"
branch_labels = None
depends_on = None

from alembic import op
from sqlalchemy import types

OLD_OPTIONS = ('pending', 'running', 'completed', 'failed', 'error')
NEW_OPTIONS = ('pending', 'running', 'completed', 'failed', 'error', 'canceled')
OLD_OPTIONS = ("pending", "running", "completed", "failed", "error")
NEW_OPTIONS = ("pending", "running", "completed", "failed", "error", "canceled")


def upgrade():
op.alter_column('analysis', 'status',
existing_type=types.Enum(*OLD_OPTIONS),
type_=types.Enum(*NEW_OPTIONS))
op.alter_column(
"analysis", "status", existing_type=types.Enum(*OLD_OPTIONS), type_=types.Enum(*NEW_OPTIONS)
)


def downgrade():
op.alter_column('analysis', 'status',
existing_type=types.Enum(*NEW_OPTIONS),
type_=types.Enum(*OLD_OPTIONS))
op.alter_column(
"analysis", "status", existing_type=types.Enum(*NEW_OPTIONS), type_=types.Enum(*OLD_OPTIONS)
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"""

# revision identifiers, used by Alembic.
revision = '92599c4afa62'
down_revision = '3140747f399a'
revision = "92599c4afa62"
down_revision = "3140747f399a"
branch_labels = None
depends_on = None

Expand All @@ -18,13 +18,17 @@

def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(u'_uc_case_start_status_step', 'analysis', type_='unique')
op.create_unique_constraint('_uc_case_start_status_step', 'analysis', ['case_id', 'started_at', 'status', 'failed_step'])
op.drop_constraint(u"_uc_case_start_status_step", "analysis", type_="unique")
op.create_unique_constraint(
"_uc_case_start_status_step", "analysis", ["case_id", "started_at", "status", "failed_step"]
)
### end Alembic commands ###


def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_constraint('_uc_case_start_status_step', 'analysis', type_='unique')
op.create_unique_constraint(u'_uc_case_start_status_step', 'analysis', ['case_id', 'started_at', 'status'])
op.drop_constraint("_uc_case_start_status_step", "analysis", type_="unique")
op.create_unique_constraint(
u"_uc_case_start_status_step", "analysis", ["case_id", "started_at", "status"]
)
### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@
"""

# revision identifiers, used by Alembic.
revision = 'afffbd40f0c3'
down_revision = '2029c2789209'
revision = "afffbd40f0c3"
down_revision = "2029c2789209"
branch_labels = None
depends_on = None

from alembic import op
from sqlalchemy import types

OLD_OPTIONS = ('pending', 'running', 'completed', 'failed')
NEW_OPTIONS = ('pending', 'running', 'completed', 'failed', 'error')
OLD_OPTIONS = ("pending", "running", "completed", "failed")
NEW_OPTIONS = ("pending", "running", "completed", "failed", "error")


def upgrade():
op.alter_column('analysis', 'status',
existing_type=types.Enum(*OLD_OPTIONS),
type_=types.Enum(*NEW_OPTIONS))
op.alter_column(
"analysis", "status", existing_type=types.Enum(*OLD_OPTIONS), type_=types.Enum(*NEW_OPTIONS)
)


def downgrade():
op.alter_column('analysis', 'status',
existing_type=types.Enum(*NEW_OPTIONS),
type_=types.Enum(*OLD_OPTIONS))
op.alter_column(
"analysis", "status", existing_type=types.Enum(*NEW_OPTIONS), type_=types.Enum(*OLD_OPTIONS)
)
25 changes: 13 additions & 12 deletions alembic/versions/b26bb11641b4_actually_add_user_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"""

# revision identifiers, used by Alembic.
revision = 'b26bb11641b4'
down_revision = '4f4098ada28f'
revision = "b26bb11641b4"
down_revision = "4f4098ada28f"
branch_labels = None
depends_on = None

Expand All @@ -18,20 +18,21 @@

def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('google_id', sa.String(length=128), nullable=True),
sa.Column('email', sa.String(length=128), nullable=True),
sa.Column('name', sa.String(length=128), nullable=True),
sa.Column('avatar', sa.Text(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email'),
sa.UniqueConstraint('google_id')
op.create_table(
"user",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("google_id", sa.String(length=128), nullable=True),
sa.Column("email", sa.String(length=128), nullable=True),
sa.Column("name", sa.String(length=128), nullable=True),
sa.Column("avatar", sa.Text(), nullable=True),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("email"),
sa.UniqueConstraint("google_id"),
)
### end Alembic commands ###


def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_table('user')
op.drop_table("user")
### end Alembic commands ###
Loading

0 comments on commit 4213f0d

Please sign in to comment.