외래 키
Android SQLite 드라이버의 onOpen 콜백을 통해 외래 키 제약 조건(foreign key constraints)을 활성화할 수 있습니다.
kotlin
AndroidSqliteDriver(
schema = Database.Schema,
callback = object : AndroidSqliteDriver.Callback(Database.Schema) {
override fun onOpen(db: SupportSQLiteDatabase) {
db.setForeignKeyConstraintsEnabled(true)
}
}
)
드라이버의 속성(properties)에 설정을 전달하여 JVM SQLite 드라이버에서 외래 키 제약 조건(foreign key constraints)을 활성화할 수 있습니다.
```kotlin
JdbcSqliteDriver(
url = "...",
properties = Properties().apply { put("foreign_keys", "true") }
)
데이터베이스 설정에서 외래 키 제약 조건(foreign key constraints)을 활성화하여 Native SQLite 드라이버에 적용할 수 있습니다.
```kotlin
NativeSqliteDriver(
schema = Database.Schema,
onConfiguration = { config: DatabaseConfiguration ->
config.copy(
extendedConfig = DatabaseConfiguration.Extended(foreignKeyConstraints = true)
)
}
)