diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/Migration.cs | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/OpenSim/Data/Migration.cs b/OpenSim/Data/Migration.cs index 6857c2c..ecd18ae 100644 --- a/OpenSim/Data/Migration.cs +++ b/OpenSim/Data/Migration.cs | |||
@@ -36,7 +36,7 @@ using log4net; | |||
36 | 36 | ||
37 | namespace OpenSim.Data | 37 | namespace OpenSim.Data |
38 | { | 38 | { |
39 | /// <summary> | 39 | /// <summary> |
40 | /// | 40 | /// |
41 | /// The Migration theory is based on the ruby on rails concept. | 41 | /// The Migration theory is based on the ruby on rails concept. |
42 | /// Each database driver is going to be allowed to have files in | 42 | /// Each database driver is going to be allowed to have files in |
@@ -77,11 +77,11 @@ namespace OpenSim.Data | |||
77 | // private string _subtype; | 77 | // private string _subtype; |
78 | private Assembly _assem; | 78 | private Assembly _assem; |
79 | private Regex _match; | 79 | private Regex _match; |
80 | 80 | ||
81 | private static readonly string _migrations_create = "create table migrations(name varchar(100), version int)"; | 81 | private static readonly string _migrations_create = "create table migrations(name varchar(100), version int)"; |
82 | // private static readonly string _migrations_init = "insert into migrations values('migrations', 1)"; | 82 | // private static readonly string _migrations_init = "insert into migrations values('migrations', 1)"; |
83 | // private static readonly string _migrations_find = "select version from migrations where name='migrations'"; | 83 | // private static readonly string _migrations_find = "select version from migrations where name='migrations'"; |
84 | 84 | ||
85 | public Migration(DbConnection conn, Assembly assem, string type) | 85 | public Migration(DbConnection conn, Assembly assem, string type) |
86 | { | 86 | { |
87 | _type = type; | 87 | _type = type; |
@@ -105,7 +105,7 @@ namespace OpenSim.Data | |||
105 | // clever, eh, we figure out which migrations version we are | 105 | // clever, eh, we figure out which migrations version we are |
106 | int migration_version = FindVersion("migrations"); | 106 | int migration_version = FindVersion("migrations"); |
107 | 107 | ||
108 | if (migration_version > 0) | 108 | if (migration_version > 0) |
109 | return; | 109 | return; |
110 | 110 | ||
111 | // If not, create the migration tables | 111 | // If not, create the migration tables |
@@ -130,14 +130,14 @@ namespace OpenSim.Data | |||
130 | m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!"); | 130 | m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!"); |
131 | 131 | ||
132 | DbCommand cmd = _conn.CreateCommand(); | 132 | DbCommand cmd = _conn.CreateCommand(); |
133 | foreach (KeyValuePair<int, string> kvp in migrations) | 133 | foreach (KeyValuePair<int, string> kvp in migrations) |
134 | { | 134 | { |
135 | int newversion = kvp.Key; | 135 | int newversion = kvp.Key; |
136 | cmd.CommandText = kvp.Value; | 136 | cmd.CommandText = kvp.Value; |
137 | // we need to up the command timeout to infinite as we might be doing long migrations. | 137 | // we need to up the command timeout to infinite as we might be doing long migrations. |
138 | cmd.CommandTimeout = 0; | 138 | cmd.CommandTimeout = 0; |
139 | cmd.ExecuteNonQuery(); | 139 | cmd.ExecuteNonQuery(); |
140 | 140 | ||
141 | if (version == 0) | 141 | if (version == 0) |
142 | { | 142 | { |
143 | InsertVersion(_type, newversion); | 143 | InsertVersion(_type, newversion); |
@@ -158,7 +158,7 @@ namespace OpenSim.Data | |||
158 | // foreach (string s in names) | 158 | // foreach (string s in names) |
159 | // { | 159 | // { |
160 | // Match m = _match.Match(s); | 160 | // Match m = _match.Match(s); |
161 | // if (m.Success) | 161 | // if (m.Success) |
162 | // { | 162 | // { |
163 | // int MigrationVersion = int.Parse(m.Groups[1].ToString()); | 163 | // int MigrationVersion = int.Parse(m.Groups[1].ToString()); |
164 | // if (MigrationVersion > max) | 164 | // if (MigrationVersion > max) |
@@ -168,10 +168,10 @@ namespace OpenSim.Data | |||
168 | // return max; | 168 | // return max; |
169 | // } | 169 | // } |
170 | 170 | ||
171 | public int Version | 171 | public int Version |
172 | { | 172 | { |
173 | get { return FindVersion(_type); } | 173 | get { return FindVersion(_type); } |
174 | set { | 174 | set { |
175 | if (Version < 1) | 175 | if (Version < 1) |
176 | { | 176 | { |
177 | InsertVersion(_type, value); | 177 | InsertVersion(_type, value); |
@@ -179,11 +179,11 @@ namespace OpenSim.Data | |||
179 | else | 179 | else |
180 | { | 180 | { |
181 | UpdateVersion(_type, value); | 181 | UpdateVersion(_type, value); |
182 | } | 182 | } |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | private int FindVersion(string type) | 186 | private int FindVersion(string type) |
187 | { | 187 | { |
188 | int version = 0; | 188 | int version = 0; |
189 | DbCommand cmd = _conn.CreateCommand(); | 189 | DbCommand cmd = _conn.CreateCommand(); |
@@ -206,22 +206,22 @@ namespace OpenSim.Data | |||
206 | return version; | 206 | return version; |
207 | } | 207 | } |
208 | 208 | ||
209 | private void InsertVersion(string type, int version) | 209 | private void InsertVersion(string type, int version) |
210 | { | 210 | { |
211 | DbCommand cmd = _conn.CreateCommand(); | 211 | DbCommand cmd = _conn.CreateCommand(); |
212 | cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")"; | 212 | cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")"; |
213 | m_log.InfoFormat("[MIGRATIONS] Creating {0} at version {1}", type, version); | 213 | m_log.InfoFormat("[MIGRATIONS] Creating {0} at version {1}", type, version); |
214 | cmd.ExecuteNonQuery(); | 214 | cmd.ExecuteNonQuery(); |
215 | } | 215 | } |
216 | 216 | ||
217 | private void UpdateVersion(string type, int version) | 217 | private void UpdateVersion(string type, int version) |
218 | { | 218 | { |
219 | DbCommand cmd = _conn.CreateCommand(); | 219 | DbCommand cmd = _conn.CreateCommand(); |
220 | cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'"; | 220 | cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'"; |
221 | m_log.InfoFormat("[MIGRATIONS] Updating {0} to version {1}", type, version); | 221 | m_log.InfoFormat("[MIGRATIONS] Updating {0} to version {1}", type, version); |
222 | cmd.ExecuteNonQuery(); | 222 | cmd.ExecuteNonQuery(); |
223 | } | 223 | } |
224 | 224 | ||
225 | // private SortedList<int, string> GetAllMigrations() | 225 | // private SortedList<int, string> GetAllMigrations() |
226 | // { | 226 | // { |
227 | // return GetMigrationsAfter(0); | 227 | // return GetMigrationsAfter(0); |
@@ -261,4 +261,4 @@ namespace OpenSim.Data | |||
261 | return migrations; | 261 | return migrations; |
262 | } | 262 | } |
263 | } | 263 | } |
264 | } \ No newline at end of file | 264 | } |