Skip to content

Commit aba9db7

Browse files
committed
Try fixing migrations 6: gear table fix
1 parent f0cb96b commit aba9db7

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

migrations/versions/eb948c31a342_create_gear_table.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,22 @@
2121

2222

2323
def upgrade():
24-
op.create_table(
25-
"gear",
26-
sa.Column("id", sa.Integer(), primary_key=True),
27-
sa.Column("activity_id", sa.Integer(), nullable=False),
28-
sa.Column("name", sa.String(), nullable=False),
29-
sa.Column("cost", sa.Float(), nullable=False),
30-
sa.Column("rate", sa.String(), nullable=True),
31-
sa.Column("type", price_type_enum, nullable=False),
32-
)
24+
op.execute("""
25+
DO $$
26+
BEGIN
27+
IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'gear') THEN
28+
CREATE TABLE gear (
29+
id SERIAL NOT NULL,
30+
activity_id INTEGER NOT NULL,
31+
name VARCHAR NOT NULL,
32+
cost FLOAT NOT NULL,
33+
rate VARCHAR,
34+
type pricetype NOT NULL,
35+
PRIMARY KEY (id)
36+
);
37+
END IF;
38+
END $$;
39+
""")
3340

3441
def downgrade():
3542
op.drop_table("gear")

0 commit comments

Comments
 (0)