-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update schema and alembic so we only have unique metric names (#185)
* Update schema and alembic so we only have unique metric names * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add constraint name --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
4a7e731
commit 97d631e
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/insight/alembic/versions/512d9168f6c2_add_metric_name_unique_constraint.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,30 @@ | ||
"""add_metric_name_unique_constraint | ||
Revision ID: 512d9168f6c2 | ||
Revises: eaf7bb3598af | ||
Create Date: 2024-03-27 14:18:55.504729 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "512d9168f6c2" | ||
down_revision = "eaf7bb3598af" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_unique_constraint( | ||
constraint_name="name-unique", table_name="metric", columns=["name"] | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint(constraint_name="name-unique", table_name="metric", type_="unique") | ||
# ### end Alembic commands ### |
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