migrate_fix.go 632 B

12345678910111213141516171819202122232425262728293031
  1. package main
  2. import (
  3. "os"
  4. _ "code.osinet.fr/fgm/kurz/migrations"
  5. "github.com/pressly/goose"
  6. "github.com/spf13/cobra"
  7. )
  8. var cmdMigrateFix = &cobra.Command{
  9. Args: cobra.NoArgs,
  10. Long: "Development command: renumber migrations from timestamps to sequential. Kurz version of 'goose fix'.",
  11. Run: migrateFixHandler,
  12. Short: "Fix migrations numbering",
  13. Use: "fix",
  14. }
  15. func init() {
  16. cmdMigrate.AddCommand(cmdMigrateFix)
  17. }
  18. // migrateFixHandler implements the "kurzd migrate fix" command.
  19. func migrateFixHandler(_ *cobra.Command, args []string) {
  20. cwd, err := os.Getwd()
  21. if err != nil {
  22. panic(err)
  23. }
  24. goose.Fix(cwd)
  25. }