mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-08-11 11:47:50 +00:00
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user