ashb commented on code in PR #63185:
URL: https://github.com/apache/airflow/pull/63185#discussion_r2905500928
##########
airflow-core/src/airflow/migrations/versions/0082_3_1_0_make_bundle_name_not_nullable.py:
##########
@@ -43,63 +43,62 @@
def upgrade():
"""Make bundle_name not nullable."""
+ import contextlib
+
+ # We need the DagBundlesManager here to respect and validate the user
configured bundles instead of hardcoding 'dags-folder' and 'example_dags' as
the only two bundles.
+ from airflow.dag_processing.bundles.manager import DagBundlesManager
+
+ user_config_bundles = DagBundlesManager().bundle_names
dialect_name = op.get_bind().dialect.name
- if dialect_name == "postgresql":
- op.execute(
- text("""
- INSERT INTO dag_bundle (name) VALUES
- ('example_dags'),
- ('dags-folder')
- ON CONFLICT (name) DO NOTHING;
- """)
- )
- if dialect_name == "mysql":
- op.execute(
- text("""
- INSERT IGNORE INTO dag_bundle (name) VALUES
- ('example_dags'),
- ('dags-folder');
- """)
- )
+ conn = op.get_bind()
+
+ exitstack = contextlib.ExitStack()
if dialect_name == "sqlite":
- op.execute(text("PRAGMA foreign_keys=OFF"))
- op.execute(
- text("""
- INSERT OR IGNORE INTO dag_bundle (name) VALUES
- ('example_dags'),
- ('dags-folder');
- """)
- )
+ # SQLite requires foreign key constraints to be disabled during batch
operations
+ conn = op.get_bind()
Review Comment:
Nit: we already have `conn` from L53
--
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]