Spaces:
Sleeping

axeronis commited on
Commit
64438b2
·
1 Parent(s): 960cd60

fix: use IF NOT EXISTS for landing_config table migration

Browse files
backend/alembic/versions/2025_12_26_landing_config.py CHANGED
@@ -20,19 +20,22 @@ depends_on: Union[str, Sequence[str], None] = None
20
 
21
 
22
  def upgrade() -> None:
23
- """Create landing_config table."""
24
- op.create_table(
25
- 'landing_config',
26
- sa.Column('id', UUID(as_uuid=True), primary_key=True),
27
- sa.Column('trust_logos', JSON, nullable=True, default=[]),
28
- sa.Column('hero_title', sa.String, nullable=True),
29
- sa.Column('hero_subtitle', sa.String, nullable=True),
30
- sa.Column('show_chat_demo', sa.Boolean, nullable=False, server_default='true'),
31
- sa.Column('show_pricing', sa.Boolean, nullable=False, server_default='true'),
32
- sa.Column('updated_at', sa.DateTime, nullable=False, server_default=sa.func.now()),
33
- )
 
 
34
 
35
 
36
  def downgrade() -> None:
37
  """Drop landing_config table."""
38
  op.drop_table('landing_config')
 
 
20
 
21
 
22
  def upgrade() -> None:
23
+ """Create landing_config table if it doesn't exist."""
24
+ # Use raw SQL with IF NOT EXISTS to handle table already existing
25
+ op.execute("""
26
+ CREATE TABLE IF NOT EXISTS landing_config (
27
+ id UUID NOT NULL PRIMARY KEY,
28
+ trust_logos JSON,
29
+ hero_title VARCHAR,
30
+ hero_subtitle VARCHAR,
31
+ show_chat_demo BOOLEAN NOT NULL DEFAULT true,
32
+ show_pricing BOOLEAN NOT NULL DEFAULT true,
33
+ updated_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now()
34
+ )
35
+ """)
36
 
37
 
38
  def downgrade() -> None:
39
  """Drop landing_config table."""
40
  op.drop_table('landing_config')
41
+