1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

Implement structured logging using log/slog package

This commit is contained in:
Frédéric Guillot 2023-09-24 16:32:09 -07:00
parent 54cb8fa028
commit c0e954f19d
77 changed files with 1868 additions and 892 deletions

View file

@ -6,6 +6,7 @@ package database // import "miniflux.app/v2/internal/database"
import (
"database/sql"
"fmt"
"log/slog"
"time"
// Postgresql driver import
@ -31,12 +32,13 @@ func Migrate(db *sql.DB) error {
var currentVersion int
db.QueryRow(`SELECT version FROM schema_version`).Scan(&currentVersion)
fmt.Println("-> Current schema version:", currentVersion)
fmt.Println("-> Latest schema version:", schemaVersion)
slog.Debug("Running database migrations",
slog.Int("current_version", currentVersion),
slog.Int("latest_version", schemaVersion),
)
for version := currentVersion; version < schemaVersion; version++ {
newVersion := version + 1
fmt.Println("* Migrating to version:", newVersion)
tx, err := db.Begin()
if err != nil {