Copy the core payments/db code into payments/db/migration1 and add the required sqlc-generated types/queries from sqldb/sqlc. This effectively freezes the migration code so it stays robust against future query or schema changes in the main payments package. Replace the delegation to channeldb.ReadElement/WriteElement with self-contained, frozen implementations that only handle the exact types required by this migration package. This removes the dependency on the live channeldb codec so that future changes to channeldb serialization cannot silently corrupt or break the migration. UnknownElementType is also defined locally for the same reason.
27 lines
667 B
Go
27 lines
667 B
Go
package migration1
|
|
|
|
// StoreOptions holds parameters for the KVStore.
|
|
type StoreOptions struct {
|
|
// NoMigration allows to open the database in readonly mode
|
|
NoMigration bool
|
|
}
|
|
|
|
// DefaultOptions returns a StoreOptions populated with default values.
|
|
func DefaultOptions() *StoreOptions {
|
|
return &StoreOptions{
|
|
NoMigration: false,
|
|
}
|
|
}
|
|
|
|
// OptionModifier is a function signature for modifying the default
|
|
// StoreOptions.
|
|
type OptionModifier func(*StoreOptions)
|
|
|
|
// WithNoMigration allows the database to be opened in read only mode by
|
|
// disabling migrations.
|
|
func WithNoMigration(b bool) OptionModifier {
|
|
return func(o *StoreOptions) {
|
|
o.NoMigration = b
|
|
}
|
|
}
|