OpenSource » Database Migrator » Legacy Migrator
Clone URL:  

Migrator * added a remove constraint method
* moved the add/remove constraint implementation down in to the providers

Changeset 4c749d0f0c2e

Parent ac7862d335c5

by gareth.farrington

Changes to 5 files · Browse files at 4c749d0f0c2e Showing diff from parent ac7862d335c5 Diff from another changeset...

 
292
293
294
 
 
 
 
 
 
 
 
 
 
295
296
 
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
@@ -292,5 +292,15 @@
    #endregion   + + public override void RemoveConstraint(string constraint, string table) + { + throw new NotImplementedException(); + } + + public override void AddUniqueConstraint(string constraint, string table, params string[] columns) + { + throw new NotImplementedException(); + }   }  }
 
282
283
284
 
 
 
 
 
 
 
 
 
 
285
286
 
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
@@ -282,5 +282,15 @@
    #endregion   + + public override void RemoveConstraint(string constraint, string table) + { + throw new NotImplementedException(); + } + + public override void AddUniqueConstraint(string constraint, string table, params string[] columns) + { + throw new NotImplementedException(); + }   }  }
 
566
567
568
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569
570
 
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
@@ -566,5 +566,19 @@
  }   }   #endregion + + public override void AddUniqueConstraint(string constraint, string table, params string[] columns) + { + if (ConstraintExists(constraint, table)) + throw new ArgumentException("Constraint [" + constraint + "] already exists.", "constraint"); + + ExecuteNonQuery("Alter Table {0} Add Constraint {1} Unique ({2})", table, constraint, string.Join(",", columns)); + } + + public override void RemoveConstraint(string constraint, string table) + { + if (ConstraintExists(constraint, table)) + ExecuteNonQuery("Alter Table {0} Drop Constraint {1}", table, constraint); + }   }  }
 
201
202
203
204
205
206
207
208
209
 
210
211
212
213
214
215
 
 
 
 
 
 
 
216
217
218
 
201
202
203
 
 
 
 
 
 
204
205
 
 
 
 
 
206
207
208
209
210
211
212
213
214
215
@@ -201,18 +201,15 @@
  /// <param name="constraint">Name of the Constraint</param>   /// <param name="table">Name of the table to add the constraint to</param>   /// <param name="columns">Columns to constrain to uniqueness</param> - public void AddUniqueConstraint(string constraint, string table, params string[] columns) - { - if (ConstraintExists(constraint, table)) - { - _logger.Warn("Constraint {0} exists and will be dropped first.", constraint); - throw new ArgumentException("Constraint [" + constraint + "] already exists.", "constraint"); + public abstract void AddUniqueConstraint(string constraint, string table, params string[] columns);   - - } // if (ConstraintExists) - ExecuteNonQuery("Alter Table {0} ADD CONSTRAINT {1} UNIQUE ({2})", table, constraint, string.Join(",", columns)); - - } // AddUniqueConstraint(constraint, table, columns) + /// <summary> + /// Removes an existing constraint from a table + /// </summary> + /// <param name="table">Name of the table</param> + /// <param name="constraint">Name of the Constraint</param> + public abstract void RemoveConstraint(string constraint, string table); +   #endregion     /// <summary>
 
157
158
159
160
 
161
162
163
164
165
 
166
167
168
169
170
 
171
172
173
174
175
 
176
177
178
179
180
 
 
 
 
 
 
 
 
 
 
 
181
182
183
 
157
158
159
 
160
161
162
163
164
 
165
166
167
168
169
 
170
171
172
173
174
 
175
176
177
178
179
 
180
181
182
183
184
185
186
187
188
189
190
191
192
193
@@ -157,27 +157,37 @@
    public override bool ConvertColumn<T, U>(string table, string column, string tempColumn, TransformationProvider.ConvertColumnDelegate<T, U> convertFunc)   { - throw new Exception("The method or operation is not implemented."); + throw new NotImplementedException();   }     public override bool ConvertColumn<T, U>(string table, string column, string tempColumn, TransformationProvider.ConvertColumnDelegate<T, U> convertFunc, int size)   { - throw new Exception("The method or operation is not implemented."); + throw new NotImplementedException();   }     public override bool ConvertColumn<T, U>(string table, string column, string tempColumn, TransformationProvider.ConvertColumnDelegate<T, U> convertFunc, int size, ColumnProperties property)   { - throw new Exception("The method or operation is not implemented."); + throw new NotImplementedException();   }     public override bool ConvertColumn<T, U>(string table, string column, string tempColumn, TransformationProvider.ConvertColumnDelegate<T, U> convertFunc, ColumnProperties property)   { - throw new Exception("The method or operation is not implemented."); + throw new NotImplementedException();   }     public override bool ConvertColumn<T, U>(string table, string column, string tempColumn, TransformationProvider.ConvertColumnDelegate<T, U> convertFunc, int size, object defaultValue, ColumnProperties property)   { - throw new Exception("The method or operation is not implemented."); + throw new NotImplementedException(); + } + + public override void AddUniqueConstraint(string table, string constraint, params string[] columns) + { + throw new NotImplementedException(); + } + + public override void RemoveConstraint(string table, string constraint) + { + throw new NotImplementedException();   }   }  }