Skip to content

Commit

Permalink
fix(26): handle nullable for alembic
Browse files Browse the repository at this point in the history
alembic was generating incorrect nullable for version_tables when
generating a migrations script for empty DB, so setting value
based on discussion in original issue thread in

kvesteri/sqlalchemy-continuum#285 (comment)
  • Loading branch information
indiVar0508 committed Aug 26, 2023
1 parent 03f1832 commit 89f9d5f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sqlalchemy_history/table_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ def reflect_column(self, column):

if not column_copy.primary_key:
column_copy.nullable = True
# ref: https://github.com/sqlalchemy/sqlalchemy/blob/rel_1_4_41/lib/sqlalchemy/sql/schema.py#L2018
# ref: https://github.com/kvesteri/sqlalchemy-continuum/issues/285#issuecomment-1239230120
# when copying `_user_defined_nullable` was set to parents value itself so alembic was
# probably picking this value to give nullable as False first so setting it explicitly to False
column_copy._user_defined_nullable = True

# Find the right column key
if self.model is not None:
Expand Down

0 comments on commit 89f9d5f

Please # to comment.