mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 12:37:20 +08:00
fix(api): Remove postgresql_nulls_not_distinct=False in unique indexes
This option would generate upgrading / table creating sql with `NULLS DISTINCT` part and causing syntax error while running testcontainer tests. The `NULLS DISTINCT` syntax is only supported by PG 15+.
This commit is contained in:
parent
370127b87a
commit
8f2b53275c
@ -156,7 +156,7 @@ def upgrade():
|
|||||||
sa.Column('type', sa.String(20), nullable=False),
|
sa.Column('type', sa.String(20), nullable=False),
|
||||||
sa.Column('file_id', models.types.StringUUID(), nullable=False),
|
sa.Column('file_id', models.types.StringUUID(), nullable=False),
|
||||||
sa.PrimaryKeyConstraint('id', name=op.f('workflow_node_execution_offload_pkey')),
|
sa.PrimaryKeyConstraint('id', name=op.f('workflow_node_execution_offload_pkey')),
|
||||||
sa.UniqueConstraint('node_execution_id', 'type', name=op.f('workflow_node_execution_offload_node_execution_id_key'), postgresql_nulls_not_distinct=False)
|
sa.UniqueConstraint('node_execution_id', 'type', name=op.f('workflow_node_execution_offload_node_execution_id_key'))
|
||||||
)
|
)
|
||||||
with op.batch_alter_table('datasets', schema=None) as batch_op:
|
with op.batch_alter_table('datasets', schema=None) as batch_op:
|
||||||
batch_op.add_column(sa.Column('keyword_number', sa.Integer(), server_default=sa.text('10'), nullable=True))
|
batch_op.add_column(sa.Column('keyword_number', sa.Integer(), server_default=sa.text('10'), nullable=True))
|
||||||
|
|||||||
@ -890,12 +890,18 @@ class WorkflowNodeExecutionModel(Base): # This model is expected to have `offlo
|
|||||||
class WorkflowNodeExecutionOffload(Base):
|
class WorkflowNodeExecutionOffload(Base):
|
||||||
__tablename__ = "workflow_node_execution_offload"
|
__tablename__ = "workflow_node_execution_offload"
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
# PostgreSQL 14 treats NULL values as distinct in unique constraints by default,
|
||||||
|
# allowing multiple records with NULL values for the same column combination.
|
||||||
|
#
|
||||||
|
# This behavior allows us to have multiple records with NULL node_execution_id,
|
||||||
|
# simplifying garbage collection process.
|
||||||
UniqueConstraint(
|
UniqueConstraint(
|
||||||
"node_execution_id",
|
"node_execution_id",
|
||||||
"type",
|
"type",
|
||||||
# Treat `NULL` as distinct for this unique index, so
|
# Note: PostgreSQL 15+ supports explicit `nulls distinct` behavior through
|
||||||
# we can have mutitple records with `NULL` node_exeution_id, simplify garbage collection process.
|
# `postgresql_nulls_not_distinct=False`, which would make our intention clearer.
|
||||||
postgresql_nulls_not_distinct=False,
|
# We rely on PostgreSQL's default behavior of treating NULLs as distinct values.
|
||||||
|
# postgresql_nulls_not_distinct=False,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
_HASH_COL_SIZE = 64
|
_HASH_COL_SIZE = 64
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user