mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: Remove required Close from database.Migrate (#25)
* fix: Remove required Close from database.Migrate * Remove dbName from Migrate function arguments * Fix func call
This commit is contained in:
+2
-9
@@ -16,7 +16,7 @@ import (
|
||||
var migrations embed.FS
|
||||
|
||||
// Migrate runs SQL migrations to ensure the database schema is up-to-date.
|
||||
func Migrate(ctx context.Context, dbName string, db *sql.DB) error {
|
||||
func Migrate(ctx context.Context, db *sql.DB) error {
|
||||
sourceDriver, err := iofs.New(migrations, "migrations")
|
||||
if err != nil {
|
||||
return xerrors.Errorf("create iofs: %w", err)
|
||||
@@ -25,7 +25,7 @@ func Migrate(ctx context.Context, dbName string, db *sql.DB) error {
|
||||
if err != nil {
|
||||
return xerrors.Errorf("wrap postgres connection: %w", err)
|
||||
}
|
||||
m, err := migrate.NewWithInstance("", sourceDriver, dbName, dbDriver)
|
||||
m, err := migrate.NewWithInstance("", sourceDriver, "", dbDriver)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("migrate: %w", err)
|
||||
}
|
||||
@@ -37,12 +37,5 @@ func Migrate(ctx context.Context, dbName string, db *sql.DB) error {
|
||||
}
|
||||
return xerrors.Errorf("up: %w", err)
|
||||
}
|
||||
srcErr, dbErr := m.Close()
|
||||
if srcErr != nil {
|
||||
return xerrors.Errorf("close source: %w", err)
|
||||
}
|
||||
if dbErr != nil {
|
||||
return xerrors.Errorf("close database: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user