-
Notifications
You must be signed in to change notification settings - Fork 82
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 #125 from VictorKabata/room-db-migration
Room DB migration
- Loading branch information
Showing
134 changed files
with
911 additions
and
573 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,5 @@ appiOS/Pods/ | |
appiOS/Podfile.lock | ||
*.podspec | ||
*.xcuserstate | ||
|
||
notflix.preferences_pb |
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
112 changes: 112 additions & 0 deletions
112
composeApp/schemas/com.vickbt.composeApp.data.cache.AppDatabase/1.json
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,112 @@ | ||
{ | ||
"formatVersion": 1, | ||
"database": { | ||
"version": 1, | ||
"identityHash": "b735d958b317149fd8c12c6ffeccf7a6", | ||
"entities": [ | ||
{ | ||
"tableName": "Favorite Movies", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `imdbId` TEXT, `backdropPath` TEXT NOT NULL, `posterPath` TEXT NOT NULL, `originalLanguage` TEXT, `originalTitle` TEXT NOT NULL, `overview` TEXT NOT NULL, `popularity` REAL, `releaseDate` TEXT, `runtime` INTEGER, `status` TEXT, `tagLine` TEXT, `title` TEXT NOT NULL, `voteAverage` REAL, `voteCount` INTEGER, `createdAt` TEXT NOT NULL, PRIMARY KEY(`id`))", | ||
"fields": [ | ||
{ | ||
"fieldPath": "id", | ||
"columnName": "id", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "imdbId", | ||
"columnName": "imdbId", | ||
"affinity": "TEXT" | ||
}, | ||
{ | ||
"fieldPath": "backdropPath", | ||
"columnName": "backdropPath", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "posterPath", | ||
"columnName": "posterPath", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "originalLanguage", | ||
"columnName": "originalLanguage", | ||
"affinity": "TEXT" | ||
}, | ||
{ | ||
"fieldPath": "originalTitle", | ||
"columnName": "originalTitle", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "overview", | ||
"columnName": "overview", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "popularity", | ||
"columnName": "popularity", | ||
"affinity": "REAL" | ||
}, | ||
{ | ||
"fieldPath": "releaseDate", | ||
"columnName": "releaseDate", | ||
"affinity": "TEXT" | ||
}, | ||
{ | ||
"fieldPath": "runtime", | ||
"columnName": "runtime", | ||
"affinity": "INTEGER" | ||
}, | ||
{ | ||
"fieldPath": "status", | ||
"columnName": "status", | ||
"affinity": "TEXT" | ||
}, | ||
{ | ||
"fieldPath": "tagLine", | ||
"columnName": "tagLine", | ||
"affinity": "TEXT" | ||
}, | ||
{ | ||
"fieldPath": "title", | ||
"columnName": "title", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "voteAverage", | ||
"columnName": "voteAverage", | ||
"affinity": "REAL" | ||
}, | ||
{ | ||
"fieldPath": "voteCount", | ||
"columnName": "voteCount", | ||
"affinity": "INTEGER" | ||
}, | ||
{ | ||
"fieldPath": "createdAt", | ||
"columnName": "createdAt", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": false, | ||
"columnNames": [ | ||
"id" | ||
] | ||
} | ||
} | ||
], | ||
"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, 'b735d958b317149fd8c12c6ffeccf7a6')" | ||
] | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
composeApp/src/androidMain/kotlin/com/vickbt/composeApp/di/Module.android.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,12 @@ | ||
package com.vickbt.composeApp.di | ||
|
||
import com.vickbt.composeApp.utils.DatabaseFactory | ||
import com.vickbt.composeApp.utils.DatastoreFactory | ||
import org.koin.core.module.Module | ||
import org.koin.dsl.module | ||
|
||
actual fun platformModule(): Module = module { | ||
single { DatastoreFactory(context = get()).createDatastore() } | ||
|
||
single { DatabaseFactory(context = get()).createDatabase() } | ||
} |
4 changes: 2 additions & 2 deletions
4
...vickbt/shared/ui/activity/MainActivity.kt → ...bt/composeApp/ui/activity/MainActivity.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
2 changes: 1 addition & 1 deletion
2
...n/com/vickbt/shared/utils/ContextUtils.kt → ...m/vickbt/composeApp/utils/ContextUtils.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.vickbt.shared.utils | ||
package com.vickbt.composeApp.utils | ||
|
||
import android.content.Context | ||
|
||
|
20 changes: 20 additions & 0 deletions
20
composeApp/src/androidMain/kotlin/com/vickbt/composeApp/utils/DatabaseFactory.android.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,20 @@ | ||
package com.vickbt.composeApp.utils | ||
|
||
import android.content.Context | ||
import androidx.room.Room | ||
import androidx.sqlite.driver.bundled.BundledSQLiteDriver | ||
import com.vickbt.composeApp.data.cache.AppDatabase | ||
import kotlinx.coroutines.Dispatchers | ||
|
||
actual class DatabaseFactory(private val context: Context) { | ||
actual fun createDatabase(): AppDatabase { | ||
val appContext = context.applicationContext | ||
|
||
val dbFile = appContext.getDatabasePath("notflix.db") | ||
return Room.databaseBuilder<AppDatabase>( | ||
context = appContext, | ||
name = dbFile.absolutePath | ||
).setQueryCoroutineContext(Dispatchers.IO).fallbackToDestructiveMigration(true) | ||
.setDriver(BundledSQLiteDriver()).build() | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
.../shared/utils/DatastoreFactory.android.kt → ...poseApp/utils/DatastoreFactory.android.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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
package com.vickbt.shared.utils | ||
package com.vickbt.composeApp.utils | ||
|
||
import android.content.Context | ||
import androidx.datastore.core.DataStore | ||
import androidx.datastore.preferences.core.Preferences | ||
import com.vickbt.shared.domain.utils.Constants | ||
import com.vickbt.composeApp.domain.utils.Constants | ||
|
||
actual class DatastoreFactory(private val context: Context) { | ||
actual fun createDatastore(): DataStore<Preferences> { | ||
return initDataStore { | ||
context.filesDir.resolve(Constants.dataStoreFileName).absolutePath | ||
context.filesDir.resolve(Constants.DATASTORE_FILE_NAME).absolutePath | ||
} | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
composeApp/src/androidMain/kotlin/com/vickbt/shared/di/Module.kt
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
composeApp/src/androidMain/kotlin/com/vickbt/shared/utils/DatabaseDriverFactory.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.