[Rt-commit] rt branch, 4.2/drop-more-if-exists, created. rt-4.2.3-31-g5287d4f

Kevin Falcone falcone at bestpractical.com
Wed Mar 12 15:34:36 EDT 2014


The branch, 4.2/drop-more-if-exists has been created
        at  5287d4fcc8dc70038da97dc4ea5299bfdf80398e (commit)

- Log -----------------------------------------------------------------
commit 5287d4fcc8dc70038da97dc4ea5299bfdf80398e
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Wed Mar 12 15:13:44 2014 -0400

    Add more bullet-proofing to upgrade steps
    
    This builds on the work in 04d58ea6.  During an upgrade, it's common to
    restore from your backup without clearing out the current database,
    meaning tables are left behind and cause errors when we try to create
    them again.
    
    As noted previously, DROP TABLE IF EXISTS is painful on Oracle, so we
    don't bother jumping through hoops.
    
    The Pg steps are simpler here than in 04d58ea6 because the ids are
    declared as type SERIAL so Pg auto-manages dropping/creating the
    sequences for us.

diff --git a/etc/upgrade/3.9.8/schema.Pg b/etc/upgrade/3.9.8/schema.Pg
index d12e27a..1f56d3b 100644
--- a/etc/upgrade/3.9.8/schema.Pg
+++ b/etc/upgrade/3.9.8/schema.Pg
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS Classes;
 CREATE TABLE Classes (
 id SERIAL,
 Name varchar(255) NOT NULL DEFAULT '',
@@ -12,6 +13,7 @@ HotList smallint NOT NULL DEFAULT 0,
 PRIMARY KEY (id)
 );
 
+DROP TABLE IF EXISTS Articles;
 CREATE TABLE Articles (
 id SERIAL,
 Name varchar(255) NOT NULL DEFAULT '',
@@ -28,6 +30,7 @@ PRIMARY KEY (id)
 );
 
 
+DROP TABLE IF EXISTS Topics;
 CREATE TABLE Topics (
 id SERIAL,
 Parent integer NOT NULL DEFAULT 0,
@@ -39,6 +42,7 @@ PRIMARY KEY (id)
 );
 
 
+DROP TABLE IF EXISTS ObjectTopics;
 CREATE TABLE ObjectTopics (
 id SERIAL,
 Topic integer NOT NULL,
@@ -48,6 +52,7 @@ PRIMARY KEY (id)
 );
 
 
+DROP TABLE IF EXISTS ObjectClasses;
 CREATE TABLE ObjectClasses (
 id SERIAL,
 Class integer NOT NULL,
diff --git a/etc/upgrade/3.9.8/schema.SQLite b/etc/upgrade/3.9.8/schema.SQLite
index 29ed7e8..b5af936 100644
--- a/etc/upgrade/3.9.8/schema.SQLite
+++ b/etc/upgrade/3.9.8/schema.SQLite
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS Classes;
 CREATE TABLE Classes (
 id INTEGER PRIMARY KEY,
 Name varchar(255) NOT NULL DEFAULT '',
@@ -11,6 +12,7 @@ LastUpdated TIMESTAMP NULL,
 HotList smallint NOT NULL DEFAULT 0
 );
 
+DROP TABLE IF EXISTS Articles;
 CREATE TABLE Articles (
 id INTEGER PRIMARY KEY,
 Name varchar(255) NOT NULL DEFAULT '',
@@ -25,7 +27,7 @@ LastUpdatedBy integer NOT NULL DEFAULT 0,
 LastUpdated TIMESTAMP NULL
 );
 
-
+DROP TABLE IF EXISTS Topics;
 CREATE TABLE Topics (
 id INTEGER PRIMARY KEY,
 Parent integer NOT NULL DEFAULT 0,
@@ -36,6 +38,7 @@ ObjectId integer NOT NULL
 );
 
 
+DROP TABLE IF EXISTS ObjectTopics;
 CREATE TABLE ObjectTopics (
 id INTEGER PRIMARY KEY,
 Topic integer NOT NULL,
@@ -43,6 +46,7 @@ ObjectType varchar(64) NOT NULL DEFAULT '',
 ObjectId integer NOT NULL
 );
 
+DROP TABLE IF EXISTS ObjectClasses;
 CREATE TABLE ObjectClasses (
 id INTEGER PRIMARY KEY,
 Class integer NOT NULL,
diff --git a/etc/upgrade/3.9.8/schema.mysql b/etc/upgrade/3.9.8/schema.mysql
index e7ed84d..4eaa3a1 100644
--- a/etc/upgrade/3.9.8/schema.mysql
+++ b/etc/upgrade/3.9.8/schema.mysql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS Classes;
 CREATE TABLE Classes (
   id int(11) NOT NULL auto_increment,
   Name varchar(255) NOT NULL default '',
@@ -12,6 +13,7 @@ CREATE TABLE Classes (
   PRIMARY KEY  (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+DROP TABLE IF EXISTS Articles;
 CREATE TABLE Articles (
   id int(11) NOT NULL auto_increment,
   Name varchar(255) NOT NULL default '',
@@ -27,6 +29,7 @@ CREATE TABLE Articles (
   PRIMARY KEY  (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+DROP TABLE IF EXISTS Topics;
 CREATE TABLE Topics (
   id int(11) NOT NULL auto_increment,
   Parent int(11) NOT NULL default '0',
@@ -37,6 +40,7 @@ CREATE TABLE Topics (
   PRIMARY KEY  (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+DROP TABLE IF EXISTS ObjectTopics;
 CREATE TABLE ObjectTopics (
   id int(11) NOT NULL auto_increment,
   Topic int(11) NOT NULL default '0',
@@ -45,6 +49,7 @@ CREATE TABLE ObjectTopics (
   PRIMARY KEY  (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+DROP TABLE IF EXISTS ObjectClasses;
 CREATE TABLE ObjectClasses (
   id int(11) NOT NULL auto_increment,
   Class int(11) NOT NULL default '0',

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


More information about the rt-commit mailing list