Documentation ¶
Index ¶
- Constants
- func BigIntToClampedInt64(val *big.Int) *int64
- func BigIntToPadded128BitsStr(val *big.Int) *string
- func ChangeEncryptionKey(path string, key string, kdfIterationsNumber int, newKey string, ...) error
- func DecryptDB(oldPath string, newPath string, key string, kdfIterationsNumber int) error
- func EncryptDB(unencryptedPath string, encryptedPath string, key string, ...) error
- func ExportDB(encryptedPath string, key string, kdfIterationsNumber int, newPath string, ...) error
- func GetLastMigrationVersion(db *sql.DB) (version uint, migrationTableExists bool, err error)
- func Int64ToPadded128BitsStr(val int64) *string
- func Migrate(db *sql.DB, resources *bindata.AssetSource, customSteps []PostStep, ...) error
- func MigrateV3ToV4(v3Path string, v4Path string, key string, kdfIterationsNumber int, ...) error
- func OpenDB(path string, key string, kdfIterationsNumber int) (*sql.DB, error)
- func OpenUnecryptedDB(path string) (*sql.DB, error)
- type JSONBlob
- type PostStep
Constants ¶
const ( // The reduced number of kdf iterations (for performance reasons) which is // used as the default value // https://github.com/status-im/status-go/pull/1343 // https://notes.status.im/i8Y_l7ccTiOYq09HVgoFwA ReducedKDFIterationsNumber = 3200 // WALMode for sqlite. WALMode = "wal" InMemoryPath = ":memory:" V4CipherPageSize = 8192 V3CipherPageSize = 1024 )
Variables ¶
This section is empty.
Functions ¶
func BigIntToClampedInt64 ¶ added in v0.157.2
func BigIntToPadded128BitsStr ¶ added in v0.157.2
BigIntToPadded128BitsStr converts a big.Int to a string, padding it with 0 to account for 128 bits size Returns nil if input val is nil This should work to sort and compare big.Ints values in SQLite
func ChangeEncryptionKey ¶ added in v0.80.2
func EncryptDB ¶ added in v0.69.0
func EncryptDB(unencryptedPath string, encryptedPath string, key string, kdfIterationsNumber int, onStart func(), onEnd func()) error
EncryptDB takes a plaintext database and adds encryption
func ExportDB ¶ added in v0.158.0
func ExportDB(encryptedPath string, key string, kdfIterationsNumber int, newPath string, newKey string, onStart func(), onEnd func()) error
Export takes an encrypted database and re-encrypts it in a new file, with a new key
func GetLastMigrationVersion ¶ added in v0.157.2
GetLastMigrationVersion returns the last migration version stored in the migration table. Returns 0 for version in case migrationTableExists is true
func Int64ToPadded128BitsStr ¶ added in v0.159.2
func Migrate ¶
func Migrate(db *sql.DB, resources *bindata.AssetSource, customSteps []PostStep, untilVersion *uint) error
Migrate database with option to augment the migration steps with additional processing using the customSteps parameter. For each PostStep entry in customSteps the CustomMigration will be called after the migration step with the matching Version number has been executed. If the CustomMigration returns an error, the migration process is aborted. In case the custom step failures the migrations are run down to RollBackVersion if > 0.
The recommended way to create a custom migration is by providing empty and versioned run/down sql files as markers. Then running all the SQL code inside the same transaction to transform and commit provides the possibility to completely rollback the migration in case of failure, avoiding to leave the DB in an inconsistent state.
Marker migrations can be created by using PostStep structs with specific Version numbers and a callback function, even when no accompanying SQL migration is needed. This can be used to trigger Go code at specific points during the migration process.
Caution: This mechanism should be used as a last resort. Prefer data migration using SQL migration files whenever possible to ensure consistency and compatibility with standard migration tools.
untilVersion, for testing purposes optional parameter, can be used to limit the migration to a specific version. Pass nil to migrate to the latest available version.
func MigrateV3ToV4 ¶ added in v0.158.0
func MigrateV3ToV4(v3Path string, v4Path string, key string, kdfIterationsNumber int, onStart func(), onEnd func()) error
MigrateV3ToV4 migrates database from v3 to v4 format with encryption.