shiori/internal/cmd/migrate.go
Felipe Martin Garcia 81d52a2e24
feat: sqlite migrations (#398)
- Moved migrations from code to SQL files
- Using golang-migrate/v4
- Added a new CLI command: migrate
2022-03-26 08:33:57 +01:00

21 lines
381 B
Go

package cmd
import (
"github.com/spf13/cobra"
)
func migrateCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "migrate",
Short: "Migrates the database to the latest version",
Run: migrateHandler,
}
return cmd
}
func migrateHandler(cmd *cobra.Command, args []string) {
if err := db.Migrate(); err != nil {
cError.Printf("Error during migration: %s", err)
}
}