Fixed RelationAttributeACSObject upgrade.
git-svn-id: https://svn.libreccm.org/ccm/trunk@2280 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
cc7014141b
commit
2ce26b2386
|
|
@ -46,8 +46,8 @@ public class RelationAttributeACSObject extends Program {
|
||||||
|
|
||||||
final List<RelationAttributeEntry> entries = new ArrayList<RelationAttributeEntry>();
|
final List<RelationAttributeEntry> entries = new ArrayList<RelationAttributeEntry>();
|
||||||
try {
|
try {
|
||||||
final Statement stmt = connection.createStatement();
|
final Statement stmt = connection.createStatement();
|
||||||
|
|
||||||
final ResultSet result = stmt.executeQuery(
|
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;");
|
||||||
|
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -86,10 +99,9 @@ public class RelationAttributeACSObject extends Program {
|
||||||
|
|
||||||
for (RelationAttributeEntry entry : entries) {
|
for (RelationAttributeEntry entry : entries) {
|
||||||
createRelationAttribute(entry);
|
createRelationAttribute(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}.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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue