forked from adlio/schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialect.go
23 lines (19 loc) · 1.02 KB
/
dialect.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package schema
import "context"
// Dialect defines the minimal interface for a database dialect. All dialects
// must implement functions to create the migrations table, get all applied
// migrations, insert a new migration tracking record, and perform escaping
// for the tracking table's name
type Dialect interface {
QuotedTableName(schemaName, tableName string) string
CreateMigrationsTable(ctx context.Context, tx Queryer, tableName string) error
GetAppliedMigrations(ctx context.Context, tx Queryer, tableName string) (applied []*AppliedMigration, err error)
InsertAppliedMigration(ctx context.Context, tx Queryer, tableName string, migration *AppliedMigration) error
}
// Locker defines an optional Dialect extension for obtaining and releasing
// a global database lock during the running of migrations. This feature is
// supported by PostgreSQL and MySQL, but not SQLite.
type Locker interface {
Lock(ctx context.Context, tx Queryer, tableName string) error
Unlock(ctx context.Context, tx Queryer, tableName string) error
}