From a10c52795658c849b5d3c9d56fa3b2ca890bac57 Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Thu, 31 Jan 2019 22:24:21 -0500 Subject: [PATCH] Introducing an optional field called bts_value in the Transfer entity --- .../3.json | 12 +++++++++--- .../bitsybitshareswallet/database/BitsyDatabase.kt | 2 ++ .../database/entities/Transfer.kt | 5 +++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/schemas/cy.agorise.bitsybitshareswallet.database.BitsyDatabase/3.json b/app/schemas/cy.agorise.bitsybitshareswallet.database.BitsyDatabase/3.json index 3b68ce6..5da05ac 100644 --- a/app/schemas/cy.agorise.bitsybitshareswallet.database.BitsyDatabase/3.json +++ b/app/schemas/cy.agorise.bitsybitshareswallet.database.BitsyDatabase/3.json @@ -2,7 +2,7 @@ "formatVersion": 1, "database": { "version": 3, - "identityHash": "5b34bbcb2a3774fb9db64655b7217bbc", + "identityHash": "01c36f5fcfeb86c75594b083f9b82894", "entities": [ { "tableName": "assets", @@ -177,7 +177,7 @@ }, { "tableName": "transfers", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `block_number` INTEGER NOT NULL, `timestamp` INTEGER NOT NULL, `fee_amount` INTEGER NOT NULL, `fee_asset_id` TEXT NOT NULL, `source` TEXT NOT NULL, `destination` TEXT NOT NULL, `transfer_amount` INTEGER NOT NULL, `transfer_asset_id` TEXT NOT NULL, `memo` TEXT NOT NULL, PRIMARY KEY(`id`))", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `block_number` INTEGER NOT NULL, `timestamp` INTEGER NOT NULL, `fee_amount` INTEGER NOT NULL, `fee_asset_id` TEXT NOT NULL, `source` TEXT NOT NULL, `destination` TEXT NOT NULL, `transfer_amount` INTEGER NOT NULL, `transfer_asset_id` TEXT NOT NULL, `memo` TEXT NOT NULL, `bts_value` INTEGER, PRIMARY KEY(`id`))", "fields": [ { "fieldPath": "id", @@ -238,6 +238,12 @@ "columnName": "memo", "affinity": "TEXT", "notNull": true + }, + { + "fieldPath": "btsValue", + "columnName": "bts_value", + "affinity": "INTEGER", + "notNull": false } ], "primaryKey": { @@ -409,7 +415,7 @@ "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, \"5b34bbcb2a3774fb9db64655b7217bbc\")" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"01c36f5fcfeb86c75594b083f9b82894\")" ] } } \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/BitsyDatabase.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/BitsyDatabase.kt index af507c2..e62c07e 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/BitsyDatabase.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/BitsyDatabase.kt @@ -69,6 +69,8 @@ abstract class BitsyDatabase : RoomDatabase() { database.execSQL("DROP TABLE 'equivalent_values'") database.execSQL("CREATE TABLE IF NOT EXISTS 'equivalent_values' ('transfer_id' TEXT NOT NULL, 'value' INTEGER NOT NULL, 'symbol' TEXT NOT NULL, PRIMARY KEY(transfer_id, symbol), FOREIGN KEY (transfer_id) REFERENCES transfers(id))") + database.execSQL("ALTER TABLE transfers ADD bts_value INTEGER") + database.execSQL("DROP TABLE assets") database.execSQL("CREATE TABLE IF NOT EXISTS assets (`id` TEXT NOT NULL, `symbol` TEXT NOT NULL, `precision` INTEGER NOT NULL, `description` TEXT NOT NULL, `issuer` TEXT NOT NULL, PRIMARY KEY(`id`))") } diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/entities/Transfer.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/entities/Transfer.kt index f8caf61..cce1ae6 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/entities/Transfer.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/entities/Transfer.kt @@ -16,5 +16,6 @@ data class Transfer ( @ColumnInfo(name = "destination") val destination: String, // TODO should be foreign key to UserAccount @ColumnInfo(name = "transfer_amount") val transferAmount: Long, @ColumnInfo(name = "transfer_asset_id") val transferAssetId: String, // TODO should be foreign key to Asset - @ColumnInfo(name = "memo") val memo: String -) \ No newline at end of file + @ColumnInfo(name = "memo") val memo: String, + @ColumnInfo(name = "bts_value") val btsValue: Long? = -1 + ) \ No newline at end of file