fix(migrations): create days_to_sync_history column read by wmiau.go - #361
Open
yanmayck wants to merge 1 commit into
Open
fix(migrations): create days_to_sync_history column read by wmiau.go#361yanmayck wants to merge 1 commit into
yanmayck wants to merge 1 commit into
Conversation
wmiau.go queries days_to_sync_history to decide how much history to request
on connect:
query := "SELECT COALESCE(days_to_sync_history, 0) FROM users WHERE id=$1"
but no migration creates that column. On a fresh install the query errors,
the code logs "Failed to get days_to_sync_history from database" and falls
through to 0, so the history-sync-by-days feature never runs. It only works
on databases where the column arrived from somewhere else.
Adds migration 13 (next free ID: 9, 10 and 12 are taken) with the same
guarded pattern used by the surrounding migrations — IF NOT EXISTS on
PostgreSQL, addColumnIfNotExistsSQLite on SQLite — so it is a no-op where
the column already exists.
Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_01Ep6DPMhWw9D2UhfhKtRe3s
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
wmiau.goreadsdays_to_sync_historywhen deciding how much history to request on connect:But no migration creates that column.
On a fresh install the query errors out, the code logs
Failed to get days_to_sync_history from databaseand falls through to0, so the history-sync-by-days feature silently never runs. It only works on databases where the column arrived from somewhere else (a hand-written ALTER, or a fork that added its own migration).Because the failure path only warns and continues, this is easy to miss — there is no error, just a feature that quietly does nothing.
Fix
Adds migration
13— the next free ID, since 9, 10 and 12 are taken — creating the column with the same guarded pattern the surrounding migrations already use:DO $$ ... IF NOT EXISTS (SELECT 1 FROM information_schema.columns ...)addColumnIfNotExistsSQLite(tx, "users", "days_to_sync_history", "INTEGER DEFAULT 0")Both are no-ops where the column already exists, so this is safe to apply to existing databases.
Testing
Reviewed against the existing migration idioms in
migrations.go; the SQLite path reuses the same helper as migrations 10 and 12. I don't have a Go toolchain on this machine to run the suite — worth a CI run before merging.