在我的旧sqlite表中,我有这些列(id INTEGER PRIMARY KEY AUTOINCREMENT,api_response_json TEXT,api_req TEXT,post_params TEXT,req_type VARCHAR,timestamp TIMESTAMP)
现在我正在尝试将它迁移到Room DB,如下所示: -
static final Migration MIGRATION_1_2 = new migration(1,2){
@Override
public void migrate(SupportSQLiteDatabase database) {
// Create the new table
database.execSQL(
"CREATE TABLE users_new (id INTEGER PRIMARY KEY AUTOINCREMENT,api_response_json TEXT, api_req TEXT,post_params TEXT,req_type VARCHAR,timestamp TIMESTAMP)");
// Copy the data
database.execSQL("INSERT INTO users_new (id,api_response_json, api_req,post_params,req_type,timestamp) "
+ "SELECT id,api_response_json, api_req,post_params, req_type,timestamp "
+ "FROM old_Table_name");
// Remove the old table
database.execSQL("DROP TABLE old_Table_name");
// Change the table name to the …Run Code Online (Sandbox Code Playgroud)