Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Mysql 5.7 id utf8mb3 #14535

Merged
merged 1 commit into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from alembic import op
from sqlalchemy.engine.reflection import Inspector

from airflow.models.base import COLLATION_ARGS

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should go above the comment. In other files as well.


# revision identifiers, used by Alembic.
revision = '03afc6b6f902'
down_revision = '92c57b58940d'
Expand Down Expand Up @@ -59,7 +61,10 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
from alembic import op
from sqlalchemy.dialects import mysql

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

# revision identifiers, used by Alembic.
revision = '0a2a5b66e19d'
down_revision = '9635ae0956e7'
branch_labels = None
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 @@ -27,6 +27,8 @@
import sqlalchemy as sa
from alembic import op

from airflow.models.base import COLLATION_ARGS

# revision identifiers, used by Alembic.
revision = '1b38cef5b76e'
down_revision = '502898887f84'
Expand All @@ -38,10 +40,10 @@ def upgrade():
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 @@ -26,9 +26,9 @@
import sqlalchemy as sa
from alembic import op

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

# revision identifiers, used by Alembic.
revision = '64de9cddf6c9'
down_revision = '211e584da130'
branch_labels = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import sqlalchemy as sa
from alembic import op

from airflow.models.base import COLLATION_ARGS

# revision identifiers, used by Alembic.
revision = '7939bcff74ba'
down_revision = 'fe461863935f'
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 @@ -27,6 +27,8 @@
import sqlalchemy as sa
from alembic import op

from airflow.models.base import COLLATION_ARGS

# revision identifiers, used by Alembic.
revision = '852ae6c715af'
down_revision = 'a4c2fd67d16b'
Expand All @@ -51,8 +53,8 @@ def upgrade():

op.create_table(
TABLE_NAME,
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,13 +28,12 @@
import sqlalchemy as sa
from alembic import op
from sqlalchemy import Column, Float, Integer, PickleType, String

# revision identifiers, used by Alembic.
from sqlalchemy.ext.declarative import declarative_base

from airflow.models.base import COLLATION_ARGS
from airflow.utils.sqlalchemy import UtcDateTime

# revision identifiers, used by Alembic.
revision = '8646922c8a04'
down_revision = '449b4072c2da'
branch_labels = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import sqlalchemy as sa
from alembic import op

from airflow.models.base import COLLATION_ARGS

# revision identifiers, used by Alembic.
revision = '8d48763f6d53'
down_revision = '8f966b9c467a'
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 @@ -27,9 +27,9 @@
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
from airflow.models.dagcode import DagCode

# revision identifiers, used by Alembic.
revision = '952da73b5eff'
down_revision = '852ae6c715af'
branch_labels = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import sqlalchemy as sa
from alembic import op

from airflow.models.base import COLLATION_ARGS

# revision identifiers, used by Alembic.
revision = 'b25a55525161'
down_revision = 'bbf4a7ad0465'
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 @@ -31,10 +31,9 @@

from airflow import settings
from airflow.models import DagBag

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

# revision identifiers, used by Alembic.
revision = 'cc1e65623dc7'
down_revision = '127d2bf2dfa7'
branch_labels = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
from alembic import op
from sqlalchemy.dialects import mysql

from airflow.models.base import COLLATION_ARGS

# revision identifiers, used by Alembic.
revision = 'd38e04c12aa2'
down_revision = '6e96a59344a4'
Expand All @@ -49,7 +51,7 @@ def upgrade():

op.create_table(
'serialized_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('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 @@ -29,6 +29,8 @@
from sqlalchemy.dialects import mysql
from sqlalchemy.engine.reflection import Inspector

from airflow.models.base import COLLATION_ARGS

# revision identifiers, used by Alembic.
revision = 'e38be357a868'
down_revision = '8d48763f6d53'
Expand Down Expand Up @@ -66,8 +68,8 @@ def upgrade():
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 @@ -29,9 +29,9 @@
from sqlalchemy import func
from sqlalchemy.engine.reflection import Inspector

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

# revision identifiers, used by Alembic.
revision = 'e3a246e0dc1'
down_revision = None
branch_labels = None
Expand All @@ -47,7 +47,7 @@ def upgrade():
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=True),
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():
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():
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():
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():
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import sqlalchemy as sa
from alembic import op

from airflow.models.base import COLLATION_ARGS

# revision identifiers, used by Alembic.
revision = 'f2ca10b85618'
down_revision = '64de9cddf6c9'
Expand All @@ -36,7 +38,7 @@
def upgrade():
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