-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migration: add columns action_type and selector_id to bulk_actions (#…
…7995) selector_id: a way to filter backfills by Job action_type: will hold an enum of types (BACKFILL and TERMINATION for now)
- Loading branch information
Showing
12 changed files
with
182 additions
and
1 deletion.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...ter/dagster/core/storage/alembic/versions/030_add_columns_action_type_and_selector_id_.py
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,58 @@ | ||
"""add columns action_type and selector_id to bulk_actions | ||
Revision ID: 6860f830e40c | ||
Revises: 721d858e1dda | ||
Create Date: 2022-05-20 15:00:01.260860 | ||
""" | ||
import sqlalchemy as db | ||
from alembic import op | ||
|
||
from dagster.core.storage.migration.utils import has_column, has_index, has_table | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "6860f830e40c" | ||
down_revision = "721d858e1dda" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
if not has_table("bulk_actions"): | ||
return | ||
|
||
if not has_column("bulk_actions", "action_type"): | ||
op.add_column("bulk_actions", db.Column("action_type", db.String(32), nullable=True)) | ||
|
||
if not has_column("bulk_actions", "selector_id"): | ||
op.add_column("bulk_actions", db.Column("selector_id", db.Text, nullable=True)) | ||
|
||
if not has_index("bulk_actions", "idx_bulk_actions_action_type"): | ||
op.create_index( | ||
"idx_bulk_actions_action_type", | ||
"bulk_actions", | ||
["action_type"], | ||
unique=False, | ||
mysql_length={"action_type": 32}, | ||
) | ||
|
||
if not has_index("bulk_actions", "idx_bulk_actions_selector_id"): | ||
op.create_index( | ||
"idx_bulk_actions_selector_id", | ||
"bulk_actions", | ||
["selector_id"], | ||
unique=False, | ||
mysql_length={"selector_id": 64}, | ||
) | ||
|
||
|
||
def downgrade(): | ||
with op.batch_alter_table("bulk_actions") as batch_op: | ||
if has_index("bulk_actions", "idx_bulk_actions_action_type"): | ||
batch_op.drop_index("idx_bulk_actions_action_type") | ||
if has_index("bulk_actions", "idx_bulk_actions_selector_id"): | ||
batch_op.drop_index("idx_bulk_actions_selector_id") | ||
if has_column("bulk_actions", "action_type"): | ||
batch_op.drop_column("action_type") | ||
if has_column("bulk_actions", "selector_id"): | ||
batch_op.drop_column("selector_id") |
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
Binary file added
BIN
+92 KB
...s/general_tests/compat_tests/snapshot_0_14_16_bulk_actions_columns/sqlite/history/runs.db
Binary file not shown.
Binary file added
BIN
+188 KB
..._0_14_16_bulk_actions_columns/sqlite/history/runs/ff77b333-8ad8-49e1-aae7-4807c71463db.db
Binary file not shown.
Binary file added
BIN
+32 KB
...4_16_bulk_actions_columns/sqlite/history/runs/ff77b333-8ad8-49e1-aae7-4807c71463db.db-shm
Binary file not shown.
Empty file.
Binary file added
BIN
+52 KB
...ral_tests/compat_tests/snapshot_0_14_16_bulk_actions_columns/sqlite/history/runs/index.db
Binary file not shown.
Binary file added
BIN
+32 KB
...tests/compat_tests/snapshot_0_14_16_bulk_actions_columns/sqlite/history/runs/index.db-shm
Binary file not shown.
Empty file.
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
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
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