Skip to content

Commit

Permalink
Add b4b1291b2628_add_dataproduct_resource.py migration
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Jan 22, 2025
1 parent 26c406d commit 0f31b76
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions alembic/versions/b4b1291b2628_add_dataproduct_resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Add dataproduct resource
Revision ID: b4b1291b2628
Revises: 59709e421270
Create Date: 2025-01-22 19:16:12.075431
"""
import os
from alembic import op
import sqlalchemy as sa

qwc_config_schema = os.getenv("QWC_CONFIG_SCHEMA", "qwc_config")

# revision identifiers, used by Alembic.
revision = 'b4b1291b2628'
down_revision = '59709e421270'
branch_labels = None
depends_on = None


def upgrade():
sql = sa.sql.text("""
INSERT INTO {schema}.resource_types (name, description, list_order)
VALUES (
'dataproduct', 'Dataproduct',
(SELECT MAX(list_order) + 1 FROM {schema}.resource_types)
);
""".format(schema=qwc_config_schema))

conn = op.get_bind()
conn.execute(sql)


def downgrade():
sql = sa.sql.text("""
DELETE FROM {schema}.resource_types WHERE name = 'dataproduct';
""".format(schema=qwc_config_schema))

conn = op.get_bind()
conn.execute(sql)

0 comments on commit 0f31b76

Please sign in to comment.