Skip to content

Commit

Permalink
Handle the situation for removing redundant columns and add index whe…
Browse files Browse the repository at this point in the history
…n migrating.
  • Loading branch information
zcc1234567 committed Jul 29, 2020
1 parent 511a748 commit 347c4e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,13 @@ private List<String> getRemoveColumnSQLs(Collection<String> removeColumnNames, S
LitePalLog.d(TAG, "generateRemoveColumnSQL >> " + dataMigrationSQL);
String dropTempTableSQL = generateDropTempTableSQL(tableName);
LitePalLog.d(TAG, "generateRemoveColumnSQL >> " + dropTempTableSQL);
List<String> createIndexSQLs = generateCreateIndexSQLs(tableModelFromDB);
List<String> sqls = new ArrayList<>();
sqls.add(alterToTempTableSQL);
sqls.add(createNewTableSQL);
sqls.add(dataMigrationSQL);
sqls.add(dropTempTableSQL);
sqls.addAll(createIndexSQLs);
return sqls;
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/litepal/tablemanager/Upgrader.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,14 @@ private List<String> getChangeColumnsConstraintsSQL() {
List<String> addForeignKeySQLs = generateAddForeignKeySQL();
String dataMigrationSQL = generateDataMigrationSQL(mTableModelDB);
String dropTempTableSQL = generateDropTempTableSQL(mTableModel.getTableName());
List<String> createIndexSQL = generateCreateIndexSQLs(mTableModel);
List<String> createIndexSQLs = generateCreateIndexSQLs(mTableModel);
List<String> sqls = new ArrayList<>();
sqls.add(alterToTempTableSQL);
sqls.add(createNewTableSQL);
sqls.addAll(addForeignKeySQLs);
sqls.add(dataMigrationSQL);
sqls.add(dropTempTableSQL);
sqls.addAll(createIndexSQL);
sqls.addAll(createIndexSQLs);
LitePalLog.d(TAG, "generateChangeConstraintSQL >> ");
for (String sql : sqls) {
LitePalLog.d(TAG, sql);
Expand Down

0 comments on commit 347c4e0

Please sign in to comment.