我需要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)""");