cosmos-sdk/indexer/postgres
dependabot[bot] aabd4b1922
build(deps): Bump github.com/jackc/pgx/v5 from 5.7.1 to 5.7.2 in /indexer/postgres/tests (#23078)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <dependabot[bot]@users.noreply.github.com>
2024-12-26 09:37:48 +00:00
..
internal/testdata refactor(schema)!: rename ObjectType -> StateObjectType (#21691) 2024-09-16 08:17:52 +00:00
tests build(deps): Bump github.com/jackc/pgx/v5 from 5.7.1 to 5.7.2 in /indexer/postgres/tests (#23078) 2024-12-26 09:37:48 +00:00
base_sql.go feat(indexer/postgres)!: add basic support for header, txs and events (#22695) 2024-12-09 18:36:24 +00:00
CHANGELOG.md chore: re-add IntProto and DecProto and deprecate msg (#22925) 2024-12-17 14:57:03 +00:00
column.go refactor(schema)!: rename IntegerStringKind and DecimalStringKind (#21694) 2024-09-14 01:45:15 +00:00
conn.go refactor(indexer/postgres)!: use schema/indexer API and hide types/methods (#21363) 2024-08-21 14:49:02 +00:00
create_table_test.go refactor(schema)!: rename ObjectType -> StateObjectType (#21691) 2024-09-16 08:17:52 +00:00
create_table.go feat(indexer): add to modules and implement proto fields (#22544) 2024-11-28 09:46:59 +00:00
delete.go feat(indexer/postgres): add insert/update/delete functionality (#21186) 2024-09-04 12:06:49 +00:00
enum_test.go refactor(indexer/postgres)!: use schema/indexer API and hide types/methods (#21363) 2024-08-21 14:49:02 +00:00
enum.go feat(indexer): add to modules and implement proto fields (#22544) 2024-11-28 09:46:59 +00:00
go.mod chore: package release prep (2/n) (#22885) 2024-12-16 19:35:53 +00:00
go.sum chore: package release prep (2/n) (#22885) 2024-12-16 19:35:53 +00:00
indexer.go feat(schema/indexer)!: implement start indexing (#21636) 2024-09-23 16:09:01 +00:00
insert_update.go feat(indexer/postgres): add insert/update/delete functionality (#21186) 2024-09-04 12:06:49 +00:00
listener.go feat(indexer/postgres)!: add basic support for header, txs and events (#22695) 2024-12-09 18:36:24 +00:00
module.go refactor(schema)!: rename ObjectType -> StateObjectType (#21691) 2024-09-16 08:17:52 +00:00
object.go refactor(schema)!: rename ObjectType -> StateObjectType (#21691) 2024-09-16 08:17:52 +00:00
options.go feat(indexer/postgres): add insert/update/delete functionality (#21186) 2024-09-04 12:06:49 +00:00
params.go chore(all): replace all fmt.Errorf without paramters with errors.New (#21590) 2024-09-09 06:50:03 +00:00
README.md feat(indexer): postgres schema creation + CI config (#20701) 2024-07-18 09:34:09 +00:00
select.go docs: fix function comments (#21814) 2024-09-19 06:53:08 +00:00
sonar-project.properties feat(indexer): postgres schema creation + CI config (#20701) 2024-07-18 09:34:09 +00:00
view.go refactor(schema)!: rename ObjectType -> StateObjectType (#21691) 2024-09-16 08:17:52 +00:00
where.go feat(indexer/postgres): add insert/update/delete functionality (#21186) 2024-09-04 12:06:49 +00:00

PostgreSQL Indexer

The PostgreSQL indexer can fully index the current state for all modules that implement cosmossdk.io/schema.HasModuleCodec. implement cosmossdk.io/schema.HasModuleCodec.

Table, Column and Enum Naming

ObjectTypes names are converted to table names prefixed with the module name and an underscore. i.e. the ObjectType foo in module bar will be stored in a table named bar_foo.

Column names are identical to field names. All identifiers are quoted with double quotes so that they are case-sensitive and won't clash with any reserved names.

Like, table names, enum types are prefixed with the module name and an underscore.

Schema Type Mapping

The mapping of cosmossdk.io/schema Kinds to PostgreSQL types is as follows:

Kind PostgreSQL Type Notes
StringKind TEXT
BoolKind BOOLEAN
BytesKind BYTEA
Int8Kind SMALLINT
Int16Kind SMALLINT
Int32Kind INTEGER
Int64Kind BIGINT
Uint8Kind SMALLINT
Uint16Kind INTEGER
Uint32Kind BIGINT
Uint64Kind NUMERIC
Float32Kind REAL
Float64Kind DOUBLE PRECISION
IntegerStringKind NUMERIC
DecimalStringKind NUMERIC
JSONKind JSONB
Bech32AddressKind TEXT addresses are converted to strings with the specified address prefix
TimeKind BIGINT and TIMESTAMPTZ time types are stored as two columns, one with the _nanos suffix with full nanoseconds precision, and another as a TIMESTAMPTZ generated column with microsecond precision
DurationKind BIGINT durations are stored as a single column in nanoseconds
EnumKind <module_name>_<enum_name> a custom enum type is created for each module prefixed with the module name it pertains to