-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Don't auto-upgrade db for new Experiments [Resolves #695] To avoid the problem of time-consuming database upgrades happening when we don't want them, the Experiment now: 1. Checks to see if the results_schema_versions table exists at all. if it doesn't exist, upgrade. This is because means the results schema should be clean in this case, and new users won't have to always run a new thing when they first try Triage. 2. If it does exist, and the version number doesn't match what the code's current HEAD revision is, throw an error. The error message is customized to whether the database revision is a known revision to the code (easy case, just upgrade if you have time) or not (you probably upgraded on a different branch and need to go check out that branch to downgrade).
- Loading branch information
Showing
3 changed files
with
67 additions
and
3 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,17 @@ | ||
from triage.component import results_schema | ||
from alembic import command, script | ||
import pytest | ||
|
||
|
||
def test_upgrade_if_clean_upgrades_if_clean(db_engine): | ||
results_schema.upgrade_if_clean(db_engine.url) | ||
db_version = db_engine.execute("select version_num from results_schema_versions").scalar() | ||
alembic_cfg = results_schema.alembic_config(db_engine.url) | ||
assert db_version == script.ScriptDirectory.from_config(alembic_cfg).get_current_head() | ||
|
||
|
||
def test_upgrade_if_clean_does_not_upgrade_if_not_clean(db_engine): | ||
command.upgrade(results_schema.alembic_config(dburl=db_engine.url), "head") | ||
command.downgrade(results_schema.alembic_config(dburl=db_engine.url), "-1") | ||
with pytest.raises(ValueError): | ||
results_schema.upgrade_if_clean(db_engine.url) |
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