Merge pull request #116 from Routstr/fix-migrations

Fix migrations
This commit is contained in:
shroominic
2025-08-09 15:01:49 -03:00
committed by GitHub
2 changed files with 19 additions and 16 deletions
+18 -15
View File
@@ -17,21 +17,24 @@ depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"api_keys",
sa.Column("hashed_key", sqlm.sql.sqltypes.AutoString(), nullable=False),
sa.Column("balance", sa.Integer(), nullable=False),
sa.Column("refund_address", sqlm.sql.sqltypes.AutoString(), nullable=True),
sa.Column("key_expiry_time", sa.Integer(), nullable=True),
sa.Column("total_spent", sa.Integer(), nullable=False),
sa.Column("total_requests", sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint("hashed_key"),
)
# ### end Alembic commands ###
if "api_keys" not in sa.inspect(op.get_bind()).get_table_names():
op.create_table(
"api_keys",
sa.Column("hashed_key", sqlm.sql.sqltypes.AutoString(), nullable=False),
sa.Column("balance", sa.Integer(), nullable=False),
sa.Column("refund_address", sqlm.sql.sqltypes.AutoString(), nullable=True),
sa.Column("key_expiry_time", sa.Integer(), nullable=True),
sa.Column("total_spent", sa.Integer(), nullable=False),
sa.Column("total_requests", sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint("hashed_key"),
)
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("api_keys")
# ### end Alembic commands ###
# Only drop the table if it exists
conn = op.get_bind()
inspector = sa.inspect(conn)
tables = inspector.get_table_names()
if "api_keys" in tables:
op.drop_table("api_keys")
+1 -1
View File
@@ -16,4 +16,4 @@ setup(
"marshmallow>=3.13,<4.0",
],
python_requires=">=3.11",
)
)