Skip to content

Commit

Permalink
Ensure include_deferred is not nullable (#33280)
Browse files Browse the repository at this point in the history
* Ensure include_deferred is not nullable

This uses a multi-step process to introduce the NOT NULL constraint to
the column, needed due to MSSQL restrictions.

* MSSQL does not even support boolean literals

* Postgres does not support 0 as boolean

This is fine. SQL is fun.

* Wrap raw SQL in text()

(cherry picked from commit 4f6d597)
  • Loading branch information
uranusjr authored and ephraimbuddy committed Aug 10, 2023
1 parent 2ff8d4d commit a050a6a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

.. towncrier release notes start

Airflow 2.7.0 (2023-08-10)
Airflow 2.7.0 (2023-08-14)
--------------------------

Significant Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@
def upgrade():
"""Apply add include_deferred column to pool"""
with op.batch_alter_table("slot_pool") as batch_op:
batch_op.add_column(sa.Column("include_deferred", sa.Boolean, default=False))
batch_op.add_column(sa.Column("include_deferred", sa.Boolean))
# Different databases support different literal for FALSE. This is fine.
op.execute(sa.text(f"UPDATE slot_pool SET include_deferred = {sa.false().compile(op.get_bind())}"))
with op.batch_alter_table("slot_pool") as batch_op:
batch_op.alter_column("include_deferred", existing_type=sa.Boolean, nullable=False)


def downgrade():
Expand Down
2 changes: 1 addition & 1 deletion docs/apache-airflow/img/airflow_erd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
52b0e45032fb1c60274374e0114cf199dfb759adc0a4fe32964136347457506a
266a8533dca6d9c7e984341bfe29e99f29217e44529455a49e7c4a5faccdcdf3
8 changes: 4 additions & 4 deletions docs/apache-airflow/img/airflow_erd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a050a6a

Please sign in to comment.