Files
2026-03-08 14:54:29 +03:00

24 lines
434 B
Go

package db
import (
"context"
"fmt"
"os"
"github.com/jackc/pgx/v5/pgxpool"
)
func RunMigrations(migrationFilePath string, pool *pgxpool.Pool) error {
sql, err := os.ReadFile(migrationFilePath)
if err != nil {
return fmt.Errorf("failed to execute migrations: %w", err)
}
_, err = pool.Exec(context.Background(), string(sql))
if err != nil {
return fmt.Errorf("failed to execute migrations: %w", err)
}
return nil
}