Skip to content

Commit

Permalink
feat(templates): scaffold module migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Jan 23, 2024
1 parent 0dbdd2c commit 0911832
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package keeper

// Migrator is a struct for handling in-place store migrations.
type Migrator struct {
keeper *Keeper
}

// NewMigrator returns a new Migrator.
func NewMigrator(keeper *Keeper) Migrator {
return Migrator{
keeper: keeper,
}
}

// this line is used by starport scaffolding # migrations/migrator
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ func NewAppModule(
func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)

m := keeper.NewMigrator(am.keeper)
_ = m
// this line is used by starport scaffolding # migrations/register
}

// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package {{ num }}

import (
"context"

corestoretypes "cosmossdk.io/core/store"

"github.com/cosmos/cosmos-sdk/codec"
)

// MigrateStore migrates the module to consensus version {{ num }}.
func MigrateStore(ctx context.Context, storeService corestoretypes.KVStoreService, cdc codec.BinaryCodec) {
// Insert {{ num }} migration here.
}
4 changes: 4 additions & 0 deletions ignite/templates/module/placeholders.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ const (
PlaceholderTypesGenesisValidField = "// this line is used by starport scaffolding # types/genesis/validField"
PlaceholderGenesisTestState = "// this line is used by starport scaffolding # genesis/test/state"
PlaceholderGenesisTestAssert = "// this line is used by starport scaffolding # genesis/test/assert"

// Migrations
PlaceholderMigrationsRegister = "// this line is used by starport scaffolding # migrations/register"
PlaceholderMigrationsMigrator = "// this line is used by starport scaffolding # migrations/migrator"
)

0 comments on commit 0911832

Please sign in to comment.