Skip to content

Commit

Permalink
Merge pull request #300 from kaleido-io/remove-member-field
Browse files Browse the repository at this point in the history
remove-member-field Removing member field from operations table
  • Loading branch information
nguyer authored Oct 28, 2021
2 parents d61b8d0 + 8a45ee1 commit ce179d5
Show file tree
Hide file tree
Showing 16 changed files with 17 additions and 36 deletions.
3 changes: 3 additions & 0 deletions db/migrations/postgres/000041_drop_operations_member.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BEGIN;
ALTER TABLE operations ADD COLUMN member VARCHAR(1024);
COMMIT;
3 changes: 3 additions & 0 deletions db/migrations/postgres/000041_drop_operations_member.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BEGIN;
ALTER TABLE operations DROP COLUMN member;
COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE operations ADD COLUMN member VARCHAR(1024);
1 change: 1 addition & 0 deletions db/migrations/sqlite/000041_drop_operations_member.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE operations DROP COLUMN member;
11 changes: 0 additions & 11 deletions docs/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2450,8 +2450,6 @@ paths:
input:
additionalProperties: {}
type: object
member:
type: string
namespace:
type: string
output:
Expand Down Expand Up @@ -3061,11 +3059,6 @@ paths:
name: input
schema:
type: string
- description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^'
in: query
name: member
schema:
type: string
- description: 'Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^'
in: query
name: namespace
Expand Down Expand Up @@ -3151,8 +3144,6 @@ paths:
input:
additionalProperties: {}
type: object
member:
type: string
namespace:
type: string
output:
Expand Down Expand Up @@ -3211,8 +3202,6 @@ paths:
input:
additionalProperties: {}
type: object
member:
type: string
namespace:
type: string
output:
Expand Down
3 changes: 1 addition & 2 deletions internal/assets/token_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ func (am *assetManager) createTokenPoolInternal(ctx context.Context, pool *fftyp
tx.ID,
"",
fftypes.OpTypeTokenCreatePool,
fftypes.OpStatusPending,
"")
fftypes.OpStatusPending)
addTokenPoolCreateInputs(op, pool)

err = am.database.RunAsGroup(ctx, func(ctx context.Context) (err error) {
Expand Down
3 changes: 1 addition & 2 deletions internal/assets/token_pool_created.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ func (am *assetManager) TokenPoolCreated(tk tokens.Plugin, pool *fftypes.TokenPo
transaction.ID,
"",
fftypes.OpTypeTokenAnnouncePool,
fftypes.OpStatusPending,
pool.Key)
fftypes.OpStatusPending)

valid, err = am.txhelper.PersistTransaction(ctx, transaction)
if valid && err == nil {
Expand Down
3 changes: 1 addition & 2 deletions internal/assets/token_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ func (s *transferSender) sendInternal(ctx context.Context, method sendMethod) er
tx.ID,
"",
fftypes.OpTypeTokenTransfer,
fftypes.OpStatusPending,
"")
fftypes.OpStatusPending)
addTokenTransferInputs(op, &s.transfer.TokenTransfer)

err = s.mgr.database.RunAsGroup(ctx, func(ctx context.Context) (err error) {
Expand Down
3 changes: 1 addition & 2 deletions internal/batchpin/batchpin.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ func (bp *batchPinSubmitter) SubmitPinnedBatch(ctx context.Context, batch *fftyp
batch.Payload.TX.ID,
"",
fftypes.OpTypeBlockchainBatchPin,
fftypes.OpStatusPending,
"")
fftypes.OpStatusPending)
err = bp.database.UpsertOperation(ctx, op, false)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion internal/broadcast/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (bm *broadcastManager) submitTXAndUpdateDB(ctx context.Context, batch *ffty
batch.PayloadRef,
fftypes.OpTypePublicStorageBatchBroadcast,
fftypes.OpStatusSucceeded, // Note we performed the action synchronously above
"")
)
err = bm.database.UpsertOperation(ctx, op, false)
if err != nil {
return err
Expand Down
4 changes: 0 additions & 4 deletions internal/database/sqlcommon/operation_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ var (
"tx_id",
"optype",
"opstatus",
"member",
"plugin",
"backend_id",
"created",
Expand Down Expand Up @@ -83,7 +82,6 @@ func (s *SQLCommon) UpsertOperation(ctx context.Context, operation *fftypes.Oper
Set("tx_id", operation.Transaction).
Set("optype", operation.Type).
Set("opstatus", operation.Status).
Set("member", operation.Member).
Set("plugin", operation.Plugin).
Set("backend_id", operation.BackendID).
Set("created", operation.Created).
Expand All @@ -108,7 +106,6 @@ func (s *SQLCommon) UpsertOperation(ctx context.Context, operation *fftypes.Oper
operation.Transaction,
string(operation.Type),
string(operation.Status),
operation.Member,
operation.Plugin,
operation.BackendID,
operation.Created,
Expand Down Expand Up @@ -136,7 +133,6 @@ func (s *SQLCommon) opResult(ctx context.Context, row *sql.Rows) (*fftypes.Opera
&op.Transaction,
&op.Type,
&op.Status,
&op.Member,
&op.Plugin,
&op.BackendID,
&op.Created,
Expand Down
2 changes: 0 additions & 2 deletions internal/database/sqlcommon/operation_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func TestOperationE2EWithDB(t *testing.T) {
Type: fftypes.OpTypeBlockchainBatchPin,
Transaction: fftypes.NewUUID(),
Status: fftypes.OpStatusFailed,
Member: "sally",
Plugin: "ethereum",
BackendID: fftypes.NewRandB32().String(),
Error: "pop",
Expand All @@ -90,7 +89,6 @@ func TestOperationE2EWithDB(t *testing.T) {
fb.Eq("id", operationUpdated.ID.String()),
fb.Eq("tx", operationUpdated.Transaction),
fb.Eq("type", operationUpdated.Type),
fb.Eq("member", operationUpdated.Member),
fb.Eq("status", operationUpdated.Status),
fb.Eq("error", operationUpdated.Error),
fb.Eq("plugin", operationUpdated.Plugin),
Expand Down
6 changes: 2 additions & 4 deletions internal/privatemessaging/privatemessaging.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ func (pm *privateMessaging) transferBlobs(ctx context.Context, data []*fftypes.D
txid,
trackingID,
fftypes.OpTypeDataExchangeBlobSend,
fftypes.OpStatusPending,
node.ID.String())
fftypes.OpStatusPending)
if err = pm.database.UpsertOperation(ctx, op, false); err != nil {
return err
}
Expand Down Expand Up @@ -211,8 +210,7 @@ func (pm *privateMessaging) sendData(ctx context.Context, mType string, mID *fft
txid,
trackingID,
fftypes.OpTypeDataExchangeBatchSend,
fftypes.OpStatusPending,
node.ID.String())
fftypes.OpStatusPending)
if err = pm.database.UpsertOperation(ctx, op, false); err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion pkg/database/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,6 @@ var OperationQueryFactory = &queryFields{
"id": &UUIDField{},
"tx": &UUIDField{},
"type": &StringField{},
"member": &StringField{},
"namespace": &StringField{},
"status": &StringField{},
"error": &StringField{},
Expand Down
4 changes: 1 addition & 3 deletions pkg/fftypes/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@ type Named interface {
}

// NewTXOperation creates a new operation for a transaction
func NewTXOperation(plugin Named, namespace string, tx *UUID, backendID string, opType OpType, opStatus OpStatus, member string) *Operation {
func NewTXOperation(plugin Named, namespace string, tx *UUID, backendID string, opType OpType, opStatus OpStatus) *Operation {
return &Operation{
ID: NewUUID(),
Namespace: namespace,
Plugin: plugin.Name(),
BackendID: backendID,
Transaction: tx,
Type: opType,
Member: member,
Status: opStatus,
Created: Now(),
}
Expand All @@ -75,7 +74,6 @@ type Operation struct {
Namespace string `json:"namespace"`
Transaction *UUID `json:"tx"`
Type OpType `json:"type" ffenum:"optype"`
Member string `json:"member,omitempty"`
Status OpStatus `json:"status"`
Error string `json:"error,omitempty"`
Plugin string `json:"plugin"`
Expand Down
3 changes: 1 addition & 2 deletions pkg/fftypes/operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ func (f *fakePlugin) Name() string { return "fake" }
func TestNewPendingMessageOp(t *testing.T) {

txID := NewUUID()
op := NewTXOperation(&fakePlugin{}, "ns1", txID, "testBackend", OpTypePublicStorageBatchBroadcast, OpStatusPending, "member")
op := NewTXOperation(&fakePlugin{}, "ns1", txID, "testBackend", OpTypePublicStorageBatchBroadcast, OpStatusPending)
assert.Equal(t, Operation{
ID: op.ID,
Namespace: "ns1",
Transaction: txID,
Plugin: "fake",
BackendID: "testBackend",
Type: OpTypePublicStorageBatchBroadcast,
Member: "member",
Status: OpStatusPending,
Created: op.Created,
}, *op)
Expand Down

0 comments on commit ce179d5

Please sign in to comment.