From 675e0e5889cce269a758abf5fc6933dd09b0f9fd Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Fri, 12 Sep 2014 10:57:34 +0200 Subject: [PATCH] SQL scripts should not manage transactions Cinder SQL scripts assume too much about the environment and the way in which they are executed by sqlalchemy-migrate. Particularly, they manage transactions on their own even though sqlalchemy-migrate do it itself, plus it assumes that scripts are executed in one go (even though standard Python DB-API 2.0 does not mention multi-statement SQL commands to be executed on DB cursors. blueprint enable-mysql-connector Change-Id: I10c58b3af75d3ab9153a8bbd2a539bf1577de328 Closes-Bug: 1368391 --- .../sqlalchemy/migrate_repo/versions/005_sqlite_downgrade.sql | 3 --- .../sqlalchemy/migrate_repo/versions/007_sqlite_downgrade.sql | 4 ---- .../sqlalchemy/migrate_repo/versions/011_sqlite_downgrade.sql | 3 --- .../sqlalchemy/migrate_repo/versions/012_sqlite_downgrade.sql | 3 --- .../sqlalchemy/migrate_repo/versions/013_sqlite_downgrade.sql | 3 --- .../sqlalchemy/migrate_repo/versions/014_sqlite_downgrade.sql | 3 --- 6 files changed, 19 deletions(-) diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/005_sqlite_downgrade.sql b/cinder/db/sqlalchemy/migrate_repo/versions/005_sqlite_downgrade.sql index c34f31752..51dd54f7e 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/005_sqlite_downgrade.sql +++ b/cinder/db/sqlalchemy/migrate_repo/versions/005_sqlite_downgrade.sql @@ -1,5 +1,3 @@ -BEGIN TRANSACTION; - CREATE TEMPORARY TABLE volumes_backup ( created_at DATETIME, updated_at DATETIME, @@ -121,4 +119,3 @@ INSERT INTO volumes FROM volumes_backup; DROP TABLE volumes_backup; -COMMIT; diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/007_sqlite_downgrade.sql b/cinder/db/sqlalchemy/migrate_repo/versions/007_sqlite_downgrade.sql index d2fe9b693..5c73a1c6d 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/007_sqlite_downgrade.sql +++ b/cinder/db/sqlalchemy/migrate_repo/versions/007_sqlite_downgrade.sql @@ -1,8 +1,6 @@ -- As sqlite does not support the DROP FOREIGN KEY, we need to create -- the table, and move all the data to it. -BEGIN TRANSACTION; - CREATE TABLE snapshots_v6 ( created_at DATETIME, updated_at DATETIME, @@ -28,5 +26,3 @@ INSERT INTO snapshots_v6 SELECT * FROM snapshots; DROP TABLE snapshots; ALTER TABLE snapshots_v6 RENAME TO snapshots; - -COMMIT; diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/011_sqlite_downgrade.sql b/cinder/db/sqlalchemy/migrate_repo/versions/011_sqlite_downgrade.sql index f27f48541..d86ea6a98 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/011_sqlite_downgrade.sql +++ b/cinder/db/sqlalchemy/migrate_repo/versions/011_sqlite_downgrade.sql @@ -1,5 +1,3 @@ -BEGIN TRANSACTION; - CREATE TABLE volumes_v10 ( created_at DATETIME, updated_at DATETIME, @@ -61,4 +59,3 @@ INSERT INTO volumes_v10 DROP TABLE volumes; ALTER TABLE volumes_v10 RENAME TO volumes; -COMMIT; diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/012_sqlite_downgrade.sql b/cinder/db/sqlalchemy/migrate_repo/versions/012_sqlite_downgrade.sql index f3813cc5c..0170e8d89 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/012_sqlite_downgrade.sql +++ b/cinder/db/sqlalchemy/migrate_repo/versions/012_sqlite_downgrade.sql @@ -1,5 +1,3 @@ -BEGIN TRANSACTION; - CREATE TABLE volumes_v11 ( created_at DATETIME, updated_at DATETIME, @@ -63,4 +61,3 @@ INSERT INTO volumes_v11 DROP TABLE volumes; ALTER TABLE volumes_v11 RENAME TO volumes; -COMMIT; diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/013_sqlite_downgrade.sql b/cinder/db/sqlalchemy/migrate_repo/versions/013_sqlite_downgrade.sql index 509fe434b..b42162863 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/013_sqlite_downgrade.sql +++ b/cinder/db/sqlalchemy/migrate_repo/versions/013_sqlite_downgrade.sql @@ -1,5 +1,3 @@ -BEGIN TRANSACTION; - CREATE TABLE volumes_v12 ( created_at DATETIME, updated_at DATETIME, @@ -65,4 +63,3 @@ INSERT INTO volumes_v12 DROP TABLE volumes; ALTER TABLE volumes_v12 RENAME TO volumes; -COMMIT; diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/014_sqlite_downgrade.sql b/cinder/db/sqlalchemy/migrate_repo/versions/014_sqlite_downgrade.sql index a8260fa97..688516830 100644 --- a/cinder/db/sqlalchemy/migrate_repo/versions/014_sqlite_downgrade.sql +++ b/cinder/db/sqlalchemy/migrate_repo/versions/014_sqlite_downgrade.sql @@ -1,5 +1,3 @@ -BEGIN TRANSACTION; - CREATE TABLE volumes_v13 ( created_at DATETIME, updated_at DATETIME, @@ -67,4 +65,3 @@ INSERT INTO volumes_v13 DROP TABLE volumes; ALTER TABLE volumes_v13 RENAME TO volumes; -COMMIT; -- 2.45.2