modules/core/dbutils/pom.xml | 8 -- modules/core/dbutils/src/main/java/org/rhq/core/db/OracleDatabaseType.java | 23 ++++++++ modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 27 ++++++++-- 3 files changed, 47 insertions(+), 11 deletions(-)
New commits: commit e80294f5775b38e4e99c242aef4cbfcc01fd2c45 Author: Jay Shaughnessy jshaughn@redhat.com Date: Tue Jan 31 13:15:04 2012 -0500
Add a demarcation comment for JON 3.0.1
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml index f005ff0..7dd68d4 100644 --- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml +++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml @@ -3828,6 +3828,8 @@ </schema-directSQL> </schemaSpec>
+<!-- JON 3.0.1 RELEASE uses DB Schema 2.118 --> + </dbupgrade> </target> </project>
commit b7faba1d8d376f32407fa306db7c0a5df4d63585 Author: Jay Shaughnessy jshaughn@redhat.com Date: Thu Dec 15 13:16:59 2011 -0500
Supporting check-in for [Bug 768031 - Pin template failure on upgraded dbs] - Fix a long standing issue in dbupgrade due to Oracle throwing exceptions when trying to set nullable to the current value. In other words, the upgrade would fail on oracle if you tried to set nullable false on a column that was already nullable false. (same for nullable true). This caused issues when you can't guarantee the current state, you just know what you need it to be. Now, catch the relevant exceptions and toss them as needed.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/OracleDatabaseType.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/OracleDatabaseType.java index afd9ed9..ad038b0 100644 --- a/modules/core/dbutils/src/main/java/org/rhq/core/db/OracleDatabaseType.java +++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/OracleDatabaseType.java @@ -25,6 +25,8 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List;
+import mazz.i18n.Logger; + /** * Superclass of all versions of the Oracle database. * @@ -32,6 +34,8 @@ import java.util.List; * */ public abstract class OracleDatabaseType extends DatabaseType { + private static final Logger LOG = DbUtilsI18NFactory.getLogger(OracleDatabaseType.class); + /** * The vendor name for all Oracle databases. */ @@ -156,7 +160,24 @@ public abstract class OracleDatabaseType extends DatabaseType {
sql += ")";
- executeSql(conn, sql); + try { + executeSql(conn, sql); + } catch (SQLException e) { + // Oracle throws an exception if you try to set nullable to its current setting. Ignore errors + // generated when a nullable setting is already the way we want it to be. + // ORA-01442: column to be modified to NOT NULL is already NOT NULL + // ORA-01451: column to be modified to NULL cannot be modified to NULL + if (nullable != null) { + String msg = e.getMessage(); + if (msg.contains("ORA-01442") || msg.contains("ORA-01451")) { + if (LOG.isDebugEnabled()) { + LOG.debug("Ignoring exception, column already set to nullable=" + nullable, e); + } + } else { + throw e; + } + } + }
if ((reindex != null) && reindex.booleanValue()) { reindexTable(conn, table);
commit 8667a4c591e4ef6f803d0b485e3e7cfda76f3440 Author: Jay Shaughnessy jshaughn@redhat.com Date: Thu Dec 15 13:18:32 2011 -0500
[Bug 768031 - Pin template failure on upgraded dbs] Set RHQ_DRIFT_CHANGE_SET.DRIFT_DEFINITION_ID nullable in the db upgrade.
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml index b77d98a..f005ff0 100644 --- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml +++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml @@ -3813,7 +3813,10 @@
<schemaSpec version="2.117"> <!-- Remove an obsolete drift table that may be hanging around --> - <schema-dropTable table="RHQ_DRIFT_TEMPLATE_MAP" /> + <schema-dropTable table="RHQ_DRIFT_TEMPLATE_MAP" /> + + <!-- Remove an unwanted null consraint --> + <schema-alterColumn table="RHQ_DRIFT_CHANGE_SET" column="DRIFT_DEFINITION_ID" nullable="TRUE" /> </schemaSpec>
<schemaSpec version="2.118">
commit 8b8ce32cf7bc2ab04c28d9717911007878ba895a Author: Jay Shaughnessy jshaughn@redhat.com Date: Mon Jan 9 15:45:21 2012 -0500
[Bug 772742 - DB upgrade gives "All Resources Role" an unintended permission] Fix the upgrade step that grants the bad permission. And add a new step to revoke it if it exists.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml index f08d22d..f58d07d 100644 --- a/modules/core/dbutils/pom.xml +++ b/modules/core/dbutils/pom.xml @@ -15,7 +15,7 @@ <description>Database schema setup, upgrade and other utilities</description>
<properties> - <db.schema.version>2.117</db.schema.version> + <db.schema.version>2.118</db.schema.version> <rhq.ds.type-mapping>${rhq.test.ds.type-mapping}</rhq.ds.type-mapping> <rhq.ds.db-name>${rhq.test.ds.db-name}</rhq.ds.db-name> <rhq.ds.connection-url>${rhq.test.ds.connection-url}</rhq.ds.connection-url> diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml index c690317..b77d98a 100644 --- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml +++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml @@ -3370,12 +3370,12 @@ </statement> </schema-directSQL>
- <!-- Now add modify the permissions to give all the roles with MANAGE_INVENTORY - the new MANAGE_REPOSITORIES privilege so that people's privs remain unchanged. --> + <!-- Now modify the permissions to give all the roles with MANAGE_INVENTORY, except for + all-resources-role, the new MANAGE_REPOSITORIES privilege so that privs remain unchanged. --> <schema-directSQL> <statement> INSERT INTO RHQ_PERMISSION (role_id, operation) - SELECT role_id, 15 FROM RHQ_PERMISSION WHERE operation = 1 + SELECT role_id, 15 FROM RHQ_PERMISSION WHERE operation = 1 AND NOT role_id = 2 </statement> </schema-directSQL> </schemaSpec> @@ -3815,6 +3815,15 @@ <!-- Remove an obsolete drift table that may be hanging around --> <schema-dropTable table="RHQ_DRIFT_TEMPLATE_MAP" /> </schemaSpec> + + <schemaSpec version="2.118"> + <!-- Correct an earlier upgrade issue where 'All Resources Role' was granted MANAGE_REPOSITORIES. --> + <schema-directSQL> + <statement> + DELETE FROM RHQ_PERMISSION WHERE role_id = 2 AND operation = 15 + </statement> + </schema-directSQL> + </schemaSpec>
</dbupgrade> </target>
commit fb7177edccdd59a8f33cdc1253d6d02428ea51b5 Author: Jay Shaughnessy jshaughn@redhat.com Date: Tue Jan 31 12:21:44 2012 -0500
Add 2.117 to remove an obsolete drift table that may exist after upgrades.
Conflicts:
modules/core/dbutils/pom.xml modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml index b298636..f08d22d 100644 --- a/modules/core/dbutils/pom.xml +++ b/modules/core/dbutils/pom.xml @@ -14,14 +14,8 @@ <name>RHQ Database Utilities</name> <description>Database schema setup, upgrade and other utilities</description>
- <scm> - <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/core/dbutils</connection> - <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/core/dbutils</developerConnection> - </scm> - <properties> - <scm.module.path>modules/core/dbutils/</scm.module.path> - <db.schema.version>2.116</db.schema.version> + <db.schema.version>2.117</db.schema.version> <rhq.ds.type-mapping>${rhq.test.ds.type-mapping}</rhq.ds.type-mapping> <rhq.ds.db-name>${rhq.test.ds.db-name}</rhq.ds.db-name> <rhq.ds.connection-url>${rhq.test.ds.connection-url}</rhq.ds.connection-url> diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml index fb2ed85..c690317 100644 --- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml +++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml @@ -3809,6 +3809,13 @@ <schema-alterColumn table="RHQ_PRD_VER" column="VERSION" columnType="VARCHAR2" precision="100" /> </schemaSpec>
+<!-- JON 3.0 RELEASE uses DB Schema 2.116 --> + + <schemaSpec version="2.117"> + <!-- Remove an obsolete drift table that may be hanging around --> + <schema-dropTable table="RHQ_DRIFT_TEMPLATE_MAP" /> + </schemaSpec> + </dbupgrade> </target> </project>
rhq-commits@lists.fedorahosted.org