First pass implementation of an SQLite backing store for fetched opportunities
This commit is contained in:
1 parent
9b0e6dccfe
commit
045492a148
29 files changed
+3132
-9
No files matched your search
@@ -0,0 +1,42 @@
|
||||
// Package migrate provides the "migrate" command and its subcommands, which
|
||||
// apply, roll back and report the store's migrations (goose, embedded in the
|
||||
// store package) on the configured SQLite database.
|
||||
//
|
||||
// goose runs each migration in its own transaction, so a failed migration is
|
||||
// rolled back and leaves the database at the previous version.
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"git.avsdev.uk/Go/job-search/internal/cli"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// NewCommand returns the "migrate" command, which migrates the database schema (see
|
||||
// internal/store).
|
||||
func NewCommand(opts *cli.Options) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "migrate",
|
||||
Short: "Migrate SQLite database to latest version",
|
||||
Long: `Migrate the SQLite database to the latest version.
|
||||
|
||||
Running without a subcommand is the same as running "migrate up": every pending
|
||||
migration is applied.`,
|
||||
Args: cobra.NoArgs,
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
slog.Debug("migrate.PersistentPreRun")
|
||||
},
|
||||
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
||||
slog.Debug("migrate.PersistentPostRun")
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
slog.Debug("migrate.Run")
|
||||
return runStepUp(cmd, opts, 0, false)
|
||||
},
|
||||
}
|
||||
cmd.AddCommand(commandUp(opts))
|
||||
cmd.AddCommand(commandDown(opts))
|
||||
cmd.AddCommand(commandStatus(opts))
|
||||
return cmd
|
||||
}
|
||||
Reference in new issue
Block a user