initial commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user