-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservicer.go
47 lines (37 loc) · 1.65 KB
/
servicer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package migrator
// DatabaseServicer represents a service that runs the migrations.
type DatabaseServicer interface {
// BeginTransaction creates a transaction in the implementing database
// servicer.
BeginTransaction() error
// CommitTransaction ends the created transaction providing there is one
// and commits it to the database.
CommitTransaction() error
// RanMigrations retrieves all previously ran migrations.
RanMigrations() ([]RanMigration, error)
// RemoveMigrationHistory removes the specified migration from the
// history table.
RemoveMigrationHistory(m Migration) error
// RollbackTransaction ends the created transaction providing there is one
// and rolls it back, ensuring there are no changes to the database made.
RollbackTransaction() error
// RollbackMigration rolls back the specified migration and removes it
// from the RanMigrations table.
RollbackMigration(m Migration) error
// RunMigration runs the specified migration against the current database.
RunMigration(m Migration) error
// TryCreateHistoryTable creates the migration history table if it does
// not already exist. The boolean return value indicates whether or not
// the table had to be created.
TryCreateHistoryTable() (bool, error)
// WriteMigrationHistory writes that a migration has been ran into the
// migration history table.
WriteMigrationHistory(m Migration) error
}
// LogServicer abstracts common logging functions so we do not have to
// call the log.Logger implementation directly.
type LogServicer interface {
// Printf formats a string with a set of parameters before printing it to
// the output.
Printf(format string, v ...interface{})
}