-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from MayconCardoso/feature/split-share
[Feature] Split Share
- Loading branch information
Showing
44 changed files
with
835 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
data/src/main/java/com/mctech/stocktradetracking/data/database/migration/Migrations.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.mctech.stocktradetracking.data.database.migration | ||
|
||
import androidx.room.RoomDatabase | ||
import androidx.room.migration.Migration | ||
import androidx.sqlite.db.SupportSQLiteDatabase | ||
|
||
object Migrations { | ||
val MIGRATION_1_2 = object : Migration(1, 2) { | ||
override fun migrate(database: SupportSQLiteDatabase) { | ||
database.execSQL("ALTER TABLE stock_share ADD COLUMN initialShareAmount INTEGER NOT NULL default 0") | ||
database.execSQL("ALTER TABLE stock_share ADD COLUMN initialPurchasePrice REAL NOT NULL default 0.0") | ||
database.execSQL("UPDATE stock_share set initialShareAmount = shareAmount") | ||
database.execSQL("UPDATE stock_share set initialPurchasePrice = purchasePrice") | ||
} | ||
} | ||
} | ||
|
||
fun <T : RoomDatabase> RoomDatabase.Builder<T>.bindMigrations(): RoomDatabase.Builder<T> { | ||
addMigrations( | ||
Migrations.MIGRATION_1_2 | ||
) | ||
return this | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.