【发布时间】:2019-05-22 03:03:02
【问题描述】:
我需要为我现有的表添加一个新的列名id INTEGER AUTOINCREMENT 和一个用于当前数据库的新表。如何使用“升级”?是否需要更改版本号?
initDb() async {
io.Directory documentsDirectory = await getApplicationDocumentsDirectory();
String path = join(documentsDirectory.path, "HelperDatabase.db");
var theDb = await openDatabase(path, version: 1, onCreate: _onCreate, onUpgrade: _onUpgrade);
return theDb;
}
如何使用_onUpgrade
void _onUpgrade(Database db, int oldVersion, int newVersion)async{
}
也需要加列吗?
void _onCreate(Database db, int version) async {
await db.execute(
"""CREATE TABLE AssetAssemblyTable(e INTEGER, a INTEGER, c INTEGER)""");
【问题讨论】: