Fixed RelationAttributeACSObject upgrade.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2280 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-07-31 16:47:50 +00:00
parent cc7014141b
commit 2ce26b2386
1 changed files with 22 additions and 11 deletions

View File

@ -62,23 +62,36 @@ public class RelationAttributeACSObject extends Program {
} }
System.out.printf("Found %d RelationAttributes entries.\n", entries.size()); System.out.printf("Found %d RelationAttributes entries.\n", entries.size());
stmt.addBatch("DROP TABLE 'cms_relation_attribute';"); stmt.addBatch("ALTER TABLE cms_relation_attribute DROP CONSTRAINT cms_rel_att_att_key_at_u_nh3g1");
stmt.addBatch("CREATE TABLE cms_relation_attribute object_id integer NOT NULL," 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," + "attribute character varying(100) NOT NULL,"
+ "attr_key character varying(100) NOT NULL," + "attr_key character varying(100) NOT NULL,"
+ "lang character varying(2) NOT NULL," + "lang character varying(2) NOT NULL,"
+ "name character varying(100) NOT NULL," + "name character varying(100) NOT NULL,"
+ "description character varying(500)"); + "description character varying(500))");
stmt.addBatch("ALTER TABLE public.cms_relation_attribute OWNER TO ccm;"); 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 " 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);"); + "ADD CONSTRAINT cms_rela_attrib_obj_id_f_23qc3 FOREIGN KEY (object_id) REFERENCES acs_objects(object_id);");
stmt.executeBatch(); stmt.executeBatch();
connection.commit();
close(connection); close(connection);
} catch (SQLException ex) { } catch (SQLException ex) {
System.err.printf("SQL Error"); System.err.printf("SQL Error\n");
//ex.printStackTrace(System.err);
SQLException currentEx = ex;
while (currentEx != null) {
ex.printStackTrace(System.err);
System.out.println(" ");
currentEx = currentEx.getNextException();
}
rollback(connection); rollback(connection);
close(connection); close(connection);
return; return;
@ -89,7 +102,6 @@ public class RelationAttributeACSObject extends Program {
} }
} }
}.excurse(); }.excurse();
} }
@ -182,6 +194,5 @@ public class RelationAttributeACSObject extends Program {
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
} }
} }