Use the "testcase" table as the table to check if a database has been initialized.
ClosedPublic

Authored by mprahl on Jan 19 2017, 8:49 PM.

Details

Summary

Previous to v2.0.0 of ResultsDB, the table that was checked was "job". In v2.0.0,
that table was replaced with the "group" table. The initialize_db function first
checks to see if the database has been initialized by checking if a certain expected table exists,
and if it doesn't, it creates the tables. If it does find it, it then upgrades the database to the
latest Alembic revision. This was a handy function/command to run whether you were initializing the
database or just migrating to the latest version. The change in v2.0.0 however, made upgrading from a
v1.x.x database to a v2.x.x database using this function a mess (which I used in my Ansible role).
It would check for the "group" table, which was only available in v2.0.0, and it would see it wasn't
there and it would run the db.create_all() function, and stamp the database as the latest revision.
I would end up with the legacy job table and the new group table coexisting and all the alterations made
in the migrations beyond that were not present. Using a table to check that exists in both v1.x.x and v2.x.x
is a solution to this problem in the future.

Test Plan

NA

Diff Detail

Repository
rRSDB resultsdb
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mprahl retitled this revision from to Use the "testcase" table as the table to check if a database has been initialized..Jan 19 2017, 8:49 PM
mprahl updated this object.
mprahl edited the test plan for this revision. (Show Details)
mprahl added reviewers: tflink, jskladan.
mprahl added a subscriber: ralph.
jskladan accepted this revision.Jan 19 2017, 9:22 PM

Makes sense. Weird thing is that we did not hit any troubles with the migration, but whatever.
Good catch, thanks!

This revision is now accepted and ready to land.Jan 19 2017, 9:22 PM

@jskladan can you merge this please? :)

Closed by commit rRSDB363500dc7f30: Use testcase table to check db initialization (authored by mprahl <mprahl@redhat.com>, committed by Josef Skladanka <jskladan@redhat.com>). · Explain WhyJan 21 2017, 9:19 AM
This revision was automatically updated to reflect the committed changes.