
Merge these, removing an unnecessary layer of abstraction, and place them in the new 'nova.db.main' directory. The resulting change is huge, but it's mainly the result of 's/sqlalchemy import api/main import api/' and 's/nova.db.api/nova.db.main.api/' with some necessary cleanup. We also need to rework how we do the blocking of API calls since we no longer have a 'DBAPI' object that we can monkey patch as we were doing before. This is now done via a global variable that is set by the 'main' function of 'nova.cmd.compute'. The main impact of this change is that it's no longer possible to set '[database] use_db_reconnect' and have all APIs automatically wrapped in a DB retry. Seeing as this behavior is experimental, isn't applied to any of the API DB methods (which don't use oslo.db's 'DBAPI' helper), and is used explicitly in what would appear to be the critical cases (via the explicit 'oslo_db.api.wrap_db_retry' decorator), this doesn't seem like a huge loss. Change-Id: Iad2e4da4546b80a016e477577d23accb2606a6e4 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
124 lines
2.5 KiB
Bash
Executable File
124 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Script to generate schemas for the various versions.
|
|
#
|
|
# Some setup is required, similar to the opportunistic tests.
|
|
#
|
|
# MySQL ->
|
|
#
|
|
# $ mysql -uroot
|
|
# MariaDB [(none)]> CREATE DATABASE nova
|
|
# MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'password';
|
|
# MariaDB [(none)]> quit;
|
|
#
|
|
# Postgres ->
|
|
#
|
|
# $ sudo -u postgres psql
|
|
# postgres=# create user nova with createdb login password 'password';
|
|
# postgres=# create database nova with owner nova;
|
|
# postgres=# quit;
|
|
#
|
|
# Note that you may also have to configure 'pg_hba.conf' to use password-based
|
|
# auth instead of "ident", if you haven't done so already. You can locate this
|
|
# with 'locate pg_hba.conf'. More details at
|
|
# https://ubuntu.com/server/docs/databases-postgresql
|
|
|
|
set -o xtrace
|
|
set -e
|
|
|
|
source .tox/py36/bin/activate
|
|
pushd nova/db/main/legacy_migrations
|
|
|
|
INIT_VERSION=$(ls -1 versions/ | head -1 | awk -F_ '{print $1}')
|
|
INIT_VERSION=$(($INIT_VERSION-1))
|
|
|
|
echo "Detected init version of $INIT_VERSION"
|
|
|
|
mkdir -p schemas
|
|
rm -f "schemas/$INIT_VERSION-*.sql"
|
|
|
|
#
|
|
# sqlite
|
|
#
|
|
|
|
# cleanup from previous runs
|
|
|
|
rm -f nova.db
|
|
|
|
# sync schema
|
|
|
|
python manage.py version_control \
|
|
--database 'sqlite:///nova.db' \
|
|
--version $INIT_VERSION
|
|
|
|
python manage.py upgrade \
|
|
--database 'sqlite:///nova.db'
|
|
|
|
# dump the schema
|
|
|
|
sqlite3 nova.db << EOF
|
|
.output "schemas/${INIT_VERSION}-sqlite.sql"
|
|
.schema
|
|
.quit
|
|
EOF
|
|
|
|
rm -f nova.db
|
|
|
|
#
|
|
# mysql
|
|
#
|
|
|
|
# cleanup from previous runs
|
|
|
|
mysql -u nova -ppassword << EOF
|
|
DROP DATABASE IF EXISTS nova;
|
|
CREATE DATABASE nova;
|
|
EOF
|
|
|
|
# sync schema
|
|
|
|
python manage.py version_control \
|
|
--database 'mysql+pymysql://nova:password@localhost/nova' \
|
|
--version "$INIT_VERSION"
|
|
|
|
python manage.py upgrade \
|
|
--database 'mysql+pymysql://nova:password@localhost/nova'
|
|
|
|
# dump the schema
|
|
|
|
mysqldump --no-data --skip-comments -u nova -ppassword \
|
|
nova > "schemas/${INIT_VERSION}-mysql.sql"
|
|
|
|
mysql -u nova -ppassword << EOF
|
|
DROP DATABASE IF EXISTS nova;
|
|
EOF
|
|
|
|
|
|
#
|
|
# postgres
|
|
#
|
|
|
|
# cleanup from previous runs
|
|
|
|
sudo -u postgres dropdb --if-exists nova
|
|
sudo -u postgres createdb --owner=nova nova
|
|
|
|
# sync to initial version
|
|
|
|
python manage.py version_control \
|
|
--database 'postgresql://nova:password@localhost/nova' \
|
|
--version "$INIT_VERSION"
|
|
|
|
python manage.py upgrade \
|
|
--database 'postgresql://nova:password@localhost/nova'
|
|
|
|
# dump the schema
|
|
|
|
pg_dump postgresql://nova:password@localhost/nova \
|
|
--schema-only > "schemas/${INIT_VERSION}-postgres.sql"
|
|
|
|
sudo -u postgres dropdb --if-exists nova
|
|
|
|
popd
|
|
deactivate
|