Merged V3.1 to HEAD

17006: Added implicit SQL script variables for TRUE and FALSE
   17007: Fixed ETHREEOH-2310: Upgrade from 2.1 E Sp7 to 3.1.1 E build 225 - Duplicate alf_node_status entries detected
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /alfresco/BRANCHES/V3.1:r17006-17007


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17089 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2009-10-22 13:58:35 +00:00
parent 0d51a96d7c
commit fd738ed890
5 changed files with 118 additions and 0 deletions

View File

@@ -94,6 +94,7 @@
<ref bean="patch.db-V2.1-NotNullColumns" /> <ref bean="patch.db-V2.1-NotNullColumns" />
<ref bean="patch.db-V2.2-ACL-From-2.1-A" /> <ref bean="patch.db-V2.2-ACL-From-2.1-A" />
<ref bean="patch.db-V2.2-ACL" /> <ref bean="patch.db-V2.2-ACL" />
<ref bean="patch.db-V2.2-CleanNodeStatuses" />
<ref bean="patch.db-V2.2-0-CreateMissingTables" /> <ref bean="patch.db-V2.2-0-CreateMissingTables" />
<ref bean="patch.db-V2.2-Upgrade-From-2.1" /> <ref bean="patch.db-V2.2-Upgrade-From-2.1" />
<ref bean="patch.db-V2.2-Upgrade-From-2.2SP1" /> <ref bean="patch.db-V2.2-Upgrade-From-2.2SP1" />

View File

@@ -0,0 +1,22 @@
--
-- Title: Clean duplicate alf_node_status entries
-- Database: Generic
-- Since: V3.1 schema 1011
-- Author: Derek Hulley
--
-- Please contact support@alfresco.com if you need assistance with the upgrade.
--
-- Does nothing. The script is only meaningful for DBs supported by Alfresco on V2.1
-- This script does not need to run if the server has already been upgraded to schema 90 or later
--
-- Record script finish
--
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V2.2-CleanNodeStatuses';
INSERT INTO alf_applied_patch
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
VALUES
(
'patch.db-V2.2-CleanNodeStatuses', 'Manually executed script upgrade V2.2: Clean alf_node_status table',
0, 89, -1, 90, null, 'UNKOWN', ${true}, ${true}, 'Script completed'
);

View File

@@ -0,0 +1,58 @@
--
-- Title: Clean duplicate alf_node_status entries
-- Database: MySQL
-- Since: V3.1 schema 1011
-- Author: Derek Hulley
--
-- Please contact support@alfresco.com if you need assistance with the upgrade.
--
-- Cleans out duplicate alf_node_status entries for V2.1 installations.
-- This script does not need to run if the server has already been upgraded to schema 90 or later
CREATE TABLE t_node_status
(
node_id INTEGER NOT NULL,
transaction_id BIGINT(20) NOT NULL,
PRIMARY KEY (node_id)
);
INSERT INTO t_node_status
(
SELECT c.node_id, c.transaction_id FROM
(
SELECT COUNT(node_id) x, ns.node_id, ns.transaction_id FROM alf_node_status ns GROUP BY node_id
) c
WHERE c.x > 1
);
DELETE FROM alf_node_status WHERE node_id IN (SELECT node_id FROM t_node_status);
INSERT INTO alf_node_status (protocol, identifier, guid, node_id, transaction_id, version)
(
SELECT n.protocol, n.identifier, n.uuid, n.id, tns.transaction_id, 0 FROM t_node_status tns JOIN alf_node n ON (n.id = tns.node_id)
);
DROP TABLE t_node_status;
DELETE FROM alf_node_status WHERE node_id IS NULL;
UPDATE alf_node_status ns SET ns.protocol =
(
SELECT n.protocol FROM alf_node n WHERE n.id = ns.node_id
);
DELETE
alf_transaction
FROM
alf_transaction
LEFT JOIN alf_node_status ON (alf_node_status.transaction_id = alf_transaction.id)
WHERE
alf_node_status.node_id is null;
--
-- Record script finish
--
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V2.2-CleanNodeStatuses';
INSERT INTO alf_applied_patch
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
VALUES
(
'patch.db-V2.2-CleanNodeStatuses', 'Manually executed script upgrade V2.2: Clean alf_node_status table',
0, 89, -1, 90, null, 'UNKOWN', ${true}, ${true}, 'Script completed'
);

View File

@@ -1148,6 +1148,21 @@
</property> </property>
</bean> </bean>
<bean id="patch.db-V2.2-CleanNodeStatuses" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch">
<property name="id"><value>patch.db-V2.2-CleanNodeStatuses</value></property>
<property name="description"><value>patch.schemaUpgradeScript.description</value></property>
<property name="fixesFromSchema"><value>0</value></property>
<property name="fixesToSchema"><value>89</value></property>
<property name="targetSchema"><value>90</value></property>
<property name="scriptUrl">
<value>classpath:alfresco/dbscripts/upgrade/2.2/${db.script.dialect}/AlfrescoSchemaUpdate-2.2-CleanNodeStatuses.sql</value>
</property>
<property name="alternatives" >
<list>
<ref bean="patch.db-V2.2-Upgrade-From-2.1" />
</list>
</property>
</bean>
<bean id="patch.db-V2.2-0-CreateMissingTables" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch"> <bean id="patch.db-V2.2-0-CreateMissingTables" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch">
<property name="id"><value>patch.db-V2.2-0-CreateMissingTables</value></property> <property name="id"><value>patch.db-V2.2-0-CreateMissingTables</value></property>
<property name="description"><value>patch.schemaUpgradeScript.description</value></property> <property name="description"><value>patch.schemaUpgradeScript.description</value></property>
@@ -1159,6 +1174,7 @@
</property> </property>
<property name="dependsOn" > <property name="dependsOn" >
<list> <list>
<ref bean="patch.db-V2.2-CleanNodeStatuses" />
<ref bean="patch.db-V2.2-ACL" /> <ref bean="patch.db-V2.2-ACL" />
</list> </list>
</property> </property>
@@ -1181,6 +1197,7 @@
</property> </property>
<property name="dependsOn" > <property name="dependsOn" >
<list> <list>
<ref bean="patch.db-V2.2-CleanNodeStatuses" />
<ref bean="patch.db-V2.2-0-CreateMissingTables" /> <ref bean="patch.db-V2.2-0-CreateMissingTables" />
</list> </list>
</property> </property>

View File

@@ -889,6 +889,8 @@ public class SchemaBootstrap extends AbstractLifecycleBean
File scriptFile, File scriptFile,
String scriptUrl) throws Exception String scriptUrl) throws Exception
{ {
final Dialect dialect = Dialect.getDialect(cfg.getProperties());
StringBuilder executedStatements = executedStatementsThreadLocal.get(); StringBuilder executedStatements = executedStatementsThreadLocal.get();
if (executedStatements == null) if (executedStatements == null)
{ {
@@ -917,6 +919,24 @@ public class SchemaBootstrap extends AbstractLifecycleBean
String fetchVarName = null; String fetchVarName = null;
String fetchColumnName = null; String fetchColumnName = null;
Map<String, Object> varAssignments = new HashMap<String, Object>(13); Map<String, Object> varAssignments = new HashMap<String, Object>(13);
// Special variable assignments:
if (dialect instanceof PostgreSQLDialect)
{
// Needs 1/0 for true/false
varAssignments.put("true", "true");
varAssignments.put("false", "false");
varAssignments.put("TRUE", "TRUE");
varAssignments.put("FALSE", "FALSE");
}
else
{
// Needs true/false as strings
varAssignments.put("true", "1");
varAssignments.put("false", "0");
varAssignments.put("TRUE", "1");
varAssignments.put("FALSE", "0");
}
while(true) while(true)
{ {
String sqlOriginal = reader.readLine(); String sqlOriginal = reader.readLine();