Conversation
Update unit tests to not depend on the mock logic
- remove hard-coded Windows handling - validate every sql source/target using the is_schema() - builds a dictionary of valid schema files
| log = logging.getLogger("omego.db") | ||
|
|
||
| # Regular expression identifying a SQL schema | ||
| SQL_SCHEMA_REGEXP = re.compile('.*OMERO(\d+)(\.|A)?(\d*)([A-Z]*)__(\d+)$') |
There was a problem hiding this comment.
I'd replace OMERO here with [a-zA-Z]
There was a problem hiding this comment.
How should those sql files be handled?
There was a problem hiding this comment.
"OMERO" is not special in the name. It's just an arbitrary identifier. It's valid to have a sequence like:
OMERO5.2__0 --> IDR1__0 --> IDR__2__0 --> OMERO5.3__0
and in fact, we may soon.
There was a problem hiding this comment.
I can either include this change as part of this PR of a follow-up one (since this PR tries to solve an immediate deployment issue). One question here is about the schemas ordering logic i.e. what are the rules to compute the order listed above (we have one more discriminator tahn the previous M.m__p)?
There was a problem hiding this comment.
FYI previous discussion: https://trello.com/c/nLwzmAPc/80-preparatory-sql-scripts#comment-5731f5302676e7971514b397
|
Dry-run with latest release Dry-run with OMERO-DEV-merge-build with manual patch from https://patch-diff.githubusercontent.com/raw/openmicroscopy/openmicroscopy/pull/4732.diff Same, but without |
Based the discussion in ome/openmicroscopy#4732, this PR reviews and reviews the way
omegoparses and sorts SQL schema files to compute a database upgrade graph.DB upgrade strategy
While upgrading a version of the server, in order to determine whether the current database needs to be upgraded,
omegouses the following workflow:DbAdmin.get_current_db_version()retrieve the current DB schemaDbAdmin.sql_version_matrix()retrieves all DB schemas available from thesql/psqlfolders and creates a transformation matrixDbAdmin.sql_version_resolve()resolves the upgrade path given a source and a target DB schemaSQL file classification
At the moment,
omego.dbmodule classifies SQL files found on the OMERO server into two categories:OMEROM.m__pChanges
This Pull Request reviews the way
DbAdmin.sql_version_matrix()works to handle non-DB schema files in a more robust manner. The summary of changes is the following:is_schema()and sort a list of schemassort_schemas()parse_schema_files()which usesis_schema()internally and constructs a dictionary of valid DB schema files with their associated source and target schemasDbAdmin.sql_version_matrix()to drop the internal behavior and special case handling and delegate toparse_schema_files()insteadTesting
Unit tests have been added to
test/unit/test_db.pyto cover the semantics of the new functions especially the DB schema validation and parsing functionalities. All tests should pass on Travis.As an integration test, performing a dry-run upgrade of the DB using the following command against a server including ome/openmicroscopy#4732 should now return instead of failing:
Extension points
This PR does not cover improvements to parse
precheckSQL scripts and run them prior to the DB upgrade. Keeping this use case in mind, an idea might be to define a dictionary of regular expressions and pass a parameter to the top-level methods to specify the type of SQL file to validate, sort and parse.