Documentation
¶
Overview ¶
svc package integration for schema version control.
Index ¶
- func EnableSchemaMigrate(fs embed.FS, baseDir string, startVersion string, ...)
- func EnableSchemaMigrateOnProd(fs embed.FS, baseDir string, startVersion string, ...)
- func ExcludeSchemaFile(name string)
- func WithLocker(l Locker) func(*schemaMigrateOptions)
- func WithPrevErrIgnored() func(*schemaMigrateOptions)
- func WithRedisLocker() func(*schemaMigrateOptions)
- type LockContext
- type Locker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnableSchemaMigrate ¶
func EnableSchemaMigrate(fs embed.FS, baseDir string, startVersion string, ops ...func(*schemaMigrateOptions))
Enable auto schema migration.
Put all SQL scripts in a specific directory. Embed the directory as follows:
//go:embed schema/managed/*.sql var schemaFs embed.FS
SQL files should start with 'v' using a name that clearly indicates which version it belongs to, E.g., 'schema/managed/v0.0.1.sql'.
func EnableSchemaMigrateOnProd ¶
func EnableSchemaMigrateOnProd(fs embed.FS, baseDir string, startVersion string, ops ...func(*schemaMigrateOptions))
Enable auto schema migration only in production mode.
See EnableSchemaMigrate.
func ExcludeSchemaFile ¶
func ExcludeSchemaFile(name string)
func WithLocker ¶ added in v0.3.6
func WithLocker(l Locker) func(*schemaMigrateOptions)
Use custom Locker for schema migration.
func WithPrevErrIgnored ¶ added in v0.3.6
func WithPrevErrIgnored() func(*schemaMigrateOptions)
Ignore previous error if any.
func WithRedisLocker ¶ added in v0.3.6
func WithRedisLocker() func(*schemaMigrateOptions)
Use Redis as Locker for schema migration.
Types ¶
type LockContext ¶ added in v0.3.6
type Locker ¶ added in v0.3.6
type Locker interface {
Lock(lc LockContext) error
Unlock()
}
Click to show internal directories.
Click to hide internal directories.