iting0321 commented on code in PR #64838:
URL: https://github.com/apache/airflow/pull/64838#discussion_r3106829753
##########
airflow-core/src/airflow/migrations/versions/0017_2_9_2_fix_inconsistency_between_ORM_and_migration_files.py:
##########
@@ -76,9 +78,9 @@ def upgrade():
elif conn.dialect.name == "sqlite":
# SQLite does not support DROP CONSTRAINT
# We have to recreate the table without the constraint
- conn.execute(sa.text("PRAGMA foreign_keys=off"))
Review Comment:
But the line 102-104 are different from else: , I think that we should keep
` elif conn.dialect.name == "sqlite":`.
##########
airflow-core/src/airflow/migrations/versions/0017_2_9_2_fix_inconsistency_between_ORM_and_migration_files.py:
##########
@@ -213,60 +214,59 @@ def upgrade():
elif conn.dialect.name == "sqlite":
# SQLite does not support DROP CONSTRAINT
# We have to recreate the table without the constraint
- conn.execute(sa.text("PRAGMA foreign_keys=off"))
- conn.execute(
- sa.text("""
- CREATE TABLE dag_run_new (
- id INTEGER NOT NULL,
- dag_id VARCHAR(250) NOT NULL,
- queued_at TIMESTAMP,
- execution_date TIMESTAMP NOT NULL,
- start_date TIMESTAMP,
- end_date TIMESTAMP,
- state VARCHAR(50),
- run_id VARCHAR(250) NOT NULL,
- creating_job_id INTEGER,
- external_trigger BOOLEAN,
- run_type VARCHAR(50) NOT NULL,
- conf BLOB,
- data_interval_start TIMESTAMP,
- data_interval_end TIMESTAMP,
- last_scheduling_decision TIMESTAMP,
- dag_hash VARCHAR(32),
- log_template_id INTEGER,
- updated_at TIMESTAMP,
- clear_number INTEGER DEFAULT '0' NOT NULL,
- CONSTRAINT dag_run_pkey PRIMARY KEY (id),
- CONSTRAINT dag_run_dag_id_execution_date_key UNIQUE (dag_id,
execution_date),
- CONSTRAINT dag_run_dag_id_run_id_key UNIQUE (dag_id, run_id),
- CONSTRAINT task_instance_log_template_id_fkey FOREIGN
KEY(log_template_id) REFERENCES log_template (id) ON DELETE NO ACTION
- )
- """)
- )
- headers = (
- "id, dag_id, queued_at, execution_date, start_date, end_date,
state, run_id, creating_job_id, "
- "external_trigger, run_type, conf, data_interval_start,
data_interval_end, "
- "last_scheduling_decision, dag_hash, log_template_id, updated_at,
clear_number"
- )
- conn.execute(sa.text(f"INSERT INTO dag_run_new ({headers}) SELECT
{headers} FROM dag_run"))
- conn.execute(sa.text("DROP TABLE dag_run"))
- conn.execute(sa.text("ALTER TABLE dag_run_new RENAME TO dag_run"))
- conn.execute(sa.text("PRAGMA foreign_keys=on"))
- with op.batch_alter_table("dag_run") as batch_op:
- batch_op.create_index("dag_id_state", ["dag_id", "state"],
if_not_exists=True)
- batch_op.create_index("idx_dag_run_dag_id", ["dag_id"],
if_not_exists=True)
- batch_op.create_index(
- "idx_dag_run_running_dags",
- ["state", "dag_id"],
- sqlite_where=sa.text("state='running'"),
- if_not_exists=True,
+ with disable_sqlite_fkeys(op):
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]