Skip to content

Commit f35d353

Browse files
committed
Merge branch 'create-embedding-if-not-exists' into 'develop'
Create embedding column if not exists See merge request baserow/baserow!3797
2 parents 4c3ff53 + eab595e commit f35d353

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

backend/src/baserow/core/pgvector.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ def _create_field_in_model(cls, field: VectorField) -> None:
136136
"""
137137

138138
with connection.schema_editor() as schema_editor:
139+
# Ensure we only create the field if it does not exist yet. While this
140+
# should not happen if the SchemaOperation is updated correctly, this can
141+
# happen in tests or if some manual intervention happened. In any case, if
142+
# the field already exists, there's no need to fail or log an error.
143+
schema_editor.sql_create_column = schema_editor.sql_create_column.replace(
144+
"ADD COLUMN", "ADD COLUMN IF NOT EXISTS"
145+
)
139146
schema_editor.add_field(cls, field)
140147

141148
SchemaOperation.objects.create(

0 commit comments

Comments
 (0)