mirror of
https://github.com/status-im/status-go.git
synced 2025-01-10 14:47:06 +00:00
aa3d33a58f
Some functions split to be more cohesive, custom PostSteps are stored as pointers to allow their retrieval and parameters passing in runtime if needed (some extra work is dropped and TBD when needed)
38 lines
853 B
Go
38 lines
853 B
Go
package walletdatabase
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
"github.com/status-im/status-go/sqlite"
|
|
"github.com/status-im/status-go/walletdatabase/migrations"
|
|
)
|
|
|
|
type DbInitializer struct {
|
|
}
|
|
|
|
func (a DbInitializer) Initialize(path, password string, kdfIterationsNumber int) (*sql.DB, error) {
|
|
return InitializeDB(path, password, kdfIterationsNumber)
|
|
}
|
|
|
|
var walletCustomSteps = []*sqlite.PostStep{}
|
|
|
|
func doMigration(db *sql.DB) error {
|
|
// Run all the new migrations
|
|
return migrations.Migrate(db, walletCustomSteps)
|
|
}
|
|
|
|
// InitializeDB creates db file at a given path and applies migrations.
|
|
func InitializeDB(path, password string, kdfIterationsNumber int) (*sql.DB, error) {
|
|
db, err := sqlite.OpenDB(path, password, kdfIterationsNumber)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
err = doMigration(db)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return db, nil
|
|
}
|