Skip to content

Restore nullable ORM fields and drop unreleased corrective migration#63899

Open
ephraimbuddy wants to merge 1 commit intoapache:mainfrom
astronomer:fix-nullable-orm-fields
Open

Restore nullable ORM fields and drop unreleased corrective migration#63899
ephraimbuddy wants to merge 1 commit intoapache:mainfrom
astronomer:fix-nullable-orm-fields

Conversation

@ephraimbuddy
Copy link
Contributor

PR #56330 mistakenly changed several ORM-backed columns from nullable to non-nullable. I later added a corrective migration in PR #62234 to backfill existing NULLs, but after revisiting the issue we found the migration was only compensating for the nullability mistake introduced by PR #56330 itself, which has not been released.

Instead of shipping a large corrective migration for an unreleased regression, delete the migration file and restore the affected ORM fields to nullable so the models stay aligned with the actual schema and intended pre-release behavior.

PR apache#56330 mistakenly changed several ORM-backed columns from nullable to
non-nullable. I later added a corrective migration in PR apache#62234 to
backfill existing NULLs, but after revisiting the issue we found the
migration was only compensating for the nullability mistake introduced by
PR apache#56330 itself, which has not been released.

Instead of shipping a large corrective migration for an unreleased
regression, delete the migration file and restore the affected ORM fields
to nullable so the models stay aligned with the actual schema and
intended pre-release behavior.
@ephraimbuddy ephraimbuddy force-pushed the fix-nullable-orm-fields branch from de3ee18 to f3ecd1b Compare March 18, 2026 18:51
port: Mapped[int | None] = mapped_column(Integer(), nullable=True)
is_encrypted: Mapped[bool] = mapped_column(Boolean, unique=False, default=False)
is_extra_encrypted: Mapped[bool] = mapped_column(Boolean, unique=False, default=False)
is_encrypted: Mapped[bool | None] = mapped_column(Boolean, unique=False, default=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These could be left non nullable - false and not null are equivalent for where is used

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem is the field was nullable in 2.2.x (and earlier), and changing this to non-nullable without a migration will cause problems if there are nulls in the db.

# Set this default value of is_paused based on a configuration value!
is_paused_at_creation = airflow_conf.getboolean("core", "dags_are_paused_at_creation")
is_paused: Mapped[bool] = mapped_column(Boolean, default=is_paused_at_creation)
is_paused: Mapped[bool | None] = mapped_column(Boolean, default=is_paused_at_creation)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto here - null = false = not paused

id: Mapped[int] = mapped_column(Integer, primary_key=True)
key: Mapped[str] = mapped_column(String(ID_LEN), unique=True)
_val: Mapped[str] = mapped_column("val", Text().with_variant(MEDIUMTEXT, "mysql"))
key: Mapped[str | None] = mapped_column(String(ID_LEN), unique=True, nullable=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be nullable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, yes it shouldn’t be nullable, but it was, and there’s no way to fix this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants