MCPcopy
hub / github.com/rubenv/sql-migrate / SkipMigrations

Function SkipMigrations

sql-migrate/command_skip.go:54–85  ·  view source on GitHub ↗
(dir migrate.MigrationDirection, limit int)

Source from the content-addressed store, hash-verified

52}
53
54func SkipMigrations(dir migrate.MigrationDirection, limit int) error {
55 env, err := GetEnvironment()
56 if err != nil {
57 return fmt.Errorf("Could not parse config: %w", err)
58 }
59
60 db, dialect, err := GetConnection(env)
61 if err != nil {
62 return err
63 }
64 defer db.Close()
65
66 source := migrate.FileMigrationSource{
67 Dir: env.Dir,
68 }
69
70 n, err := migrate.SkipMax(db, dialect, source, dir, limit)
71 if err != nil {
72 return fmt.Errorf("Migration failed: %w", err)
73 }
74
75 switch n {
76 case 0:
77 ui.Output("All migrations have already been applied")
78 case 1:
79 ui.Output("Skipped 1 migration")
80 default:
81 ui.Output(fmt.Sprintf("Skipped %d migrations", n))
82 }
83
84 return nil
85}

Callers 1

RunMethod · 0.85

Calls 2

GetEnvironmentFunction · 0.85
GetConnectionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…