-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from costap/main
Adds index on transations table timestamp
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
internal/datastore/postgres/migrations/add_transaction_timestamp_index.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package migrations | ||
|
||
const createIndexOnTupleTransactionTimestamp = ` | ||
CREATE INDEX ix_relation_tuple_transaction_by_timestamp on relation_tuple_transaction(timestamp); | ||
` | ||
|
||
func init() { | ||
if err := DatabaseMigrations.Register("add-transaction-timestamp-index", "add-unique-living-ns", func(apd *AlembicPostgresDriver) error { | ||
tx, err := apd.db.Beginx() | ||
if err != nil { | ||
return err | ||
} | ||
defer tx.Rollback() | ||
|
||
_, err = tx.Exec(createIndexOnTupleTransactionTimestamp) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return tx.Commit() | ||
}); err != nil { | ||
panic("failed to register migration: " + err.Error()) | ||
} | ||
} |