From 190775d5ea82364ad1baf2471cd453032e9c60de Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Sat, 5 May 2012 13:55:45 -0400 Subject: Update PostgreSQL sequence names for zones/quotas. Fixes LP Bug #993667. Fixes LP Bug #993669. Change-Id: Ifcc33929ced617916bd6613fc941257494f4a99b --- .../094_update_postgresql_sequence_names.py | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 nova/db/sqlalchemy/migrate_repo/versions/094_update_postgresql_sequence_names.py diff --git a/nova/db/sqlalchemy/migrate_repo/versions/094_update_postgresql_sequence_names.py b/nova/db/sqlalchemy/migrate_repo/versions/094_update_postgresql_sequence_names.py new file mode 100644 index 000000000..bad8735d0 --- /dev/null +++ b/nova/db/sqlalchemy/migrate_repo/versions/094_update_postgresql_sequence_names.py @@ -0,0 +1,52 @@ +# Copyright (c) 2012 Red Hat, Inc. +# All Rights Reserved. +# +# 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. + +from sqlalchemy import MetaData + + +def upgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + + # NOTE(dprince): Need to rename the leftover zones stuff and quota_new + # stuff from Essex for PostgreSQL. + if migrate_engine.name == "postgresql": + sql = """ALTER TABLE zones_id_seq RENAME TO cells_id_seq; + ALTER TABLE ONLY cells DROP CONSTRAINT zones_pkey; + ALTER TABLE ONLY cells ADD CONSTRAINT cells_pkey + PRIMARY KEY (id); + + ALTER TABLE quotas_new_id_seq RENAME TO quotas_id_seq; + ALTER TABLE ONLY quotas DROP CONSTRAINT quotas_new_pkey; + ALTER TABLE ONLY quotas ADD CONSTRAINT quotas_pkey + PRIMARY KEY (id);""" + migrate_engine.execute(sql) + + +def downgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + + if migrate_engine.name == "postgresql": + sql = """ALTER TABLE cells_id_seq RENAME TO zones_id_seq; + ALTER TABLE ONLY cells DROP CONSTRAINT cells_pkey; + ALTER TABLE ONLY cells ADD CONSTRAINT zones_pkey + PRIMARY KEY (id); + + ALTER TABLE quotas_id_seq RENAME TO quotas_new_id_seq; + ALTER TABLE ONLY quotas DROP CONSTRAINT quotas_pkey; + ALTER TABLE ONLY quotas ADD CONSTRAINT quotas_new_pkey + PRIMARY KEY (id);""" + migrate_engine.execute(sql) -- cgit