Fix: Release primary key uniqueness

This commit is contained in:
machiav3lli
2024-10-15 02:20:38 +02:00
parent e29b9b2ce9
commit 905e491b3c
4 changed files with 1450 additions and 5 deletions

File diff suppressed because it is too large Load Diff

View File

@ -49,6 +49,7 @@ const val ROW_LICENSES = "licenses"
const val ROW_METADATA_ICON = "metadataIcon"
const val ROW_MINSDK_VERSION = "minSdkVersion"
const val ROW_PACKAGE_NAME = "packageName"
const val ROW_PLATFORMS = "platforms"
const val ROW_RELEASES = "releases"
const val ROW_REPOSITORY_ID = "repositoryId"
const val ROW_SCREENSHOTS = "screenshots"

View File

@ -79,7 +79,7 @@ import org.koin.dsl.module
Downloaded::class,
InstallTask::class,
],
version = 26,
version = 27,
exportSchema = true,
autoMigrations = [
AutoMigration(
@ -169,6 +169,10 @@ import org.koin.dsl.module
to = 26,
spec = DatabaseX.Companion.AutoMigration25to26::class
),
AutoMigration(
from = 26,
to = 27,
),
]
)
@TypeConverters(Converters::class)

View File

@ -6,6 +6,7 @@ import androidx.room.Entity
import androidx.room.Index
import com.machiav3lli.fdroid.ROW_MINSDK_VERSION
import com.machiav3lli.fdroid.ROW_PACKAGE_NAME
import com.machiav3lli.fdroid.ROW_PLATFORMS
import com.machiav3lli.fdroid.ROW_REPOSITORY_ID
import com.machiav3lli.fdroid.ROW_SIGNATURE
import com.machiav3lli.fdroid.ROW_TARGETSDK_VERSION
@ -16,13 +17,15 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
// TODO add repoID, use for queries
// TODO consider denormalizing by adding minSdkVersion and maxSdkVersion columns to Product
@Entity(
tableName = TABLE_RELEASE,
primaryKeys = [ROW_PACKAGE_NAME, ROW_REPOSITORY_ID, ROW_VERSION_CODE, ROW_SIGNATURE],
primaryKeys = [ROW_PACKAGE_NAME, ROW_REPOSITORY_ID, ROW_VERSION_CODE, ROW_SIGNATURE, ROW_PLATFORMS],
indices = [
Index(value = [ROW_PACKAGE_NAME, ROW_REPOSITORY_ID, ROW_VERSION_CODE, ROW_SIGNATURE], unique = true),
Index(
value = [ROW_PACKAGE_NAME, ROW_REPOSITORY_ID, ROW_VERSION_CODE, ROW_SIGNATURE, ROW_PLATFORMS],
unique = true
),
Index(value = [ROW_PACKAGE_NAME, ROW_MINSDK_VERSION, ROW_TARGETSDK_VERSION]),
Index(value = [ROW_PACKAGE_NAME]),
Index(value = [ROW_MINSDK_VERSION]),
@ -33,7 +36,7 @@ import kotlinx.serialization.json.Json
open class Release(
val packageName: String,
@ColumnInfo(defaultValue = "0")
val repositoryId : Long = 0L,
val repositoryId: Long = 0L,
val selected: Boolean,
val version: String,
val versionCode: Long,