@@ -292,25 +292,24 @@ public void MoveIndexesFromOriginalTable(string origTable, string newTable)
292292 }
293293 }
294294
295- public override void RemoveColumn ( string table , string column )
295+ public override void RemoveColumn ( string tableName , string column )
296296 {
297- if ( ! TableExists ( table ) )
297+ if ( ! TableExists ( tableName ) )
298298 {
299299 throw new Exception ( "Table does not exist" ) ;
300300 }
301301
302- if ( ! ColumnExists ( table , column ) )
302+ if ( ! ColumnExists ( tableName , column ) )
303303 {
304304 throw new Exception ( "Column does not exist" ) ;
305305 }
306306
307- var newColumns = GetColumns ( table ) . Where ( x => x . Name != column ) . ToArray ( ) ;
307+ var sqliteInfo = GetSQLiteTableInfo ( tableName ) ;
308+
309+ sqliteInfo . ColumnMappings . RemoveAll ( x => x . OldName . Equals ( column , StringComparison . InvariantCultureIgnoreCase ) ) ;
310+ sqliteInfo . Columns . RemoveAll ( x => x . Name . Equals ( column , StringComparison . InvariantCultureIgnoreCase ) ) ;
308311
309- AddTable ( table + "_temp" , null , newColumns ) ;
310- var colNamesSql = string . Join ( ", " , newColumns . Select ( x => QuoteColumnNameIfRequired ( x . Name ) ) ) ;
311- ExecuteNonQuery ( string . Format ( "INSERT INTO {0}_temp SELECT {1} FROM {0}" , table , colNamesSql ) ) ;
312- RemoveTable ( table ) ;
313- ExecuteNonQuery ( string . Format ( "ALTER TABLE {0}_temp RENAME TO {0}" , table ) ) ;
312+ RecreateTable ( sqliteInfo ) ;
314313 }
315314
316315 public override void RenameColumn ( string tableName , string oldColumnName , string newColumnName )
0 commit comments