-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds versions to block schemas (#6491)
* WIP: Adds version to block schema * WIP: Adds tests for block schema version * Adds tests for filters * Fixes read after block schema creation * Fixes erroneously removed index
- Loading branch information
1 parent
94b3951
commit ba66ced
Showing
13 changed files
with
347 additions
and
30 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
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
39 changes: 39 additions & 0 deletions
39
...igrations/versions/postgresql/2022_08_18_102804_2d5e000696f1_adds_block_schema_version.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,39 @@ | ||
"""Adds block schema version | ||
Revision ID: 2d5e000696f1 | ||
Revises: 77eb737fc759 | ||
Create Date: 2022-08-18 10:28:04.449256 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "2d5e000696f1" | ||
down_revision = "77eb737fc759" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.add_column( | ||
"block_schema", | ||
sa.Column( | ||
"version", sa.String(), server_default="non-versioned", nullable=False | ||
), | ||
) | ||
op.drop_index("uq_block_schema__checksum", table_name="block_schema") | ||
op.create_index( | ||
"uq_block_schema__checksum_version", | ||
"block_schema", | ||
["checksum", "version"], | ||
unique=True, | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_index("uq_block_schema__checksum_version", table_name="block_schema") | ||
op.create_index( | ||
"uq_block_schema__checksum", "block_schema", ["checksum"], unique=False | ||
) | ||
op.drop_column("block_schema", "version") |
39 changes: 39 additions & 0 deletions
39
...se/migrations/versions/sqlite/2022_08_18_102527_e757138e954a_adds_block_schema_version.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,39 @@ | ||
"""Adds block schema version | ||
Revision ID: e757138e954a | ||
Revises: 575634b7acd4 | ||
Create Date: 2022-08-18 10:25:27.189680 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "e757138e954a" | ||
down_revision = "575634b7acd4" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.execute("PRAGMA foreign_keys=OFF") | ||
|
||
with op.batch_alter_table("block_schema", schema=None) as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"version", sa.String(), server_default="non-versioned", nullable=False | ||
) | ||
) | ||
batch_op.drop_index("uq_block_schema__checksum") | ||
batch_op.create_index( | ||
"uq_block_schema__checksum_version", ["checksum", "version"], unique=True | ||
) | ||
|
||
op.execute("PRAGMA foreign_keys=ON") | ||
|
||
|
||
def downgrade(): | ||
with op.batch_alter_table("block_schema", schema=None) as batch_op: | ||
batch_op.drop_index("uq_block_schema__checksum_version") | ||
batch_op.create_index("uq_block_schema__checksum", ["checksum"], unique=False) | ||
batch_op.drop_column("version") |
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
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
Oops, something went wrong.