Documentation
¶
Index ¶
- Constants
- Variables
- func Dir(u string, create bool) (migrate.Dir, error)
- func DirURL(u *url.URL, create bool) (migrate.Dir, error)
- func Formatter(u *url.URL) (migrate.Formatter, error)
- type EntRevisions
- func (r *EntRevisions) CurrentRevision(ctx context.Context) (*migrate.Revision, error)
- func (r *EntRevisions) DeleteRevision(ctx context.Context, v string) error
- func (r *EntRevisions) ID(ctx context.Context, operatorV string) (string, error)
- func (r *EntRevisions) Ident() *migrate.TableIdent
- func (r *EntRevisions) Migrate(ctx context.Context) (err error)
- func (r *EntRevisions) ReadRevision(ctx context.Context, v string) (*migrate.Revision, error)
- func (r *EntRevisions) ReadRevisions(ctx context.Context) ([]*migrate.Revision, error)
- func (r *EntRevisions) WriteRevision(ctx context.Context, rev *migrate.Revision) error
- type Option
- type RevisionReadWriter
- type StatusReporter
Constants ¶
const ( FormatAtlas = "atlas" FormatGolangMigrate = "golang-migrate" FormatGoose = "goose" FormatFlyway = "flyway" FormatLiquibase = "liquibase" FormatDBMate = "dbmate" )
List of supported formats.
Variables ¶
var Formats = []string{FormatAtlas, FormatGolangMigrate, FormatGoose, FormatFlyway, FormatLiquibase, FormatDBMate}
Formats is the list of supported formats.
Functions ¶
Types ¶
type EntRevisions ¶
type EntRevisions struct {
// contains filtered or unexported fields
}
EntRevisions provides implementation for the migrate.RevisionReadWriter interface.
func NewEntRevisions ¶
func NewEntRevisions(ctx context.Context, ac *sqlclient.Client, opts ...Option) (*EntRevisions, error)
NewEntRevisions creates a new EntRevisions with the given sqlclient.Client.
func (*EntRevisions) CurrentRevision ¶ added in v0.9.1
CurrentRevision returns the current (latest) revision in the revisions table.
func (*EntRevisions) DeleteRevision ¶ added in v0.7.1
func (r *EntRevisions) DeleteRevision(ctx context.Context, v string) error
DeleteRevision deletes a revision from the revisions table.
func (*EntRevisions) ID ¶ added in v0.11.0
ID returns the identifier of the connected revisions table.
func (*EntRevisions) Ident ¶ added in v0.6.0
func (r *EntRevisions) Ident() *migrate.TableIdent
Ident returns the table identifier.
func (*EntRevisions) Migrate ¶ added in v0.6.4
func (r *EntRevisions) Migrate(ctx context.Context) (err error)
Migrate attempts to create / update the revisions table. This is separated since Ent attempts to wrap the migration execution in a transaction and assumes the underlying connection is of type *sql.DB, which is not true for actually reading and writing revisions.
func (*EntRevisions) ReadRevision ¶ added in v0.6.0
ReadRevision reads a revision from the revisions table.
ReadRevision will not return results only saved in cache.
func (*EntRevisions) ReadRevisions ¶
ReadRevisions reads the revisions from the revisions table.
ReadRevisions will not return results only saved to cache.
func (*EntRevisions) WriteRevision ¶
WriteRevision writes a revision to the revisions table.
type Option ¶
type Option func(*EntRevisions) error
Option allows to configure EntRevisions by using functional arguments.
func WithSchema ¶
WithSchema configures the schema to use for the revision table.
type RevisionReadWriter ¶ added in v0.13.0
type RevisionReadWriter interface { migrate.RevisionReadWriter // CurrentRevision returns the current revision in the revisions table. CurrentRevision(context.Context) (*migrate.Revision, error) // Migrate applies the migration of the revisions table. Migrate(context.Context) error // ID returns the current target identifier. ID(context.Context, string) (string, error) }
RevisionReadWriter is a revision read-writer with migration capabilities.
func RevisionsForClient ¶ added in v0.13.0
func RevisionsForClient(ctx context.Context, ac *sqlclient.Client, schema string) (RevisionReadWriter, error)
RevisionsForClient creates a new RevisionReadWriter for the given sqlclient.Client.
type StatusReporter ¶ added in v0.8.0
type StatusReporter struct { // Client configures the connection to the database to file a MigrateStatus for. Client *sqlclient.Client // Dir is used for scanning and validating the migration directory. Dir migrate.Dir // Schema name the revision table resides in. Schema string }
StatusReporter is used to gather information about migration status.
func (*StatusReporter) Report ¶ added in v0.8.0
func (r *StatusReporter) Report(ctx context.Context) (*cmdlog.MigrateStatus, error)
Report creates and writes a MigrateStatus.