Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

services:
postgres:
image: "postgres:11"
image: "postgres:12"
env:
POSTGRES_PASSWORD: morph
POSTGRES_DB: morph_test
Expand All @@ -31,7 +31,7 @@ jobs:
- 6432:5432

mysql:
image: "mysql:5.7"
image: "mysql:8"
env:
MYSQL_DATABASE: morph_test
MYSQL_USER: morph
Expand Down
1 change: 1 addition & 0 deletions cmd/morph/morph.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ func main() {
morph.ErrorLogger.Fprintf(os.Stderr, "An Error Occurred:\n")
}
_, _ = morph.ErrorLoggerLight.Fprintf(os.Stderr, "--> %v\n", err)
os.Exit(1)
}
}
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.1'
services:
postgres:
image: postgres
image: postgres:12
restart: always
ports:
- "6432:5432"
Expand All @@ -10,7 +10,7 @@ services:
POSTGRES_DB: morph_test
POSTGRES_USER: morph
mysql:
image: "mysql:5.7"
image: "mysql:8"
restart: always
ports:
- "3307:3306"
Expand Down
10 changes: 9 additions & 1 deletion drivers/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,27 @@ import (
)

type Config struct {
// MigrationsTableName is the name of the table that will store the migrations.
MigrationsTable string
// StatementTimeoutInSecs is used to set a timeout for each migration file.
// Set below zero to disable timeout. Zero value will result in default value, which is 60 seconds.
StatementTimeoutInSecs int
MigrationMaxSize int
// MigrationMaxSize is the maximum size of a migration file in bytes.
MigrationMaxSize int
}

// Driver is the interface that should be implemented by all drivers.
// The driver is responsible for applying migrations to the database.
type Driver interface {
Ping() error
// Close closes the underlying db connection. If the driver is created via Open() function
// this method will also going to call Close() on the sql.db instance.
Close() error
// Apply should apply the migration to the database. If saveVersion is true, the driver should
// save the migration version in the database.
Apply(migration *models.Migration, saveVersion bool) error
// AppliedMigrations should return a list of applied migrations.
// Ideally migrations should be sorted by version.
AppliedMigrations() ([]*models.Migration, error)
// SetConfig should be used to set the driver configuration. The key is the name of the configuration
// This method should return an error if the key is not supported.
Expand Down
9 changes: 1 addition & 8 deletions drivers/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func NextWaitInterval(lastWaitInterval time.Duration, err error) time.Duration {
}

type Locker interface {
// Lock locks m unless the context is canceled. If the mutex is already locked by any other
// Lock refreshes the lock unless the context is canceled. If the mutex is already locked by any other
// instance, including the current one, the calling goroutine blocks until the mutex can be locked,
// or the context is canceled.
//
Expand All @@ -75,10 +75,3 @@ type Locker interface {
type Lockable interface {
NewMutex(key string, logger Logger) (Locker, error)
}

// IsLockable returns whether the given instance satisfies
// drivers.Lockable or not.
func IsLockable(x interface{}) bool {
_, ok := x.(Lockable)
return ok
}
Loading