Skip to content

Migration breaking from 2.10.5 to 3.0.0 in sqlite #49296

@vatsrahul1001

Description

@vatsrahul1001

Apache Airflow version

3.0.0

If "Other Airflow 2 version" selected, which one?

No response

What happened?

Getting below error in migration when running migration with sqilte

Traceback (most recent call last):
  File "/Users/sunank200/code/airflow/.venv/lib/python3.9/site-packages/alembic/operations/batch.py", line 690, in drop_constraint
    const = self.named_constraints.pop(const.name)
KeyError: 'dataset_alias_dataset_alias_id_fkey'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/sunank200/code/airflow/.venv/bin/airflow", line 10, in <module>
    sys.exit(main())
  File "/Users/sunank200/code/airflow/airflow-core/src/airflow/__main__.py", line 58, in main
    args.func(args)
  File "/Users/sunank200/code/airflow/airflow-core/src/airflow/cli/cli_config.py", line 49, in command
    return func(*args, **kwargs)
  File "/Users/sunank200/code/airflow/airflow-core/src/airflow/utils/cli.py", line 111, in wrapper
    return f(*args, **kwargs)
  File "/Users/sunank200/code/airflow/airflow-core/src/airflow/utils/providers_configuration_loader.py", line 55, in wrapped_function
    return func(*args, **kwargs)
  File "/Users/sunank200/code/airflow/airflow-core/src/airflow/cli/commands/db_command.py", line 197, in migratedb
    run_db_migrate_command(args, db.upgradedb, _REVISION_HEADS_MAP)
  File "/Users/sunank200/code/airflow/airflow-core/src/airflow/cli/commands/db_command.py", line 125, in run_db_migrate_command
    command(
  File "/Users/sunank200/code/airflow/airflow-core/src/airflow/utils/session.py", line 102, in wrapper
    return func(*args, session=session, **kwargs)
  File "/Users/sunank200/code/airflow/airflow-core/src/airflow/utils/db.py", line 1146, in upgradedb
    command.upgrade(config, revision=to_revision or "heads")
  File "/Users/sunank200/code/airflow/.venv/lib/python3.9/site-packages/alembic/command.py", line 406, in upgrade
    script.run_env()
  File "/Users/sunank200/code/airflow/.venv/lib/python3.9/site-packages/alembic/script/base.py", line 586, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/Users/sunank200/code/airflow/.venv/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
    module = load_module_py(module_id, path)
  File "/Users/sunank200/code/airflow/.venv/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/sunank200/code/airflow/airflow-core/src/airflow/migrations/env.py", line 139, in <module>
    run_migrations_online()
  File "/Users/sunank200/code/airflow/airflow-core/src/airflow/migrations/env.py", line 133, in run_migrations_online
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File "/Users/sunank200/code/airflow/.venv/lib/python3.9/site-packages/alembic/runtime/environment.py", line 946, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/Users/sunank200/code/airflow/.venv/lib/python3.9/site-packages/alembic/runtime/migration.py", line 623, in run_migrations
    step.migration_fn(**kw)
  File "/Users/sunank200/code/airflow/airflow-core/src/airflow/migrations/versions/0041_3_0_0_rename_dataset_as_asset.py", line 134, in upgrade
    batch_op.drop_constraint(op.f("dataset_alias_dataset_alias_id_fkey"), type_="foreignkey")
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/contextlib.py", line 124, in __exit__
    next(self.gen)
  File "/Users/sunank200/code/airflow/.venv/lib/python3.9/site-packages/alembic/operations/base.py", line 398, in batch_alter_table
    impl.flush()
  File "/Users/sunank200/code/airflow/.venv/lib/python3.9/site-packages/alembic/operations/batch.py", line 162, in flush
    fn(*arg, **kw)
  File "/Users/sunank200/code/airflow/.venv/lib/python3.9/site-packages/alembic/operations/batch.py", line 701, in drop_constraint
    raise ValueError("No such constraint: '%s'" % const.name)
ValueError: No such constraint: 'dataset_alias_dataset_alias_id_fkey'

What you think should happen instead?

No response

How to reproduce

  1. Try to migrate from 2.10.5 sqlite to 3.0.0

Operating System

linux

Versions of Apache Airflow Providers

No response

Deployment

Official Apache Airflow Helm Chart

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corearea:db-migrationsPRs with DB migrationkind:bugThis is a clearly a bugpriority:mediumBug that should be fixed before next release but would not block a release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions