Prune the migration files for Airflow 3#41120
Conversation
3c720ce to
b67b0d4
Compare
6eed845 to
2762f60
Compare
2762f60 to
d5f0a4f
Compare
For a long time now, we have been able to create the metadata database from the ORM without going through the migration files. However, the migration files were not pruned because it would result in users being unable to roll back to a previous version. There's now an opportunity to prune this and start afresh. The migration files are getting more significant, and there are benefits to this pruning. Top in my mind is that the FAB migrations will no longer be in the airflow migration file, which would help in removing FAB from the Airflow core. This change also means we can no longer create a new database from the migration file. We can only do that through the ORM. I considered creating the 'current schema' in the migration file, which means having the database representation in the migration file and helping to create it from scratch. I dropped the idea because there would be elements of FAB in the migration files again. Due to this change, the db command option "--use-migration-files" was removed since this creates the database from the migration file.
d5f0a4f to
0120154
Compare
|
Overall LGMT, but we need to figure out what the min version we support upgrading from should be (2.10 vs some earlier 2.x). Ephraim is going to see where the FAB things are so in the migration files so we can figure out the best balance here. |
|
Good point - my proposal is that migration from 2.x & should be another migration step (possibly combined with the main This way we could allow a direct migration from pre 2.10 versions as well. |
|
FAB-related migrations stopped at 2.6.0, so we are at liberty to still have the migration cut off way down, but I think we should cut 3.0.0 migration at 2.10 as in this PR and have a migration tool for anyone upgrading, as @potiuk suggested. |
|
Merging this, we can still extend it to lower versions if need be |
* Prune the migration files for Airflow 3 For a long time now, we have been able to create the metadata database from the ORM without going through the migration files. However, the migration files were not pruned because it would result in users being unable to roll back to a previous version. There's now an opportunity to prune this and start afresh. The migration files are getting more significant, and there are benefits to this pruning. Top in my mind is that the FAB migrations will no longer be in the airflow migration file, which would help in removing FAB from the Airflow core. This change also means we can no longer create a new database from the migration file. We can only do that through the ORM. I considered creating the 'current schema' in the migration file, which means having the database representation in the migration file and helping to create it from scratch. I dropped the idea because there would be elements of FAB in the migration files again. Due to this change, the db command option "--use-migration-files" was removed since this creates the database from the migration file. * fixup! Prune the migration files for Airflow 3
The `--use-migration-files` flag was removed in apache#41120 when we pruned the migration history for Airflow 3. At the time, we couldn't create a database from scratch using only migration files because the migration chain no longer started from an empty database. The oldest migration assumed an existing 2.6.2 schema. Now that we have a squashed migration (0000_2_6_2) with `down_revision = None` that creates the full baseline schema from scratch, we can re-introduce this flag. This enables a critical development workflow, which is: creating the database purely from migration files, then using `alembic revision --autogenerate` to detect schema drift between the ORM models and the migration-produced schema. Without this flag, `autogenerate` compares against an ORM-created database (via `create_all`), which masks any drift since both sides come from the same ORM definitions.
… ORM/migration files The `--use-migration-files` flag was removed in apache#41120 when we pruned the migration history for Airflow 3. At the time, we couldn't create a database from scratch using only migration files because the migration chain no longer started from an empty database. The oldest migration assumed an existing 2.6.2 schema. Now that we have a squashed migration (0000_2_6_2) with `down_revision = None` that creates the full baseline schema from scratch, we can re-introduce this flag. This enables a critical development workflow, which is: creating the database purely from migration files, then using `alembic revision --autogenerate` to detect schema drift between the ORM models and the migration-produced schema. Without this flag, `autogenerate` compares against an ORM-created database (via `create_all`), which masks any drift since both sides come from the same ORM definitions.
… ORM/migration files The `--use-migration-files` flag was removed in apache#41120 when we pruned the migration history for Airflow 3. At the time, we couldn't create a database from scratch using only migration files because the migration chain no longer started from an empty database. The oldest migration assumed an existing 2.6.2 schema. Now that we have a squashed migration (0000_2_6_2) with `down_revision = None` that creates the full baseline schema from scratch, we can re-introduce this flag. This enables a critical development workflow, which is: creating the database purely from migration files, then using `alembic revision --autogenerate` to detect schema drift between the ORM models and the migration-produced schema. Without this flag, `autogenerate` compares against an ORM-created database (via `create_all`), which masks any drift since both sides come from the same ORM definitions.
… ORM/migration files The `--use-migration-files` flag was removed in apache#41120 when we pruned the migration history for Airflow 3. At the time, we couldn't create a database from scratch using only migration files because the migration chain no longer started from an empty database. The oldest migration assumed an existing 2.6.2 schema. Now that we have a squashed migration (0000_2_6_2) with `down_revision = None` that creates the full baseline schema from scratch, we can re-introduce this flag. This enables a critical development workflow, which is: creating the database purely from migration files, then using `alembic revision --autogenerate` to detect schema drift between the ORM models and the migration-produced schema. Without this flag, `autogenerate` compares against an ORM-created database (via `create_all`), which masks any drift since both sides come from the same ORM definitions.
… ORM/migration files The `--use-migration-files` flag was removed in apache#41120 when we pruned the migration history for Airflow 3. At the time, we couldn't create a database from scratch using only migration files because the migration chain no longer started from an empty database. The oldest migration assumed an existing 2.6.2 schema. Now that we have a squashed migration (0000_2_6_2) with `down_revision = None` that creates the full baseline schema from scratch, we can re-introduce this flag. This enables a critical development workflow, which is: creating the database purely from migration files, then using `alembic revision --autogenerate` to detect schema drift between the ORM models and the migration-produced schema. Without this flag, `autogenerate` compares against an ORM-created database (via `create_all`), which masks any drift since both sides come from the same ORM definitions.
For a long time now, we have been able to create the metadata database from the ORM without going through the migration files. However, the migration files were not pruned because it would result in users being unable to roll back to a previous version. There's now an opportunity to prune this and start afresh. The migration files are getting more significant, and there are benefits to this pruning. Top in my mind is that the FAB migrations will no longer be in the airflow migration file, which would help in removing FAB from the Airflow core.
This change also means we can no longer create a new database from the migration file. We can only do that through the ORM. I considered creating the 'current schema' in the migration file, which means having the database representation in the migration file and helping to create it from scratch. I dropped the idea because there would be elements of FAB in the migration files again.
Due to this change, the db command option "--use-migration-files" was removed since this creates the database from the migration file.