1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package com.xpn.xwiki.store.migration.hibernate; |
22 |
|
|
23 |
|
import java.sql.SQLException; |
24 |
|
import java.sql.Statement; |
25 |
|
|
26 |
|
import javax.inject.Named; |
27 |
|
import javax.inject.Singleton; |
28 |
|
|
29 |
|
import org.hibernate.HibernateException; |
30 |
|
import org.hibernate.Session; |
31 |
|
import org.xwiki.component.annotation.Component; |
32 |
|
|
33 |
|
import com.xpn.xwiki.XWikiException; |
34 |
|
import com.xpn.xwiki.store.XWikiHibernateBaseStore.HibernateCallback; |
35 |
|
import com.xpn.xwiki.store.migration.DataMigrationException; |
36 |
|
import com.xpn.xwiki.store.migration.XWikiDBVersion; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
@version |
45 |
|
@since |
46 |
|
@since |
47 |
|
|
48 |
|
@Component |
49 |
|
@Named("R7345XWIKI2079") |
50 |
|
@Singleton |
|
|
| 12.5% |
Uncovered Elements: 14 (16) |
Complexity: 6 |
Complexity Density: 0.5 |
|
51 |
|
public class R7350XWIKI2079DataMigration extends AbstractHibernateDataMigration |
52 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
53 |
0 |
@Override... |
54 |
|
public String getDescription() |
55 |
|
{ |
56 |
0 |
return "See http://jira.xwiki.org/jira/browse/XWIKI-2079"; |
57 |
|
} |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
206 |
@Override... |
60 |
|
public XWikiDBVersion getVersion() |
61 |
|
{ |
62 |
206 |
return new XWikiDBVersion(7350); |
63 |
|
} |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
0 |
@Override... |
66 |
|
public void hibernateMigrate() throws DataMigrationException, XWikiException |
67 |
|
{ |
68 |
0 |
getStore().executeWrite(getXWikiContext(), true, new HibernateCallback<Object>() |
69 |
|
{ |
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.33 |
|
70 |
0 |
@Override... |
71 |
|
public Object doInHibernate(Session session) throws HibernateException, XWikiException |
72 |
|
{ |
73 |
0 |
try { |
74 |
0 |
Statement stmt = session.connection().createStatement(); |
75 |
0 |
stmt.executeUpdate("ALTER TABLE xwikidoc DROP COLUMN XWD_ARCHIVE"); |
76 |
0 |
stmt.close(); |
77 |
|
} catch (SQLException ex) { |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
0 |
try { |
83 |
0 |
Statement stmt = session.connection().createStatement(); |
84 |
0 |
stmt.executeUpdate("ALTER TABLE xwikidoc ALTER COLUMN XWD_ARCHIVE " + "SET DEFAULT ' '"); |
85 |
0 |
stmt.close(); |
86 |
|
} catch (SQLException ex2) { |
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
} |
94 |
|
} |
95 |
|
|
96 |
0 |
return Boolean.TRUE; |
97 |
|
} |
98 |
|
}); |
99 |
|
} |
100 |
|
} |