From 68b00e94d98d8401fb69f35adcb8c9193df31636 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Sat, 4 Jan 2025 16:03:26 +0530 Subject: [PATCH] Minor code improvement --- .../messages/databases/MessagesDatabase.kt | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/messages/databases/MessagesDatabase.kt b/app/src/main/kotlin/org/fossify/messages/databases/MessagesDatabase.kt index bf843a9c..eb9a1d23 100644 --- a/app/src/main/kotlin/org/fossify/messages/databases/MessagesDatabase.kt +++ b/app/src/main/kotlin/org/fossify/messages/databases/MessagesDatabase.kt @@ -50,8 +50,8 @@ abstract class MessagesDatabase : RoomDatabase() { } private val MIGRATION_1_2 = object : Migration(1, 2) { - override fun migrate(database: SupportSQLiteDatabase) { - database.apply { + override fun migrate(db: SupportSQLiteDatabase) { + db.apply { execSQL("CREATE TABLE IF NOT EXISTS `messages` (`id` INTEGER PRIMARY KEY NOT NULL, `body` TEXT NOT NULL, `type` INTEGER NOT NULL, `participants` TEXT NOT NULL, `date` INTEGER NOT NULL, `read` INTEGER NOT NULL, `thread_id` INTEGER NOT NULL, `is_mms` INTEGER NOT NULL, `attachment` TEXT, `sender_name` TEXT NOT NULL, `sender_photo_uri` TEXT NOT NULL, `subscription_id` INTEGER NOT NULL)") execSQL("CREATE TABLE IF NOT EXISTS `message_attachments` (`id` INTEGER PRIMARY KEY NOT NULL, `text` TEXT NOT NULL, `attachments` TEXT NOT NULL)") @@ -63,8 +63,8 @@ abstract class MessagesDatabase : RoomDatabase() { } private val MIGRATION_2_3 = object : Migration(2, 3) { - override fun migrate(database: SupportSQLiteDatabase) { - database.apply { + override fun migrate(db: SupportSQLiteDatabase) { + db.apply { execSQL("CREATE TABLE conversations_new (`thread_id` INTEGER NOT NULL PRIMARY KEY, `snippet` TEXT NOT NULL, `date` INTEGER NOT NULL, `read` INTEGER NOT NULL, `title` TEXT NOT NULL, `photo_uri` TEXT NOT NULL, `is_group_conversation` INTEGER NOT NULL, `phone_number` TEXT NOT NULL)") execSQL( @@ -82,16 +82,16 @@ abstract class MessagesDatabase : RoomDatabase() { } private val MIGRATION_3_4 = object : Migration(3, 4) { - override fun migrate(database: SupportSQLiteDatabase) { - database.apply { + override fun migrate(db: SupportSQLiteDatabase) { + db.apply { execSQL("ALTER TABLE messages ADD COLUMN status INTEGER NOT NULL DEFAULT -1") } } } private val MIGRATION_4_5 = object : Migration(4, 5) { - override fun migrate(database: SupportSQLiteDatabase) { - database.apply { + override fun migrate(db: SupportSQLiteDatabase) { + db.apply { execSQL("ALTER TABLE messages ADD COLUMN is_scheduled INTEGER NOT NULL DEFAULT 0") execSQL("ALTER TABLE conversations ADD COLUMN is_scheduled INTEGER NOT NULL DEFAULT 0") } @@ -99,24 +99,24 @@ abstract class MessagesDatabase : RoomDatabase() { } private val MIGRATION_5_6 = object : Migration(5, 6) { - override fun migrate(database: SupportSQLiteDatabase) { - database.apply { + override fun migrate(db: SupportSQLiteDatabase) { + db.apply { execSQL("ALTER TABLE conversations ADD COLUMN uses_custom_title INTEGER NOT NULL DEFAULT 0") } } } private val MIGRATION_6_7 = object : Migration(6, 7) { - override fun migrate(database: SupportSQLiteDatabase) { - database.apply { + override fun migrate(db: SupportSQLiteDatabase) { + db.apply { execSQL("ALTER TABLE messages ADD COLUMN sender_phone_number TEXT NOT NULL DEFAULT ''") } } } private val MIGRATION_7_8 = object : Migration(7, 8) { - override fun migrate(database: SupportSQLiteDatabase) { - database.apply { + override fun migrate(db: SupportSQLiteDatabase) { + db.apply { execSQL("ALTER TABLE conversations ADD COLUMN archived INTEGER NOT NULL DEFAULT 0") execSQL("CREATE TABLE IF NOT EXISTS `recycle_bin_messages` (`id` INTEGER NOT NULL PRIMARY KEY, `deleted_ts` INTEGER NOT NULL)") execSQL("CREATE UNIQUE INDEX IF NOT EXISTS `index_recycle_bin_messages_id` ON `recycle_bin_messages` (`id`)")