mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Fix various migration issues (#5723)
* Indicate while backing up database * Close migrate connection to db before optimising * Don't vacuum post-migration In most cases is probably not needed and can be an optonal user-initiated step * Ensure connection close on NewMigrator error * Perform post-migration using migrator connection Flush WAL file at end of migration
This commit is contained in:
@@ -430,7 +430,19 @@ func (db *Database) Vacuum(ctx context.Context) error {
|
||||
|
||||
// Analyze runs an ANALYZE on the database to improve query performance.
|
||||
func (db *Database) Analyze(ctx context.Context) error {
|
||||
_, err := db.writeDB.ExecContext(ctx, "ANALYZE")
|
||||
return analyze(ctx, db.writeDB)
|
||||
}
|
||||
|
||||
// analyze runs an ANALYZE on the database to improve query performance.
|
||||
func analyze(ctx context.Context, db *sqlx.DB) error {
|
||||
_, err := db.ExecContext(ctx, "ANALYZE")
|
||||
return err
|
||||
}
|
||||
|
||||
// flushWAL flushes the Write-Ahead Log (WAL) to the main database file.
|
||||
// It also truncates the WAL file to 0 bytes.
|
||||
func flushWAL(ctx context.Context, db *sqlx.DB) error {
|
||||
_, err := db.ExecContext(ctx, "PRAGMA wal_checkpoint(TRUNCATE)")
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user