Documentation
¶
Overview ¶
Package migrations holds the versioned migrations of the index, one directory per dialect, and applies them on open. After a schema change, regenerate the ent client and run `go run ./gen -name <change>` from index/sql/migrations to append a migration to every dialect's directory.
Index ¶
- Constants
- func Apply(ctx context.Context, db *sql.DB, dialect string) error
- func ApplyDir(ctx context.Context, db *sql.DB, dialect string, dir migrate.Dir, ...) error
- func Diff(ctx context.Context, db *sql.DB, dialect string, dir migrate.Dir, name string) error
- func DiffWith(ctx context.Context, differ Differ, dir migrate.Dir, name string) error
- func Dir(dialect string) (*migrate.MemDir, error)
- func EntDialect(d string) string
- func ReadDir(fsys fs.FS, dialect string) (*migrate.MemDir, error)
- type Differ
Constants ¶
const ( SQLite = "sqlite" Postgres = "postgres" )
Dialects the index migrates.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply brings db to the newest migration of the dialect, recording what it applied in the atlas_schema_revisions table. A database that is up to date is left alone. Concurrent callers take turns: an SQLite migration is one write transaction, a Postgres one holds an advisory lock.
func ApplyDir ¶
func ApplyDir(ctx context.Context, db *sql.DB, dialect string, dir migrate.Dir, table, lock string) error
ApplyDir is Apply for a schema that ships its own migrations: dir is applied on top of whatever else the database holds, its history kept in the table named table and its Postgres runs serialised under lock.
func Diff ¶
Diff writes into dir the migration named name that takes the schema dir reproduces to the current ent schema, replaying dir on db, an empty scratch database of the dialect that is left empty again. It returns migrate.ErrNoPlan when dir is up to date.
func EntDialect ¶
EntDialect is the ent dialect of a migration dialect.
Types ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Command gen appends a migration to every dialect's directory when the ent schema changed.
|
Command gen appends a migration to every dialect's directory when the ent schema changed. |
|
Package generate writes the migration an ent schema change needs, for goback's own index and for anything built on goback that keeps its own schema the same way.
|
Package generate writes the migration an ent schema change needs, for goback's own index and for anything built on goback that keeps its own schema the same way. |