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 Jan 5, 2024
1 parent a4e46cd commit 4a5a867
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 @@ -67,8 +67,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 @@ -159,7 +159,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 @@ -290,7 +290,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 4a5a867

Please sign in to comment.