@@ -95,10 +95,16 @@ func testLegacyMigrationUpgradePreservesDataAndIsIdempotent(t *testing.T, db *bu
9595 }
9696 markAppliedMigration (t , ctx , migrator , "2026040501" , 1 )
9797 seedLegacyMigrationData (t , db )
98+ walletBefore := readLegacyWalletRow (t , db )
9899 if _ , err := migrator .Migrate (ctx ); err != nil {
99100 t .Fatalf ("upgrade legacy schema: %v" , err )
100101 }
101102
103+ // 2026062201 rebuilds wallet_operations on SQLite by copying rows.
104+ if walletAfter := readLegacyWalletRow (t , db ); walletAfter != walletBefore {
105+ t .Fatalf ("wallet row changed across the upgrade:\n before=%s\n after =%s" , walletBefore , walletAfter )
106+ }
107+
102108 var generation int
103109 var current bool
104110 if err := db .NewRaw ("SELECT generation, is_current FROM storage_data_sets WHERE id = 1" ).Scan (ctx , & generation , & current ); err != nil {
@@ -177,6 +183,12 @@ func seedLegacyMigrationData(t *testing.T, db *bun.DB) {
177183 `INSERT INTO storage_data_sets
178184 (id, bucket_id, provider_id, copy_index, status)
179185 VALUES (1, 1, '101', 0, 'ready')` ,
186+ `INSERT INTO wallet_operations
187+ (id, type, client_request_id, amount, status, tx_hash, last_error,
188+ lease_until, started_at, submitted_at, completed_at, created_at, updated_at)
189+ VALUES (1, 'fund', 'legacy-fund', '1234', 'confirmed', '0xfeed', 'boom',
190+ '2026-01-01 01:00:00', '2026-01-02 02:00:00', '2026-01-03 03:00:00',
191+ '2026-01-04 04:00:00', '2026-01-05 05:00:00', '2026-01-06 06:00:00')` ,
180192 }
181193 for _ , statement := range statements {
182194 if _ , err := db .ExecContext (ctx , statement ); err != nil {
@@ -185,6 +197,41 @@ func seedLegacyMigrationData(t *testing.T, db *bun.DB) {
185197 }
186198}
187199
200+ func readLegacyWalletRow (t * testing.T , db * bun.DB ) string {
201+ t .Helper ()
202+ var (
203+ opType , requestID , amount , status string
204+ txHash , lastError * string
205+ lease , started , submitted , done * time.Time
206+ created , updated time.Time
207+ )
208+ if err := db .NewRaw (`SELECT type, client_request_id, amount, status, tx_hash, last_error,
209+ lease_until, started_at, submitted_at, completed_at, created_at, updated_at
210+ FROM wallet_operations WHERE id = 1` ).
211+ Scan (context .Background (), & opType , & requestID , & amount , & status , & txHash , & lastError ,
212+ & lease , & started , & submitted , & done , & created , & updated ); err != nil {
213+ t .Fatalf ("read wallet row: %v" , err )
214+ }
215+ return fmt .Sprintf ("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s" ,
216+ opType , requestID , amount , status , derefString (txHash ), derefString (lastError ),
217+ formatTime (lease ), formatTime (started ), formatTime (submitted ), formatTime (done ),
218+ formatTime (& created ), formatTime (& updated ))
219+ }
220+
221+ func derefString (v * string ) string {
222+ if v == nil {
223+ return "<nil>"
224+ }
225+ return * v
226+ }
227+
228+ func formatTime (v * time.Time ) string {
229+ if v == nil {
230+ return "<nil>"
231+ }
232+ return v .UTC ().Format (time .RFC3339Nano )
233+ }
234+
188235func countDomainTables (ctx context.Context , db * bun.DB ) (int , error ) {
189236 query := `SELECT COUNT(*) FROM sqlite_schema
190237 WHERE type = 'table' AND name NOT LIKE 'sqlite_%'
0 commit comments