Use internal DB management

Use our own internal code for managing database migrations, rather than
calling sqlalchemy-migrate's command line directly. This allows us to
automatically specify the initial version of the database, which is
required in order to be able to squash migrations (bug 1072949).

Change-Id: I88206f8b55fe6fe4016cee8e5bf1d5eeb0ae30d2
This commit is contained in:
Zane Bitter 2013-03-12 10:03:29 +01:00
parent 36672da65e
commit 16cd2030aa
2 changed files with 42 additions and 2 deletions

View File

@ -238,8 +238,7 @@ if [ "${MYSQL_HEAT_PW}" != "${MYSQL_HEAT_PW_DEFAULT}" ] ; then
sed -i -e "s/mysql:\/\/heat:\(.*\)@/mysql:\/\/heat:${MYSQL_HEAT_PW}@/" ${HEAT_CONFIG}
fi
python -m heat.db.sqlalchemy.manage version_control
python -m heat.db.sqlalchemy.manage upgrade
python -m heat.db.sync
# Do a final sanity check on the database.

41
heat/db/sync.py Normal file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import gettext
import sys
gettext.install('heat', unicode=1)
from oslo.config import cfg
from heat.openstack.common import log as logging
import heat.db
from heat.db import migration
LOG = logging.getLogger(__name__)
if __name__ == '__main__':
cfg.CONF(project='heat', prog='heat-engine')
heat.db.configure()
try:
migration.db_sync()
except Exception as exc:
print >>sys.stderr, str(exc)
sys.exit(1)