[Rt-commit] rt branch, 4.2/drop-if-exists, created. rt-4.2.1-3-g04d58ea

Alex Vandiver alexmv at bestpractical.com
Wed Nov 20 18:04:13 EST 2013


The branch, 4.2/drop-if-exists has been created
        at  04d58ea61404cf199c1cae01ad59466b10ded870 (commit)

- Log -----------------------------------------------------------------
commit 04d58ea61404cf199c1cae01ad59466b10ded870
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Nov 20 17:53:31 2013 -0500

    Bullet-proof upgrade steps slighty, by dropping if the new table exists
    
    It is not uncommon to conduct a test upgrade, and then re-import the old
    data stop.  Because the backup contains 'DROP TABLE IF EXISTS ...' for
    the tables that existed in 4.0, this _mostly_ resets the database -- but
    leaves in place any additional tables that were created during the
    upgrade process.  Upon the next upgrade attempt, the process aborts
    because it cannot re-create table which was not dropped.
    
    While the most correct fix is to drop the database and re-create it with
    the backup, ensuring a pristine restore, this failure more can be
    ameliorated by attempting to drop the table before creating it.
    
    All backends except Oracle support DROP TABLE IF EXISTS, so use it.
    While it is possible to approximate DROP TABLE IF EXISTS on Oracle,
    doing so requires stored procedures, which the RT user may not have
    rights to run.  Since this is merely additional bullet-proofing, the
    inability to run it safely on Oracle should not halt the additional
    protections on other databases.

diff --git a/etc/upgrade/4.1.1/schema.Pg b/etc/upgrade/4.1.1/schema.Pg
index 25fe3c1..bb09c73 100644
--- a/etc/upgrade/4.1.1/schema.Pg
+++ b/etc/upgrade/4.1.1/schema.Pg
@@ -1,5 +1,7 @@
+DROP SEQUENCE IF EXISTS objectscrips_id_seq;
 CREATE SEQUENCE objectscrips_id_seq;
 
+DROP TABLE IF EXISTS ObjectScrips;
 CREATE TABLE ObjectScrips (
   id INTEGER DEFAULT nextval('objectscrips_id_seq'),
   Scrip integer NOT NULL,
diff --git a/etc/upgrade/4.1.1/schema.SQLite b/etc/upgrade/4.1.1/schema.SQLite
index a3a34f0..2a6a2c4 100644
--- a/etc/upgrade/4.1.1/schema.SQLite
+++ b/etc/upgrade/4.1.1/schema.SQLite
@@ -1,4 +1,4 @@
-
+DROP TABLE IF EXISTS ObjectScrips;
 CREATE TABLE ObjectScrips (
   id INTEGER NOT NULL  ,
   Scrip int NOT NULL  ,
diff --git a/etc/upgrade/4.1.1/schema.mysql b/etc/upgrade/4.1.1/schema.mysql
index d285019..2420d98 100644
--- a/etc/upgrade/4.1.1/schema.mysql
+++ b/etc/upgrade/4.1.1/schema.mysql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS ObjectScrips;
 CREATE TABLE ObjectScrips (
   id INTEGER NOT NULL  AUTO_INCREMENT,
   Scrip integer NOT NULL  ,

-----------------------------------------------------------------------


More information about the rt-commit mailing list