refactor(schema): Add support for migration editions

This refactors the schema package and subpackages to support editions.
An Edition is a collection of sql migrations. A given boundary binary
can have multiple migration editions. The `schema.Manager` is updated to
apply the necessary migrations in the correct order, leveraging an
Edition's priority to determine the order in which the separate Editions
are applied.

The sql migration files are now nested under a directory for the
edition.

This also switches from the generated code to using embed, which
eliminates the need for the `make migrations` target and the generated
code. As such this commit removes the target and generated code.

See:
    https://pkg.go.dev/embed
This commit is contained in:
Timothy Messier committed 2021-10-08 06:50:26 -04:00
1 parent 217adfc4d2
commit 8caaf3e076
144 files changed
+3469 -11098

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
// Package log provides internal structs and options for the schema package for
// tracking logs generated when applying migrations.
package log
+12
View File
@@ -0,0 +1,12 @@
package log
import "time"
// Entry represents a log entry generated during migrations.
type Entry struct {
Id int
MigrationEdition string
MigrationVersion int
CreateTime time.Time
Entry string
}
@@ -0,0 +1,29 @@
package log
// GetOpts - iterate the inbound Options and return a struct.
func GetOpts(opt ...Option) Options {
opts := getDefaultOptions()
for _, o := range opt {
o(&opts)
}
return opts
}
// Option - how Options are passed as arguments.
type Option func(*Options)
// Options = how options are represented
type Options struct {
WithDeleteLog bool
}
func getDefaultOptions() Options {
return Options{}
}
// WithDeleteLog provides an option to specify the deletion of log entries.
func WithDeleteLog(del bool) Option {
return func(o *Options) {
o.WithDeleteLog = del
}
}