rkh-hash commented on issue #13222:
URL: https://github.com/apache/airflow/issues/13222#issuecomment-749184968
@potiuk so it's a bug ^^ ?
It's fixed but I've changed another stuff.
The constraint name `known_event_user_id_fkey` may not exist anymore in
airflow `1.10.14`.
So, if the goal of this migration rule is to drop all foreign keys referred
to `users` table (before drop it), we can achieve that with this following
logic:
```python
def upgrade(): # noqa: D103
# We previously had a KnownEvent's table, but we deleted the table
without
# a down migration to remove it (so we didn't delete anyone's data if
they
# were happing to use the feature.
#
# But before we can delete the users table we need to drop the FK
conn = op.get_bind()
inspector = Inspector.from_engine(conn)
tables = inspector.get_table_names()
if 'known_event' in tables:
for fkey in inspector.get_foreign_keys(table_name="known_event",
referred_table="users"):
op.drop_constraint(
fkey['name'], 'known_event', type_="foreignkey"
)
if "chart" in tables:
op.drop_table(
"chart",
)
if "users" in tables:
op.drop_table("users")
```
With these modifications, next migration rules are applied without any
regression bugs. So, I can successfully upgrade to airflow 2.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]