execSQLDB executes SQL on a DB, either as a single exec or split by statements
(ctx context.Context, db *sql.DB, query string)
| 62 | |
| 63 | // execSQLDB executes SQL on a DB, either as a single exec or split by statements |
| 64 | func (s SQLMigration) execSQLDB(ctx context.Context, db *sql.DB, query string) error { |
| 65 | if !s.splitStatements { |
| 66 | _, err := db.ExecContext(ctx, query) |
| 67 | return err |
| 68 | } |
| 69 | |
| 70 | statements := splitSQLStatementsWithAnnotations(query) |
| 71 | for _, stmt := range statements { |
| 72 | if _, err := db.ExecContext(ctx, stmt); err != nil { |
| 73 | return err |
| 74 | } |
| 75 | } |
| 76 | return nil |
| 77 | } |
| 78 | |
| 79 | func (s SQLMigration) Name() string { |
| 80 | return s.name |
no test coverage detected