-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add b4b1291b2628_add_dataproduct_resource.py migration
- Loading branch information
1 parent
26c406d
commit 0f31b76
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |