(ctx context.Context, db *sql.DB)
| 507 | } |
| 508 | |
| 509 | func resetSchema(ctx context.Context, db *sql.DB) error { |
| 510 | tx, err := db.BeginTx(ctx, nil) |
| 511 | if err != nil { |
| 512 | return xerrors.Errorf("begin: %w", err) |
| 513 | } |
| 514 | defer func() { _ = tx.Rollback() }() |
| 515 | |
| 516 | for _, stmt := range []string{ |
| 517 | `DROP SCHEMA IF EXISTS _develop CASCADE`, |
| 518 | `DROP SCHEMA IF EXISTS public CASCADE`, |
| 519 | `CREATE SCHEMA IF NOT EXISTS public`, |
| 520 | `GRANT ALL ON SCHEMA public TO public`, |
| 521 | } { |
| 522 | if _, err := tx.ExecContext(ctx, stmt); err != nil { |
| 523 | return xerrors.Errorf("exec %q: %w", stmt, err) |
| 524 | } |
| 525 | } |
| 526 | return tx.Commit() |
| 527 | } |
| 528 | |
| 529 | func connectDB(ctx context.Context, pgURL string) (*sql.DB, error) { |
| 530 | db, err := sql.Open("postgres", pgURL) |
no test coverage detected