Skip to content

Commit

Permalink
Fix: Mysql 5.7 id utf8mb3
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrls committed Jun 1, 2021
1 parent b7d1039 commit 7ef8f47
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
from sqlalchemy.engine.reflection import Inspector

# revision identifiers, used by Alembic.
from airflow.models.base import COLLATION_ARGS

revision = '03afc6b6f902'
down_revision = '92c57b58940d'
branch_labels = None
Expand Down Expand Up @@ -59,7 +61,7 @@ def upgrade():
op.execute("PRAGMA foreign_keys=on")
else:
op.alter_column(
table_name='ab_view_menu', column_name='name', type_=sa.String(length=250), nullable=False
table_name='ab_view_menu', column_name='name', type_=sa.String(length=250, **COLLATION_ARGS), nullable=False
)


Expand Down
6 changes: 4 additions & 2 deletions airflow/migrations/versions/1b38cef5b76e_add_dagrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from alembic import op

# revision identifiers, used by Alembic.
from airflow.models.base import COLLATION_ARGS

revision = '1b38cef5b76e'
down_revision = '502898887f84'
branch_labels = None
Expand All @@ -38,10 +40,10 @@ def upgrade(): # noqa: D103
op.create_table(
'dag_run',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('dag_id', sa.String(length=250), nullable=True),
sa.Column('dag_id', sa.String(length=250, **COLLATION_ARGS), nullable=True),
sa.Column('execution_date', sa.DateTime(), nullable=True),
sa.Column('state', sa.String(length=50), nullable=True),
sa.Column('run_id', sa.String(length=250), nullable=True),
sa.Column('run_id', sa.String(length=250, **COLLATION_ARGS), nullable=True),
sa.Column('external_trigger', sa.Boolean(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('dag_id', 'execution_date'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from alembic import op

# revision identifiers, used by Alembic.
from airflow.models.base import COLLATION_ARGS

revision = '7939bcff74ba'
down_revision = 'fe461863935f'
branch_labels = None
Expand All @@ -39,7 +41,7 @@ def upgrade():
op.create_table(
'dag_tag',
sa.Column('name', sa.String(length=100), nullable=False),
sa.Column('dag_id', sa.String(length=250), nullable=False),
sa.Column('dag_id', sa.String(length=250, **COLLATION_ARGS), nullable=False),
sa.ForeignKeyConstraint(
['dag_id'],
['dag.dag_id'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from alembic import op

# revision identifiers, used by Alembic.
from airflow.models.base import COLLATION_ARGS

revision = '852ae6c715af'
down_revision = 'a4c2fd67d16b'
branch_labels = None
Expand All @@ -51,8 +53,8 @@ def upgrade():

op.create_table(
TABLE_NAME, # pylint: disable=no-member
sa.Column('dag_id', sa.String(length=250), nullable=False),
sa.Column('task_id', sa.String(length=250), nullable=False),
sa.Column('dag_id', sa.String(length=250, **COLLATION_ARGS), nullable=False),
sa.Column('task_id', sa.String(length=250, **COLLATION_ARGS), nullable=False),
sa.Column('execution_date', sa.TIMESTAMP(timezone=True), nullable=False),
sa.Column('rendered_fields', json_type(), nullable=False),
sa.PrimaryKeyConstraint('dag_id', 'task_id', 'execution_date'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from alembic import op

# revision identifiers, used by Alembic.
from airflow.models.base import COLLATION_ARGS

revision = '8d48763f6d53'
down_revision = '8f966b9c467a'
branch_labels = None
Expand All @@ -38,7 +40,7 @@ def upgrade():
"""Apply add unique constraint to conn_id and set it as non-nullable"""
try:
with op.batch_alter_table('connection') as batch_op:
batch_op.alter_column("conn_id", nullable=False, existing_type=sa.String(250))
batch_op.alter_column("conn_id", nullable=False, existing_type=sa.String(250, **COLLATION_ARGS))
batch_op.create_unique_constraint(constraint_name="unique_conn_id", columns=["conn_id"])

except sa.exc.IntegrityError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from alembic import op

# revision identifiers, used by Alembic.
from airflow.models.base import COLLATION_ARGS

revision = 'b25a55525161'
down_revision = 'bbf4a7ad0465'
branch_labels = None
Expand All @@ -38,7 +40,7 @@ def upgrade():
"""Increase column length of pool name from 50 to 256 characters"""
# use batch_alter_table to support SQLite workaround
with op.batch_alter_table('slot_pool', table_args=sa.UniqueConstraint('pool')) as batch_op:
batch_op.alter_column('pool', type_=sa.String(256))
batch_op.alter_column('pool', type_=sa.String(256, **COLLATION_ARGS))


def downgrade():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
from airflow.models.base import COLLATION_ARGS
revision = 'd38e04c12aa2'
down_revision = '6e96a59344a4'
branch_labels = None
Expand All @@ -49,7 +50,7 @@ def upgrade():

op.create_table(
'serialized_dag', # pylint: disable=no-member
sa.Column('dag_id', sa.String(length=250), nullable=False),
sa.Column('dag_id', sa.String(length=250, **COLLATION_ARGS), nullable=False),
sa.Column('fileloc', sa.String(length=2000), nullable=False),
sa.Column('fileloc_hash', sa.Integer(), nullable=False),
sa.Column('data', json_type(), nullable=False),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from sqlalchemy.engine.reflection import Inspector

# revision identifiers, used by Alembic.
from airflow.models.base import COLLATION_ARGS

revision = 'e38be357a868'
down_revision = '8d48763f6d53'
branch_labels = None
Expand Down Expand Up @@ -66,8 +68,8 @@ def upgrade(): # noqa: D103
op.create_table(
'sensor_instance',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('task_id', sa.String(length=250), nullable=False),
sa.Column('dag_id', sa.String(length=250), nullable=False),
sa.Column('task_id', sa.String(length=250, **COLLATION_ARGS), nullable=False),
sa.Column('dag_id', sa.String(length=250, **COLLATION_ARGS), nullable=False),
sa.Column('execution_date', timestamp(), nullable=False),
sa.Column('state', sa.String(length=20), nullable=True),
sa.Column('try_number', sa.Integer(), nullable=True),
Expand Down
12 changes: 6 additions & 6 deletions airflow/migrations/versions/e3a246e0dc1_current_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def upgrade(): # noqa: D103
op.create_table(
'connection',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('conn_id', sa.String(length=250), nullable=True),
sa.Column('conn_id', sa.String(length=250, **COLLATION_ARGS), nullable=False),
sa.Column('conn_type', sa.String(length=500), nullable=True),
sa.Column('host', sa.String(length=500), nullable=True),
sa.Column('schema', sa.String(length=500), nullable=True),
Expand All @@ -60,7 +60,7 @@ def upgrade(): # noqa: D103
if 'dag' not in tables:
op.create_table(
'dag',
sa.Column('dag_id', sa.String(length=250), nullable=False),
sa.Column('dag_id', sa.String(length=250, **COLLATION_ARGS), nullable=False),
sa.Column('is_paused', sa.Boolean(), nullable=True),
sa.Column('is_subdag', sa.Boolean(), nullable=True),
sa.Column('is_active', sa.Boolean(), nullable=True),
Expand Down Expand Up @@ -134,7 +134,7 @@ def upgrade(): # noqa: D103
op.create_table(
'slot_pool',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pool', sa.String(length=50), nullable=True),
sa.Column('pool', sa.String(length=50, **COLLATION_ARGS), nullable=True),
sa.Column('slots', sa.Integer(), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
sa.PrimaryKeyConstraint('id'),
Expand Down Expand Up @@ -169,7 +169,7 @@ def upgrade(): # noqa: D103
op.create_table(
'user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.String(length=250), nullable=True),
sa.Column('username', sa.String(length=250, **COLLATION_ARGS), nullable=True),
sa.Column('email', sa.String(length=500), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('username'),
Expand All @@ -178,7 +178,7 @@ def upgrade(): # noqa: D103
op.create_table(
'variable',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('key', sa.String(length=250), nullable=True),
sa.Column('key', sa.String(length=250, **COLLATION_ARGS), nullable=True),
sa.Column('val', sa.Text(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('key'),
Expand Down Expand Up @@ -211,7 +211,7 @@ def upgrade(): # noqa: D103
op.create_table(
'xcom',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('key', sa.String(length=512, **COLLATION_ARGS), nullable=True),
sa.Column('key', sa.String(length=512, **COLLATION_ARGS), nullable=False),
sa.Column('value', sa.PickleType(), nullable=True),
sa.Column('timestamp', sa.DateTime(), default=func.now(), nullable=False),
sa.Column('execution_date', sa.DateTime(), nullable=False),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
from alembic import op

# revision identifiers, used by Alembic.
from airflow.models.base import COLLATION_ARGS

revision = 'f2ca10b85618'
down_revision = '64de9cddf6c9'
branch_labels = None
Expand All @@ -36,7 +38,7 @@
def upgrade(): # noqa: D103
op.create_table(
'dag_stats',
sa.Column('dag_id', sa.String(length=250), nullable=False),
sa.Column('dag_id', sa.String(length=250, **COLLATION_ARGS), nullable=False),
sa.Column('state', sa.String(length=50), nullable=False),
sa.Column('count', sa.Integer(), nullable=False, default=0),
sa.Column('dirty', sa.Boolean(), nullable=False, default=False),
Expand Down

0 comments on commit 7ef8f47

Please sign in to comment.