fix(migrations): renumber the context checkpoint migration to 000105
#3406 (000104_skill_served_version) and #3407 (000104_message_context_checkpoint) each took version 104 and were merged eleven minutes apart. golang-migrate refuses to load a directory with a duplicate version ("duplicate migration file"), so every PostgreSQL deployment of main fails to migrate. Renumber the later of the two. It is safe for every deployment that could exist: one that migrated between the two merges applied the skill migration as 104 and now applies this one as 105, and after the second merge main could not load its migrations at all, so no deployment applied this file as 104. The migration is ADD COLUMN IF NOT EXISTS either way. Add a test that loads both migration directories. Pull request CI runs on the merge with main, so a second PR taking an already merged number now fails before it lands.main
parent
473c8726bb
commit
2a40cc37c0
|
|
@ -40,7 +40,7 @@ var versionedSQLiteColumns = map[string][]string{
|
|||
"users": {"is_system_admin"}, // 000053
|
||||
"knowledges": {"pending_subtasks_count", "profile"}, // 000056, 000101
|
||||
"knowledge_bases": {"profile_config", "generated_profile"}, // 000101
|
||||
"messages": {"attachments", "usage", "sandbox_checkpoint", "context_checkpoint"}, // 000034/085/097/104
|
||||
"messages": {"attachments", "usage", "sandbox_checkpoint", "context_checkpoint"}, // 000034/085/097/105
|
||||
"sessions": {"parent_session_id", "forked_from_message_id", "fork_bootstrap"}, // 000097
|
||||
"tenant_invitations": {"token", "accepted_count"}, // 000054
|
||||
"embed_channels": {"allow_memory"}, // 000060
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package database
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/golang-migrate/migrate/v4/source"
|
||||
_ "github.com/golang-migrate/migrate/v4/source/file"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// Two pull requests that each take the next migration number both pass their
|
||||
// own checks and collide once both are merged: golang-migrate refuses to load
|
||||
// a directory with a duplicate version, so every deployment fails to migrate.
|
||||
// 000104 did exactly that. Loading each directory catches it, since pull
|
||||
// request CI runs on the merge with the current main.
|
||||
func TestMigrationDirectoriesLoad(t *testing.T) {
|
||||
root := sqliteRepoRoot(t)
|
||||
for _, dir := range []string{"versioned", "sqlite"} {
|
||||
src, err := source.Open("file://" + filepath.Join(root, "migrations", dir))
|
||||
require.NoError(t, err, "migrations/%s must load", dir)
|
||||
require.NoError(t, src.Close())
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
-- Mirrors versioned migration 000104_message_context_checkpoint: the agent
|
||||
-- Mirrors versioned migration 000105_message_context_checkpoint: the agent
|
||||
-- compaction summary persisted on the last turn it covers.
|
||||
ALTER TABLE messages ADD COLUMN context_checkpoint TEXT;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
-- Migration: 000104_message_context_checkpoint
|
||||
-- Migration: 000105_message_context_checkpoint
|
||||
-- Agent compaction summaries persisted on the assistant message of the last
|
||||
-- turn they cover, so the next turn's history starts from the summary instead
|
||||
-- of summarizing the same turns again.
|
||||
Loading…
Reference in New Issue