From c72002beb9eed8703dbed724e9e669cd3457e340 Mon Sep 17 00:00:00 2001 From: Ambarish Manna Date: Wed, 18 Feb 2026 19:33:09 +0530 Subject: [PATCH] feat(core-base/database): updated Room annotations --- .../template/core/base/database/Room.kt | 28 +++++++++++++++++++ .../core/base/database/Room.nonJsCommon.kt | 6 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/core-base/database/src/commonMain/kotlin/template/core/base/database/Room.kt b/core-base/database/src/commonMain/kotlin/template/core/base/database/Room.kt index a0a432b8..03da3a33 100644 --- a/core-base/database/src/commonMain/kotlin/template/core/base/database/Room.kt +++ b/core-base/database/src/commonMain/kotlin/template/core/base/database/Room.kt @@ -741,6 +741,12 @@ object ColumnInfoTypeAffinity { /** Store as BLOB (binary data) */ const val BLOB = 5 + + /** Indicates that the column name should be inherited from the field name */ + const val INHERIT_FIELD_NAME: String = "[field-name]" + + /** Indicates that no default value is specified for the column */ + const val VALUE_UNSPECIFIED: String = "[value-unspecified]" } /** @@ -767,3 +773,25 @@ object CollationSequence { /** Unicode-aware comparison */ const val UNICODE = 6 } + +/** + * Cross-platform constants for foreign key actions. + * + * These constants define the action to take when a referenced key is updated or deleted. + */ +object ForeignKeyAction { + /** Take no action when a referenced key changes */ + const val NO_ACTION = 1 + + /** Prevent the operation if it would violate the foreign key constraint */ + const val RESTRICT = 2 + + /** Set the foreign key column to NULL when the referenced key is deleted/updated */ + const val SET_NULL = 3 + + /** Set the foreign key column to its default value when the referenced key is deleted/updated */ + const val SET_DEFAULT = 4 + + /** Cascade the delete/update operation to the referencing rows */ + const val CASCADE = 5 +} diff --git a/core-base/database/src/nonJsCommonMain/kotlin/template/core/base/database/Room.nonJsCommon.kt b/core-base/database/src/nonJsCommonMain/kotlin/template/core/base/database/Room.nonJsCommon.kt index b54b0384..30a74ca0 100644 --- a/core-base/database/src/nonJsCommonMain/kotlin/template/core/base/database/Room.nonJsCommon.kt +++ b/core-base/database/src/nonJsCommonMain/kotlin/template/core/base/database/Room.nonJsCommon.kt @@ -29,6 +29,8 @@ import androidx.room.TypeConverter import androidx.room.TypeConverters import androidx.room.Update import androidx.room.Upsert +import androidx.room.BuiltInTypeConverters +import androidx.room.AutoMigration /** * Multiplatform typealiases for Room database annotations and interfaces. @@ -147,7 +149,7 @@ actual typealias TypeConverters = TypeConverters * Typealias for the Room `BuiltInTypeConverters` annotation. * Used to configure built-in type converters. */ -actual typealias BuiltInTypeConverters = androidx.room.BuiltInTypeConverters +actual typealias BuiltInTypeConverters = BuiltInTypeConverters /** * Typealias for the Room `@Database` annotation. @@ -159,7 +161,7 @@ actual typealias Database = Database * Typealias for the Room `@AutoMigration` annotation. * Used to define automatic migrations between database versions. */ -actual typealias AutoMigration = androidx.room.AutoMigration +actual typealias AutoMigration = AutoMigration /** * Typealias for the Room `@Ignore` annotation.