Эх сурвалжийг харах

no need migration, just drop not used column

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 7 сар өмнө
parent
commit
c5c7e9f305

+ 1 - 3
app/src/main/java/com/nextcloud/client/database/NextcloudDatabase.kt

@@ -30,7 +30,6 @@ import com.nextcloud.client.database.entity.UploadEntity
 import com.nextcloud.client.database.entity.VirtualEntity
 import com.nextcloud.client.database.migrations.DatabaseMigrationUtil
 import com.nextcloud.client.database.migrations.Migration67to68
-import com.nextcloud.client.database.migrations.Migration84to85
 import com.nextcloud.client.database.migrations.RoomMigration
 import com.nextcloud.client.database.migrations.addLegacyMigrations
 import com.nextcloud.client.database.typeConverter.OfflineOperationTypeConverter
@@ -69,7 +68,7 @@ import com.owncloud.android.db.ProviderMeta
         AutoMigration(from = 81, to = 82),
         AutoMigration(from = 82, to = 83),
         AutoMigration(from = 83, to = 84),
-        AutoMigration(from = 84, to = 85)
+        AutoMigration(from = 84, to = 85, spec = DatabaseMigrationUtil.DeleteColumnSpec::class)
     ],
     exportSchema = true
 )
@@ -102,7 +101,6 @@ abstract class NextcloudDatabase : RoomDatabase() {
                     .addLegacyMigrations(clock, context)
                     .addMigrations(RoomMigration())
                     .addMigrations(Migration67to68())
-                    .addMigrations(Migration84to85)
                     .fallbackToDestructiveMigration()
                     .build()
             }

+ 9 - 0
app/src/main/java/com/nextcloud/client/database/migrations/DatabaseMigrationUtil.kt

@@ -7,6 +7,7 @@
  */
 package com.nextcloud.client.database.migrations
 
+import androidx.room.DeleteColumn
 import androidx.room.migration.AutoMigrationSpec
 import androidx.sqlite.db.SupportSQLiteDatabase
 
@@ -90,4 +91,12 @@ object DatabaseMigrationUtil {
             super.onPostMigrate(db)
         }
     }
+
+    @DeleteColumn.Entries(
+        DeleteColumn(
+            tableName = "offline_operations",
+            columnName = "offline_operations_parent_path"
+        )
+    )
+    class DeleteColumnSpec : AutoMigrationSpec
 }

+ 0 - 47
app/src/main/java/com/nextcloud/client/database/migrations/Migration84to85.kt

@@ -1,47 +0,0 @@
-/*
- * Nextcloud - Android Client
- *
- * SPDX-FileCopyrightText: 2024 Alper Ozturk <alper.ozturk@nextcloud.com>
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-
-package com.nextcloud.client.database.migrations
-
-import androidx.room.migration.Migration
-import androidx.sqlite.db.SupportSQLiteDatabase
-import com.owncloud.android.db.ProviderMeta
-
-@Suppress("MagicNumber", "NestedBlockDepth")
-val Migration84to85 = object : Migration(84, 85) {
-    override fun migrate(db: SupportSQLiteDatabase) {
-        db.run {
-            execSQL(
-                """
-            CREATE TABLE IF NOT EXISTS `offline_operations_new` (
-                `_id` INTEGER PRIMARY KEY AUTOINCREMENT,
-                `offline_operations_parent_oc_file_id` INTEGER,
-                `offline_operations_path` TEXT,
-                `offline_operations_type` TEXT,
-                `offline_operations_file_name` TEXT,
-                `offline_operations_created_at` INTEGER
-            )
-        """
-            )
-
-            execSQL(
-                """
-            INSERT INTO offline_operations_new 
-            SELECT _id, offline_operations_parent_oc_file_id, offline_operations_path, 
-                   offline_operations_type, offline_operations_file_name, offline_operations_created_at 
-            FROM ${ProviderMeta.ProviderTableMeta.OFFLINE_OPERATION_TABLE_NAME}
-        """
-            )
-
-            execSQL("DROP TABLE ${ProviderMeta.ProviderTableMeta.OFFLINE_OPERATION_TABLE_NAME}")
-            execSQL(
-                "ALTER TABLE offline_operations_new RENAME TO " +
-                    ProviderMeta.ProviderTableMeta.OFFLINE_OPERATION_TABLE_NAME
-            )
-        }
-    }
-}