Documentation
¶
Overview ¶
A very lightweigh migration tool to replace `ent.Schema.Create` calls.
Index ¶
- Constants
- Variables
- func AdoptLegacyEnt(ctx context.Context, db *sql.DB, connectionString string, logger *slog.Logger) error
- func NewLogger(log *slog.Logger) migrate.Logger
- type FS
- type Migrate
- func (m *Migrate) CloseOrLogError()
- func (m *Migrate) Down() error
- func (m *Migrate) Force(version uint) error
- func (m *Migrate) LatestVersion() (uint, error)
- func (m *Migrate) Migrate(version uint) error
- func (m *Migrate) Up() error
- func (m *Migrate) WaitForMigrationJob(waitOpts ...WaitForMigrationOption) error
- type MigrateOptions
- type MigrationsConfig
- type SourceWrapper
- type WaitForMigrationOption
Constants ¶
View Source
const IgnoreMarker = "-- migration:ignore"
View Source
const (
MigrationsTable = "schema_om"
)
Variables ¶
View Source
var ErrNoChange = migrate.ErrNoChange
View Source
var OMMigrationsConfig = MigrationsConfig{ FS: omMigrations, FSPath: "migrations", StateTableName: MigrationsTable, }
Functions ¶
func AdoptLegacyEnt ¶
func AdoptLegacyEnt(ctx context.Context, db *sql.DB, connectionString string, logger *slog.Logger) error
AdoptLegacyEnt brings an unversioned database created by Ent to the frozen migration baseline. It intentionally stops at the baseline so the normal migration command remains responsible for upgrading from that version to the target OpenMeter version.
Types ¶
type Migrate ¶
type Migrate struct {
// contains filtered or unexported fields
}
func (*Migrate) CloseOrLogError ¶
func (m *Migrate) CloseOrLogError()
func (*Migrate) Force ¶
Force records version as the current clean migration version without applying migrations. It is intended for adopting databases brought to a verified baseline outside the migration history.
func (*Migrate) LatestVersion ¶
func (*Migrate) WaitForMigrationJob ¶
func (m *Migrate) WaitForMigrationJob(waitOpts ...WaitForMigrationOption) error
type MigrateOptions ¶
type MigrateOptions struct {
ConnectionString string
Migrations MigrationsConfig
Logger *slog.Logger
}
func (*MigrateOptions) Validate ¶
func (m *MigrateOptions) Validate() error
type MigrationsConfig ¶
func (*MigrationsConfig) Validate ¶
func (m *MigrationsConfig) Validate() error
type SourceWrapper ¶
type SourceWrapper struct {
// contains filtered or unexported fields
}
func NewSourceWrapper ¶
func NewSourceWrapper(fsys fs.FS) *SourceWrapper
type WaitForMigrationOption ¶
type WaitForMigrationOption func(*waitForMigrationOptions)
Click to show internal directories.
Click to hide internal directories.