feat(proxy): rewrite the meta module to support hot spares

This commit is contained in:
Iain Learmonth 2023-05-30 16:38:00 +01:00
parent 9f726731c6
commit 8115966aca
4 changed files with 327 additions and 99 deletions

View file

@ -0,0 +1,29 @@
"""Add hot spare pool
Revision ID: 278bcfb487d3
Revises: 2d747ffb9928
Create Date: 2023-05-30 16:08:37.770371
"""
from alembic import op
from sqlalchemy.sql import text
# revision identifiers, used by Alembic.
revision = '278bcfb487d3'
down_revision = '2d747ffb9928'
branch_labels = None
depends_on = None
def upgrade():
# Add SQL here
sql = text("""INSERT INTO pool VALUES (
-1, 'Hot spares (reserve)', NOW(), NOW(), NULL, 'hotspare',
md5(to_char(NOW(), 'YYYY-MM-DD HH24:MI:SS.US')), NULL) ON CONFLICT (id) DO NOTHING;""")
op.execute(sql)
def downgrade():
# SQL to undo the changes
sql = text("""DELETE FROM pool WHERE id = -1;""")
op.execute(sql)