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

Function ParseMigration

migrate.go:418–435  ·  view source on GitHub ↗

Migration parsing

(id string, r io.ReadSeeker)

Source from the content-addressed store, hash-verified

416
417// Migration parsing
418func ParseMigration(id string, r io.ReadSeeker) (*Migration, error) {
419 m := &Migration{
420 Id: id,
421 }
422
423 parsed, err := sqlparse.ParseMigration(r)
424 if err != nil {
425 return nil, fmt.Errorf("Error parsing migration (%s): %w", id, err)
426 }
427
428 m.Up = parsed.UpStatements
429 m.Down = parsed.DownStatements
430
431 m.DisableTransactionUp = parsed.DisableTransactionUp
432 m.DisableTransactionDown = parsed.DisableTransactionDown
433
434 return m, nil
435}
436
437type SqlExecutor interface {
438 Exec(query string, args ...interface{}) (sql.Result, error)

Callers 3

migrationFromFileFunction · 0.70
FindMigrationsMethod · 0.70
FindMigrationsMethod · 0.70

Calls 1

ParseMigrationFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…