From 95f1b08a3701c612777b3c3d2ab8e6258834cbd3 Mon Sep 17 00:00:00 2001 From: jensp Date: Fri, 12 Dec 2014 18:38:55 +0000 Subject: [PATCH] Several fixes for upgrades (for Oracle). git-svn-id: https://svn.libreccm.org/ccm/trunk@3044 8810af33-2d31-482b-a856-94f89814c4df --- .../upgrades/AbstractBundleUpgrade.java | 28 +++++++++---------- .../upgrade/RelationAttributeACSObject.java | 16 +++++------ .../6.6.0-6.6.1/upd_application_tables.sql | 3 +- .../upgrade/oracle-se-6.5.2-6.5.3.sql | 2 +- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/upgrades/AbstractBundleUpgrade.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/upgrades/AbstractBundleUpgrade.java index 3e85308eb..3be6178df 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/upgrades/AbstractBundleUpgrade.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/upgrades/AbstractBundleUpgrade.java @@ -50,25 +50,23 @@ public abstract class AbstractBundleUpgrade { System.out.printf("Creating new table %s...\n", getBundleTableName()); final Statement stmt = conn.createStatement(); - stmt.addBatch(String.format("CREATE TABLE %s ( " - + "bundle_id integer NOT NULL);", - getBundleTableName())); + String createTable = String.format("CREATE TABLE %s ( bundle_id integer NOT NULL)", + getBundleTableName()); + System.out.println(createTable); + stmt.execute(createTable); - stmt.addBatch(String.format("ALTER TABLE ONLY %s " - + "ADD CONSTRAINT %s " - + "PRIMARY KEY (bundle_id);", + String primaryKey = String.format("ALTER TABLE %s ADD CONSTRAINT %s PRIMARY KEY (bundle_id)", getBundleTableName(), - getPrimaryKeyConstraintName())); - - stmt.addBatch(String.format("ALTER TABLE ONLY %s " - + "ADD CONSTRAINT %s " - + "FOREIGN KEY (bundle_id) " - + "REFERENCES %s(bundle_id);", + getPrimaryKeyConstraintName()); + System.out.println(primaryKey); + stmt.execute(primaryKey); + + String foreignKey = String.format("ALTER TABLE %s ADD CONSTRAINT %s FOREIGN KEY (bundle_id) REFERENCES %s(bundle_id)", getBundleTableName(), getBundleContraintName(), - getSuperBundleTable())); - - stmt.executeBatch(); + getSuperBundleTable()); + System.out.println(foreignKey); + stmt.execute(foreignKey); } catch (SQLException ex) { System.err.printf("Failed to create table %s.\n", diff --git a/ccm-cms/src/com/arsdigita/cms/upgrade/RelationAttributeACSObject.java b/ccm-cms/src/com/arsdigita/cms/upgrade/RelationAttributeACSObject.java index 8ff4ba24c..99424cde5 100644 --- a/ccm-cms/src/com/arsdigita/cms/upgrade/RelationAttributeACSObject.java +++ b/ccm-cms/src/com/arsdigita/cms/upgrade/RelationAttributeACSObject.java @@ -49,7 +49,7 @@ public class RelationAttributeACSObject extends Program { final Statement stmt = connection.createStatement(); final ResultSet result = stmt.executeQuery( - "SELECT attribute, attr_key, lang, name, description FROM cms_relation_attribute;"); + "SELECT attribute, attr_key, lang, name, description FROM cms_relation_attribute"); while (result.next()) { final RelationAttributeEntry entry = new RelationAttributeEntry(); @@ -63,19 +63,19 @@ public class RelationAttributeACSObject extends Program { System.out.printf("Found %d RelationAttributes entries.\n", entries.size()); stmt.addBatch("ALTER TABLE cms_relation_attribute DROP CONSTRAINT cms_rel_att_att_key_at_u_nh3g1"); - stmt.addBatch("DROP TABLE cms_relation_attribute;"); + stmt.addBatch("DROP TABLE cms_relation_attribute"); stmt.addBatch("CREATE TABLE cms_relation_attribute (object_id integer NOT NULL," + "attribute character varying(100) NOT NULL," + "attr_key character varying(100) NOT NULL," + "lang character varying(2) NOT NULL," + "name character varying(100) NOT NULL," + "description character varying(500))"); - stmt.addBatch("ALTER TABLE ONLY cms_relation_attribute " - + " ADD CONSTRAINT cms_rela_attrib_obj_id_p_qdgsr PRIMARY KEY (object_id);"); - stmt.addBatch("ALTER TABLE ONLY cms_relation_attribute " - + "ADD CONSTRAINT cms_rel_att_att_key_at_u_nh3g1 UNIQUE (attribute, attr_key, lang);"); - stmt.addBatch("ALTER TABLE ONLY cms_relation_attribute " - + "ADD CONSTRAINT cms_rela_attrib_obj_id_f_23qc3 FOREIGN KEY (object_id) REFERENCES acs_objects(object_id);"); + stmt.addBatch("ALTER TABLE cms_relation_attribute " + + " ADD CONSTRAINT cms_rela_attrib_obj_id_p_qdgsr PRIMARY KEY (object_id)"); + stmt.addBatch("ALTER TABLE cms_relation_attribute " + + "ADD CONSTRAINT cms_rel_att_att_key_at_u_nh3g1 UNIQUE (attribute, attr_key, lang)"); + stmt.addBatch("ALTER TABLE cms_relation_attribute " + + "ADD CONSTRAINT cms_rela_attrib_obj_id_f_23qc3 FOREIGN KEY (object_id) REFERENCES acs_objects(object_id)"); stmt.executeBatch(); diff --git a/ccm-navigation/sql/ccm-navigation/upgrade/oracle-se/6.6.0-6.6.1/upd_application_tables.sql b/ccm-navigation/sql/ccm-navigation/upgrade/oracle-se/6.6.0-6.6.1/upd_application_tables.sql index b09ce5a67..071488ce5 100644 --- a/ccm-navigation/sql/ccm-navigation/upgrade/oracle-se/6.6.0-6.6.1/upd_application_tables.sql +++ b/ccm-navigation/sql/ccm-navigation/upgrade/oracle-se/6.6.0-6.6.1/upd_application_tables.sql @@ -26,6 +26,5 @@ update application_types set object_type = 'com.arsdigita.navigation.portlet.NavigationTreePortlet', title = 'Navigation Tree', description = 'Displays a tree of navigation categories' - set (object_type,title,description) = - where object_type like 'com.arsdigita.portalworkspace.portlet.NavigationDirectoryPortlet' ; + where object_type like 'com.arsdigita.portalworkspace.portlet.NavigationDirectoryPortlet' ; diff --git a/ccm-portalworkspace/sql/ccm-portalworkspace/upgrade/oracle-se-6.5.2-6.5.3.sql b/ccm-portalworkspace/sql/ccm-portalworkspace/upgrade/oracle-se-6.5.2-6.5.3.sql index 4572bc30a..d0237be92 100644 --- a/ccm-portalworkspace/sql/ccm-portalworkspace/upgrade/oracle-se-6.5.2-6.5.3.sql +++ b/ccm-portalworkspace/sql/ccm-portalworkspace/upgrade/oracle-se-6.5.2-6.5.3.sql @@ -14,5 +14,5 @@ -- along with this library; if not, write to the Free Software Foundation, Inc., -- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -@@ /default/6.5.2-6.5.3/add-flash-portlet.sql +@@ default/6.5.2-6.5.3/add-flash-portlet.sql