Created
November 14, 2022 07:51
-
-
Save gokmenbayram/3d3f4b19ffab6f4d690b9fa208f7bf50 to your computer and use it in GitHub Desktop.
Manual Migration
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
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