From ff010b2ef20fb57d6915f9dd59cd6ceca2b64b8c Mon Sep 17 00:00:00 2001 From: Gaurav Ujjwal Date: Mon, 24 May 2021 17:49:41 +0530 Subject: [PATCH] Enable database schema export via Room --- app/build.gradle | 6 + .../com.gaurav.avnc.model.db.MainDb/1.json | 160 ++++++++++++++++++ .../java/com/gaurav/avnc/model/db/MainDb.kt | 2 +- 3 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 app/roomSchema/com.gaurav.avnc.model.db.MainDb/1.json diff --git a/app/build.gradle b/app/build.gradle index 4466a9c..4629cd8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,6 +14,12 @@ android { versionCode 1 versionName "0.1.0" + javaCompileOptions { + annotationProcessorOptions { + arguments += ["room.schemaLocation": "$projectDir/roomSchema/".toString()] + } + } + externalNativeBuild { cmake { //We are not using STL diff --git a/app/roomSchema/com.gaurav.avnc.model.db.MainDb/1.json b/app/roomSchema/com.gaurav.avnc.model.db.MainDb/1.json new file mode 100644 index 0000000..4ec603d --- /dev/null +++ b/app/roomSchema/com.gaurav.avnc.model.db.MainDb/1.json @@ -0,0 +1,160 @@ +{ + "formatVersion": 1, + "database": { + "version": 1, + "identityHash": "d00ae8ded858b1d56d7565e660aac292", + "entities": [ + { + "tableName": "profiles", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`ID` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `host` TEXT NOT NULL, `port` INTEGER NOT NULL, `username` TEXT NOT NULL, `password` TEXT NOT NULL, `securityType` INTEGER NOT NULL, `channelType` INTEGER NOT NULL, `colorLevel` INTEGER NOT NULL, `imageQuality` INTEGER NOT NULL, `viewOnly` INTEGER NOT NULL, `useLocalCursor` INTEGER NOT NULL, `compatMode` INTEGER NOT NULL, `useRepeater` INTEGER NOT NULL, `idOnRepeater` INTEGER NOT NULL, `sshHost` TEXT NOT NULL, `sshPort` INTEGER NOT NULL, `sshUsername` TEXT NOT NULL, `sshAuthType` INTEGER NOT NULL, `sshPassword` TEXT NOT NULL, `sshPrivateKey` TEXT NOT NULL, `sshPrivateKeyPassword` TEXT NOT NULL)", + "fields": [ + { + "fieldPath": "ID", + "columnName": "ID", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "host", + "columnName": "host", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "port", + "columnName": "port", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "username", + "columnName": "username", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "password", + "columnName": "password", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "securityType", + "columnName": "securityType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "channelType", + "columnName": "channelType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "colorLevel", + "columnName": "colorLevel", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "imageQuality", + "columnName": "imageQuality", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "viewOnly", + "columnName": "viewOnly", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "useLocalCursor", + "columnName": "useLocalCursor", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "compatMode", + "columnName": "compatMode", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "useRepeater", + "columnName": "useRepeater", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "idOnRepeater", + "columnName": "idOnRepeater", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "sshHost", + "columnName": "sshHost", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "sshPort", + "columnName": "sshPort", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "sshUsername", + "columnName": "sshUsername", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "sshAuthType", + "columnName": "sshAuthType", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "sshPassword", + "columnName": "sshPassword", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "sshPrivateKey", + "columnName": "sshPrivateKey", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "sshPrivateKeyPassword", + "columnName": "sshPrivateKeyPassword", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "ID" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + } + ], + "views": [], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'd00ae8ded858b1d56d7565e660aac292')" + ] + } +} \ No newline at end of file diff --git a/app/src/main/java/com/gaurav/avnc/model/db/MainDb.kt b/app/src/main/java/com/gaurav/avnc/model/db/MainDb.kt index fe9acf9..d09a0f6 100644 --- a/app/src/main/java/com/gaurav/avnc/model/db/MainDb.kt +++ b/app/src/main/java/com/gaurav/avnc/model/db/MainDb.kt @@ -14,7 +14,7 @@ import androidx.room.Room import androidx.room.RoomDatabase import com.gaurav.avnc.model.ServerProfile -@Database(entities = [ServerProfile::class], version = 1, exportSchema = false) +@Database(entities = [ServerProfile::class], version = 1, exportSchema = true) abstract class MainDb : RoomDatabase() { abstract val serverProfileDao: ServerProfileDao