Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional model and version to DataSource (#215)
Allow data sources to be distinguished by what model (and version) they ran. * Add optional model and version to DataSource * Add unique constraint * Rewrite data source description to become a property * Use new description property in DataSource object representation * Use new description property to simplify util function * Changelog entry
- Loading branch information
Showing
4 changed files
with
84 additions
and
9 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
38 changes: 38 additions & 0 deletions
38
...migrations/versions/30fe2267e7d5_add_optional_DataSource_columns_for_model_and_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,38 @@ | ||
"""add optional DataSource columns for model and version | ||
Revision ID: 30fe2267e7d5 | ||
Revises: 96f2db5bed30 | ||
Create Date: 2021-10-11 10:54:24.348371 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "30fe2267e7d5" | ||
down_revision = "96f2db5bed30" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.add_column( | ||
"data_source", sa.Column("model", sa.String(length=80), nullable=True) | ||
) | ||
op.add_column( | ||
"data_source", sa.Column("version", sa.String(length=17), nullable=True) | ||
) | ||
op.create_unique_constraint( | ||
"_data_source_name_user_id_model_version_key", | ||
"data_source", | ||
["name", "user_id", "model", "version"], | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_constraint( | ||
"_data_source_name_user_id_model_version_key", "data_source", type_="unique" | ||
) | ||
op.drop_column("data_source", "version") | ||
op.drop_column("data_source", "model") |
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