-
-
Notifications
You must be signed in to change notification settings - Fork 542
/
XWikiDBVersion.java
81 lines (73 loc) · 2.57 KB
/
XWikiDBVersion.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package com.xpn.xwiki.store.migration;
/**
* Stores XWiki's data version in the database. Used to find out which migrations to execute based on the current data
* version in the Database (each migration says which minimal version it requires to execute).
* <p>
* The version scheme in the past was to use the SVN revision number of the commit of the migrator but since we've now
* moved to Git we're now using an integer matching the current XWiki version and allowing for a range of 1000
* migrations. So if you're writing the first migrator for version 5.2 of XWiki then the version will be 52000. If
* you're writing the 2nd migration for XWiki 5.2 then its version would be 52001, etc.
*
* @version $Id$
*/
public class XWikiDBVersion implements Comparable<XWikiDBVersion>
{
/** svn revision number. */
private int version;
/** Default constructor. It is need for Hibernate. */
public XWikiDBVersion()
{
}
/** @param version - data version */
public XWikiDBVersion(int version)
{
this.version = version;
}
/** @return data version */
public int getVersion()
{
return this.version;
}
/** @param version - data version */
protected void setVersion(int version)
{
this.version = version;
}
@Override
public int compareTo(XWikiDBVersion o)
{
if (o == null) {
return -1;
}
return Integer.valueOf(getVersion()).compareTo(o.getVersion());
}
@Override
public String toString()
{
return String.valueOf(this.version);
}
/** @return next version */
public XWikiDBVersion increment()
{
return new XWikiDBVersion(getVersion() + 1);
}
}