storagenode/storagenodedb: paystubs distributed not null added
Change-Id: I021ba1c4ce4865f2575466d9b4d702775a5654cf
This commit is contained in:
parent
4661bc9b84
commit
a86bd27513
@ -1901,6 +1901,76 @@ func (db *DB) Migration(ctx context.Context) *migrate.Migration {
|
||||
`ALTER TABLE paystubs ADD COLUMN distributed bigint`,
|
||||
},
|
||||
},
|
||||
{
|
||||
DB: &db.payoutDB.DB,
|
||||
Description: "Make distributed field in paystubs table not null",
|
||||
Version: 50,
|
||||
Action: migrate.Func(func(ctx context.Context, _ *zap.Logger, rdb tagsql.DB, rtx tagsql.Tx) (err error) {
|
||||
_, err = rtx.Exec(ctx, `UPDATE paystubs SET distributed = ? WHERE distributed ISNULL`, 0)
|
||||
if err != nil {
|
||||
return errs.Wrap(err)
|
||||
}
|
||||
|
||||
_, err = rtx.Exec(ctx, `
|
||||
CREATE TABLE paystubs_new (
|
||||
period text NOT NULL,
|
||||
satellite_id bytea NOT NULL,
|
||||
created_at timestamp NOT NULL,
|
||||
codes text NOT NULL,
|
||||
usage_at_rest double precision NOT NULL,
|
||||
usage_get bigint NOT NULL,
|
||||
usage_put bigint NOT NULL,
|
||||
usage_get_repair bigint NOT NULL,
|
||||
usage_put_repair bigint NOT NULL,
|
||||
usage_get_audit bigint NOT NULL,
|
||||
comp_at_rest bigint NOT NULL,
|
||||
comp_get bigint NOT NULL,
|
||||
comp_put bigint NOT NULL,
|
||||
comp_get_repair bigint NOT NULL,
|
||||
comp_put_repair bigint NOT NULL,
|
||||
comp_get_audit bigint NOT NULL,
|
||||
surge_percent bigint NOT NULL,
|
||||
held bigint NOT NULL,
|
||||
owed bigint NOT NULL,
|
||||
disposed bigint NOT NULL,
|
||||
paid bigint NOT NULL,
|
||||
distributed bigint NOT NULL,
|
||||
PRIMARY KEY ( period, satellite_id )
|
||||
);
|
||||
INSERT INTO paystubs_new SELECT
|
||||
period,
|
||||
satellite_id,
|
||||
created_at,
|
||||
codes,
|
||||
usage_at_rest,
|
||||
usage_get,
|
||||
usage_put,
|
||||
usage_get_repair,
|
||||
usage_put_repair,
|
||||
usage_get_audit,
|
||||
comp_at_rest,
|
||||
comp_get,
|
||||
comp_put,
|
||||
comp_get_repair,
|
||||
comp_put_repair,
|
||||
comp_get_audit,
|
||||
surge_percent,
|
||||
held,
|
||||
owed,
|
||||
disposed,
|
||||
paid,
|
||||
distributed
|
||||
FROM paystubs;
|
||||
DROP TABLE paystubs;
|
||||
ALTER TABLE paystubs_new RENAME TO paystubs;
|
||||
`)
|
||||
if err != nil {
|
||||
return errs.Wrap(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ func Schema() map[string]*dbschema.Schema {
|
||||
&dbschema.Column{
|
||||
Name: "distributed",
|
||||
Type: "bigint",
|
||||
IsNullable: true,
|
||||
IsNullable: false,
|
||||
},
|
||||
&dbschema.Column{
|
||||
Name: "held",
|
||||
|
@ -64,6 +64,7 @@ var States = MultiDBStates{
|
||||
&v47,
|
||||
&v48,
|
||||
&v49,
|
||||
&v50,
|
||||
},
|
||||
}
|
||||
|
||||
|
63
storagenode/storagenodedb/testdata/v50.go
vendored
Normal file
63
storagenode/storagenodedb/testdata/v50.go
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
// Copyright (C) 2021 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package testdata
|
||||
|
||||
import "storj.io/storj/storagenode/storagenodedb"
|
||||
|
||||
var v50 = MultiDBState{
|
||||
Version: 50,
|
||||
DBStates: DBStates{
|
||||
storagenodedb.UsedSerialsDBName: v47.DBStates[storagenodedb.UsedSerialsDBName],
|
||||
storagenodedb.StorageUsageDBName: v47.DBStates[storagenodedb.StorageUsageDBName],
|
||||
storagenodedb.ReputationDBName: v48.DBStates[storagenodedb.ReputationDBName],
|
||||
storagenodedb.PieceSpaceUsedDBName: v47.DBStates[storagenodedb.PieceSpaceUsedDBName],
|
||||
storagenodedb.PieceInfoDBName: v47.DBStates[storagenodedb.PieceInfoDBName],
|
||||
storagenodedb.PieceExpirationDBName: v47.DBStates[storagenodedb.PieceExpirationDBName],
|
||||
storagenodedb.OrdersDBName: v47.DBStates[storagenodedb.OrdersDBName],
|
||||
storagenodedb.BandwidthDBName: v47.DBStates[storagenodedb.BandwidthDBName],
|
||||
storagenodedb.SatellitesDBName: v47.DBStates[storagenodedb.SatellitesDBName],
|
||||
storagenodedb.DeprecatedInfoDBName: v47.DBStates[storagenodedb.DeprecatedInfoDBName],
|
||||
storagenodedb.NotificationsDBName: v47.DBStates[storagenodedb.NotificationsDBName],
|
||||
storagenodedb.HeldAmountDBName: &DBState{
|
||||
SQL: `
|
||||
-- tables to hold payments and paystub data
|
||||
CREATE TABLE paystubs (
|
||||
period text NOT NULL,
|
||||
satellite_id bytea NOT NULL,
|
||||
created_at timestamp NOT NULL,
|
||||
codes text NOT NULL,
|
||||
usage_at_rest double precision NOT NULL,
|
||||
usage_get bigint NOT NULL,
|
||||
usage_put bigint NOT NULL,
|
||||
usage_get_repair bigint NOT NULL,
|
||||
usage_put_repair bigint NOT NULL,
|
||||
usage_get_audit bigint NOT NULL,
|
||||
comp_at_rest bigint NOT NULL,
|
||||
comp_get bigint NOT NULL,
|
||||
comp_put bigint NOT NULL,
|
||||
comp_get_repair bigint NOT NULL,
|
||||
comp_put_repair bigint NOT NULL,
|
||||
comp_get_audit bigint NOT NULL,
|
||||
surge_percent bigint NOT NULL,
|
||||
held bigint NOT NULL,
|
||||
owed bigint NOT NULL,
|
||||
disposed bigint NOT NULL,
|
||||
paid bigint NOT NULL,
|
||||
distributed bigint NOT NULL,
|
||||
PRIMARY KEY ( period, satellite_id )
|
||||
);
|
||||
CREATE TABLE payments (
|
||||
id bigserial NOT NULL,
|
||||
created_at timestamp NOT NULL,
|
||||
satellite_id bytea NOT NULL,
|
||||
period text,
|
||||
amount bigint NOT NULL,
|
||||
receipt text,
|
||||
notes text,
|
||||
PRIMARY KEY ( id )
|
||||
);`,
|
||||
},
|
||||
storagenodedb.PricingDBName: v47.DBStates[storagenodedb.PricingDBName],
|
||||
storagenodedb.APIKeysDBName: v47.DBStates[storagenodedb.APIKeysDBName]},
|
||||
}
|
@ -152,6 +152,8 @@ export function newPayoutModule(service: PayoutService): StoreModule<PayoutState
|
||||
commit(PAYOUT_MUTATIONS.SET_ESTIMATION, estimatedInfo);
|
||||
},
|
||||
[PAYOUT_ACTIONS.GET_PAYOUT_HISTORY]: async function ({ commit, state }: any): Promise<void> {
|
||||
if (!state.payoutHistoryPeriod) return;
|
||||
|
||||
const payoutHistory = await service.payoutHistory(state.payoutHistoryPeriod);
|
||||
|
||||
commit(PAYOUT_MUTATIONS.SET_PAYOUT_HISTORY, payoutHistory);
|
||||
|
@ -110,6 +110,12 @@ export default class PayoutArea extends Vue {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
try {
|
||||
await this.$store.dispatch(PAYOUT_ACTIONS.GET_HELD_HISTORY);
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
}
|
||||
|
||||
await this.$store.dispatch(APPSTATE_ACTIONS.SET_LOADING, false);
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ export class PayoutHttpApi implements PayoutApi {
|
||||
* @throws Error
|
||||
*/
|
||||
public async getHeldHistory(): Promise<SatelliteHeldHistory[]> {
|
||||
const path = `${this.ROOT_PATH}/held-history/`;
|
||||
const path = `${this.ROOT_PATH}/held-history`;
|
||||
|
||||
const response = await this.client.get(path);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user