Bump version to 1.0.59
This commit is contained in:
+20
-2
@@ -86,10 +86,28 @@ func (db *DB) runMigrationsInternal(mfs embedFS, migrationsRoot string) error {
|
||||
|
||||
for _, name := range names {
|
||||
if hasChecksumCol {
|
||||
var storedChecksum string
|
||||
var storedChecksum sql.NullString
|
||||
row := db.QueryRow("SELECT checksum FROM schema_migrations WHERE version = ?", name)
|
||||
if err := row.Scan(&storedChecksum); err == nil && storedChecksum != "" {
|
||||
switch err := row.Scan(&storedChecksum); {
|
||||
case err == nil:
|
||||
if storedChecksum.Valid && storedChecksum.String != "" {
|
||||
continue
|
||||
}
|
||||
data, err := mfs.ReadFile(filepath.Join(migrationsRoot, name))
|
||||
if err != nil {
|
||||
return fmt.Errorf("reading migration %s: %w", name, err)
|
||||
}
|
||||
checksum := sha256.Sum256(data)
|
||||
if _, err := db.Exec(
|
||||
"UPDATE schema_migrations SET checksum = ? WHERE version = ?",
|
||||
hex.EncodeToString(checksum[:]), name,
|
||||
); err != nil {
|
||||
return fmt.Errorf("backfilling checksum for %s: %w", name, err)
|
||||
}
|
||||
continue
|
||||
case err == sql.ErrNoRows:
|
||||
default:
|
||||
return fmt.Errorf("checking migration %s: %w", name, err)
|
||||
}
|
||||
} else {
|
||||
var count int
|
||||
|
||||
Reference in New Issue
Block a user