-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #261 from cschleiden/migrations
Use golang-migrate for schema migrations for SQL backends
- Loading branch information
Showing
18 changed files
with
271 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Sqlite backend | ||
|
||
## Adding a migration | ||
|
||
1. Install [golang-migrate/migrate](https://www.github.com/golang-migrate/migrate) | ||
1. ```bash | ||
migrate create -ext sql -dir ./db/migrations -seq <name> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
DROP TABLE IF EXISTS `instances`; | ||
DROP TABLE IF EXISTS `pending_events`; | ||
DROP TABLE IF EXISTS `history`; | ||
DROP TABLE IF EXISTS `activities`; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package mysql | ||
|
||
import ( | ||
"github.com/cschleiden/go-workflows/backend" | ||
) | ||
|
||
type options struct { | ||
backend.Options | ||
|
||
// ApplyMigrations automatically applies database migrations on startup. | ||
ApplyMigrations bool | ||
} | ||
|
||
type option func(*options) | ||
|
||
// WithApplyMigrations automatically applies database migrations on startup. | ||
func WithApplyMigrations(applyMigrations bool) option { | ||
return func(o *options) { | ||
o.ApplyMigrations = applyMigrations | ||
} | ||
} | ||
|
||
// WithBackendOptions allows to pass generic backend options. | ||
func WithBackendOptions(opts ...backend.BackendOption) option { | ||
return func(o *options) { | ||
for _, opt := range opts { | ||
opt(&o.Options) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Sqlite backend | ||
|
||
## Adding a migration | ||
|
||
1. Install [golang-migrate/migrate](https://www.github.com/golang-migrate/migrate) | ||
1. ```bash | ||
migrate create -ext sql -dir ./db/migrations -seq <name> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
DROP TABLE IF EXISTS `instances`; | ||
DROP TABLE IF EXISTS `pending_events`; | ||
DROP TABLE IF EXISTS `history`; | ||
DROP TABLE IF EXISTS `activities`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package sqlite | ||
|
||
import ( | ||
"github.com/cschleiden/go-workflows/backend" | ||
) | ||
|
||
type options struct { | ||
backend.Options | ||
|
||
// ApplyMigrations automatically applies database migrations on startup. | ||
ApplyMigrations bool | ||
} | ||
|
||
type option func(*options) | ||
|
||
// WithApplyMigrations automatically applies database migrations on startup. | ||
func WithApplyMigrations(applyMigrations bool) option { | ||
return func(o *options) { | ||
o.ApplyMigrations = applyMigrations | ||
} | ||
} | ||
|
||
// WithBackendOptions allows to pass generic backend options. | ||
func WithBackendOptions(opts ...backend.BackendOption) option { | ||
return func(o *options) { | ||
for _, opt := range opts { | ||
opt(&o.Options) | ||
} | ||
} | ||
} |
Oops, something went wrong.