From 77865a143d61a12c7a714fc5c80bf054c34bb62c Mon Sep 17 00:00:00 2001 From: tzugen <67737443+tzugen@users.noreply.github.com> Date: Tue, 21 Jun 2022 10:07:03 +0200 Subject: [PATCH] Enable schema export (needed for AutoMigration generator) (#757) * Enable schema export (needed for AutoMigration generator) * Add Schema folder to GIT --- ultrasonic/build.gradle | 2 +- .../5.json | 124 +++++++++++++++ .../1.json | 146 ++++++++++++++++++ .../org/moire/ultrasonic/data/MetaDatabase.kt | 3 +- 4 files changed, 273 insertions(+), 2 deletions(-) create mode 100644 ultrasonic/schemas/org.moire.ultrasonic.data.AppDatabase/5.json create mode 100644 ultrasonic/schemas/org.moire.ultrasonic.data.MetaDatabase/1.json diff --git a/ultrasonic/build.gradle b/ultrasonic/build.gradle index 986ebf0e..ed161214 100644 --- a/ultrasonic/build.gradle +++ b/ultrasonic/build.gradle @@ -63,7 +63,7 @@ android { kapt { arguments { - arg("room.schemaLocation", "$buildDir/schemas".toString()) + arg("room.schemaLocation", "$rootDir/ultrasonic/schemas".toString()) } } lint { diff --git a/ultrasonic/schemas/org.moire.ultrasonic.data.AppDatabase/5.json b/ultrasonic/schemas/org.moire.ultrasonic.data.AppDatabase/5.json new file mode 100644 index 00000000..c360a3a7 --- /dev/null +++ b/ultrasonic/schemas/org.moire.ultrasonic.data.AppDatabase/5.json @@ -0,0 +1,124 @@ +{ + "formatVersion": 1, + "database": { + "version": 5, + "identityHash": "4cea788a99b9bc28500948b1cd92e537", + "entities": [ + { + "tableName": "ServerSetting", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `index` INTEGER NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `color` INTEGER, `userName` TEXT NOT NULL, `password` TEXT NOT NULL, `jukeboxByDefault` INTEGER NOT NULL, `allowSelfSignedCertificate` INTEGER NOT NULL, `ldapSupport` INTEGER NOT NULL, `musicFolderId` TEXT, `minimumApiVersion` TEXT, `chatSupport` INTEGER, `bookmarkSupport` INTEGER, `shareSupport` INTEGER, `podcastSupport` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "index", + "columnName": "index", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "userName", + "columnName": "userName", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "password", + "columnName": "password", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "jukeboxByDefault", + "columnName": "jukeboxByDefault", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "allowSelfSignedCertificate", + "columnName": "allowSelfSignedCertificate", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "ldapSupport", + "columnName": "ldapSupport", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "musicFolderId", + "columnName": "musicFolderId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "minimumApiVersion", + "columnName": "minimumApiVersion", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "chatSupport", + "columnName": "chatSupport", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "bookmarkSupport", + "columnName": "bookmarkSupport", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "shareSupport", + "columnName": "shareSupport", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "podcastSupport", + "columnName": "podcastSupport", + "affinity": "INTEGER", + "notNull": false + } + ], + "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, '4cea788a99b9bc28500948b1cd92e537')" + ] + } +} \ No newline at end of file diff --git a/ultrasonic/schemas/org.moire.ultrasonic.data.MetaDatabase/1.json b/ultrasonic/schemas/org.moire.ultrasonic.data.MetaDatabase/1.json new file mode 100644 index 00000000..7333d42e --- /dev/null +++ b/ultrasonic/schemas/org.moire.ultrasonic.data.MetaDatabase/1.json @@ -0,0 +1,146 @@ +{ + "formatVersion": 1, + "database": { + "version": 1, + "identityHash": "0580217b1e87b02d2edaf9b008891cbc", + "entities": [ + { + "tableName": "artists", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT, `index` TEXT, `coverArt` TEXT, `albumCount` INTEGER, `closeness` INTEGER NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "index", + "columnName": "index", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "coverArt", + "columnName": "coverArt", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "albumCount", + "columnName": "albumCount", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "closeness", + "columnName": "closeness", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "indexes", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT, `index` TEXT, `coverArt` TEXT, `albumCount` INTEGER, `closeness` INTEGER NOT NULL, `musicFolderId` TEXT, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "index", + "columnName": "index", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "coverArt", + "columnName": "coverArt", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "albumCount", + "columnName": "albumCount", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "closeness", + "columnName": "closeness", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "musicFolderId", + "columnName": "musicFolderId", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "music_folders", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": false + }, + "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, '0580217b1e87b02d2edaf9b008891cbc')" + ] + } +} \ No newline at end of file diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/MetaDatabase.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/MetaDatabase.kt index 638a591b..cb58ed96 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/MetaDatabase.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/MetaDatabase.kt @@ -12,7 +12,8 @@ import org.moire.ultrasonic.domain.MusicFolder @Database( entities = [Artist::class, Index::class, MusicFolder::class], - version = 1 + version = 1, + exportSchema = true ) abstract class MetaDatabase : RoomDatabase() { abstract fun artistsDao(): ArtistsDao