When upgrading, beaker-init is supposed to perform two functions: 1) create or upgrade the schema 2) "populate" the database with static data, like hypervisor types, key types, admin user account, ... But beaker-init also has the (essentially unrelated) function of performing schema downgrades too. In that case it should not be trying to populate the database. However if you invoke beaker-init with --debug, currently it *does* attempt to perform the population step, and most of the time this will fail because the downgraded schema no longer matches what the model code (which is used for populating the db) is expecting. For example, using 22.0 to downgrade to 21.x schema: $ beaker-init --downgrade 171c07fb4970 [...] 2016-01-25 08:42:27,716 alembic.migration INFO Running downgrade 5ab8960cdb43 -> 171c07fb4970, Delete duplicate rows in osmajor_install_options Traceback (most recent call last): File "bkr/server/tools/init.py", line 310, in <module> main() File "bkr/server/tools/init.py", line 307, in main populate_db(opts.user_name, opts.password, opts.display_name, opts.email_address) File "bkr/server/tools/init.py", line 53, in populate_db admin = Group.by_name(u'admin') File "bkr/server/model/identity.py", line 467, in by_name return cls.query.filter_by(group_name=name).one() [...] sqlalchemy.exc.OperationalError: (OperationalError) (1054, "Unknown column 'tg_group.membership_type' in 'field list'") 'SELECT tg_group.root_password AS tg_group_root_password, tg_group.group_id AS tg_group_group_id, tg_group.group_name AS tg_group_group_name, tg_group.display_name AS tg_group_display_name, tg_group.membership_type AS tg_group_membership_type, tg_group.created AS tg_group_created \nFROM tg_group \nWHERE tg_group.group_name = %s' ('admin',) Looks like it was just an indentation mistake with the populate_db() call on line 307 of init.py (that line should be inside the else: block).
http://gerrit.beaker-project.org/4654
Steps to reproduce: 1. On a fully upgraded Beaker 22 environment, try to downgrade to Beaker 21: $ beaker-init --downgrade 171c07fb4970 Actual results: Database is downgraded but then a traceback is printed, as per comment 0. Expected results: Downgrade completes successfully, no output.
Beaker 22.2 has been released.