Skip to content

Instantly share code, notes, and snippets.

@gokmenbayram
Created November 14, 2022 07:51
Show Gist options
  • Save gokmenbayram/3d3f4b19ffab6f4d690b9fa208f7bf50 to your computer and use it in GitHub Desktop.
Save gokmenbayram/3d3f4b19ffab6f4d690b9fa208f7bf50 to your computer and use it in GitHub Desktop.
Manual Migration
val MIGRATION_2_3 = object : Migration(2, 3) {
override fun migrate(database: SupportSQLiteDatabase) {
// Yeni tablo oluştur
database.execSQL("CREATE TABLE USER_NEW (userid TEXT, username TEXT, age INTEGER, PRIMARY KEY(userid))")
// Eski tablodan verileri kopyala
database.execSQL("INSERT INTO USER_NEW (userid, username, age) SELECT userid, username, age FROM USER")
// Eski tabloyu sil
database.execSQL("DROP TABLE USER")
// Yeni tablo adını değiştir
database.execSQL("ALTER TABLE USER_NEW RENAME TO User")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment