Skip to content

Commit

Permalink
feat: expose Database#CreatePartitionIfNotExists method
Browse files Browse the repository at this point in the history
  • Loading branch information
RiccardoM authored and MonikaCat committed Dec 27, 2023
1 parent a274ebd commit 67e8053
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions database/postgresql/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ type Database struct {
Logger logging.Logger
}

// createPartitionIfNotExists creates a new partition having the given partition id if not existing
func (db *Database) createPartitionIfNotExists(table string, partitionID int64) error {
// CreatePartitionIfNotExists creates a new partition having the given partition id if not existing
func (db *Database) CreatePartitionIfNotExists(table string, partitionID int64) error {
partitionTable := fmt.Sprintf("%s_%d", table, partitionID)

stmt := fmt.Sprintf(
Expand Down Expand Up @@ -155,7 +155,7 @@ func (db *Database) SaveTx(tx *types.Tx) error {
partitionSize := config.Cfg.Database.PartitionSize
if partitionSize > 0 {
partitionID = tx.Height / partitionSize
err := db.createPartitionIfNotExists("transaction", partitionID)
err := db.CreatePartitionIfNotExists("transaction", partitionID)
if err != nil {
return err
}
Expand Down Expand Up @@ -286,7 +286,7 @@ func (db *Database) SaveMessage(msg *types.Message) error {
partitionSize := config.Cfg.Database.PartitionSize
if partitionSize > 0 {
partitionID = msg.Height / partitionSize
err := db.createPartitionIfNotExists("message", partitionID)
err := db.CreatePartitionIfNotExists("message", partitionID)
if err != nil {
return err
}
Expand Down

0 comments on commit 67e8053

Please sign in to comment.