-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
116 changed files
with
800 additions
and
7,365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,20 @@ | |
import android.util.Log; | ||
|
||
import com.zlb.persistence.dbmaster.DaoMaster; | ||
|
||
import com.zlb.persistence.dbmaster.SysAlertMess2Dao; | ||
import com.zlb.persistence.dbmaster.SysAlertMessDao; | ||
|
||
/** | ||
* 数据库的升级策略,一般的只会增加一些字段和添加表,字段名 是很少修改的 | ||
* FBI WARMING,如果新加的字段是int ,boolean,目前你需要修改为Integer,Boolean | ||
* | ||
* 当某张表需要添加一个int类型的列时,升级数据库则会报NOT NULL约束不通过, | ||
* 原因是 GreenDao建表时Int 类型 加了NOT NULL。而再数据转移的时候并没有Insert 该列 | ||
* | ||
* INTEGER NOT NULL | ||
* | ||
* 数据库还是有很多问题 | ||
* | ||
* Created by [email protected] on 2017/1/3. | ||
* Created by zenglb on 2017/1/3. | ||
*/ | ||
public class MySQLiteOpenHelper extends DaoMaster.OpenHelper { | ||
|
||
|
@@ -20,24 +28,19 @@ public MySQLiteOpenHelper(Context context, String name, SQLiteDatabase.CursorFac | |
|
||
@Override | ||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | ||
//数据库 的管理最好能组件化 | ||
|
||
MigrationHelper.migrate(db, | ||
|
||
SysAlertMess2Dao.class, | ||
SysAlertMessDao.class | ||
); //升级 | ||
|
||
if (oldVersion == newVersion) { | ||
Log.d("onUpgrade", "数据库是最新版本" + oldVersion + ",不需要升级"); | ||
Log.d("onUpgrade", "数据库是最新版本:" + oldVersion + ", 不需要升级"); | ||
return; | ||
} | ||
|
||
Log.d("onUpgrade", "数据库从版本" + oldVersion + "升级到版本" + newVersion); | ||
switch (oldVersion) { | ||
case 1: | ||
|
||
break; | ||
case 2: | ||
Log.d("onUpgrade", "数据库从版本:" + oldVersion + " 升级到版本:" + newVersion); | ||
|
||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} |
Oops, something went wrong.