Introducing an optional field called bts_value in the Transfer entity

This commit is contained in:
Nelson R. Perez 2019-01-31 22:24:21 -05:00
parent 032c627725
commit a10c527956
3 changed files with 14 additions and 5 deletions

View file

@ -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\")"
]
}
}

View file

@ -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`))")
}

View file

@ -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
)
@ColumnInfo(name = "memo") val memo: String,
@ColumnInfo(name = "bts_value") val btsValue: Long? = -1
)