storagenode/storagenodedb: migrate to set total to content_size
Change-Id: I4906c2fe9cdb3a32c045c98039d4bde6b8b809e3
This commit is contained in:
parent
006a2824ba
commit
21b65ca3b0
@ -1042,6 +1042,14 @@ func (db *DB) Migration(ctx context.Context) *migrate.Migration {
|
||||
`CREATE UNIQUE INDEX idx_piece_space_used_satellite_id ON piece_space_used(satellite_id)`,
|
||||
},
|
||||
},
|
||||
{
|
||||
DB: db.pieceSpaceUsedDB,
|
||||
Description: "Rename total column to content_size",
|
||||
Version: 30,
|
||||
Action: migrate.SQL{
|
||||
`UPDATE piece_space_used SET total = content_size`,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ var States = MultiDBStates{
|
||||
&v27,
|
||||
&v28,
|
||||
&v29,
|
||||
&v30,
|
||||
},
|
||||
}
|
||||
|
||||
|
36
storagenode/storagenodedb/testdata/v30.go
vendored
Normal file
36
storagenode/storagenodedb/testdata/v30.go
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2020 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package testdata
|
||||
|
||||
import (
|
||||
"storj.io/storj/storagenode/storagenodedb"
|
||||
)
|
||||
|
||||
var v30 = MultiDBState{
|
||||
Version: 30,
|
||||
DBStates: DBStates{
|
||||
storagenodedb.UsedSerialsDBName: v28.DBStates[storagenodedb.UsedSerialsDBName],
|
||||
storagenodedb.StorageUsageDBName: v28.DBStates[storagenodedb.StorageUsageDBName],
|
||||
storagenodedb.ReputationDBName: v28.DBStates[storagenodedb.ReputationDBName],
|
||||
storagenodedb.PieceSpaceUsedDBName: &DBState{
|
||||
SQL: `
|
||||
CREATE TABLE piece_space_used (
|
||||
total INTEGER NOT NULL DEFAULT 0,
|
||||
content_size INTEGER NOT NULL,
|
||||
satellite_id BLOB
|
||||
);
|
||||
CREATE UNIQUE INDEX idx_piece_space_used_satellite_id ON piece_space_used(satellite_id);
|
||||
INSERT INTO piece_space_used (content_size, total) VALUES (1337, 1337);
|
||||
INSERT INTO piece_space_used (content_size, total, satellite_id) VALUES (1337, 1337, X'0ed28abb2813e184a1e98b0f6605c4911ea468c7e8433eb583e0fca7ceac3000');
|
||||
`,
|
||||
},
|
||||
storagenodedb.PieceInfoDBName: v28.DBStates[storagenodedb.PieceInfoDBName],
|
||||
storagenodedb.PieceExpirationDBName: v28.DBStates[storagenodedb.PieceExpirationDBName],
|
||||
storagenodedb.OrdersDBName: v28.DBStates[storagenodedb.OrdersDBName],
|
||||
storagenodedb.BandwidthDBName: v28.DBStates[storagenodedb.BandwidthDBName],
|
||||
storagenodedb.SatellitesDBName: v28.DBStates[storagenodedb.SatellitesDBName],
|
||||
storagenodedb.DeprecatedInfoDBName: v28.DBStates[storagenodedb.DeprecatedInfoDBName],
|
||||
storagenodedb.NotificationsDBName: v28.DBStates[storagenodedb.NotificationsDBName],
|
||||
},
|
||||
}
|
Loading…
Reference in New Issue
Block a user