Skip to content

Commit

Permalink
add READMEs, CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronc committed Jul 3, 2024
1 parent b11bb2c commit 64bf68f
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 1 deletion.
37 changes: 37 additions & 0 deletions indexer/postgres/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--
Guiding Principles:
Changelogs are for humans, not machines.
There should be an entry for every single version.
The same types of changes should be grouped.
Versions and sections should be linkable.
The latest version comes first.
The release date of each version is displayed.
Mention whether you follow Semantic Versioning.
Usage:
Change log entries are to be added to the Unreleased section under the
appropriate stanza (see below). Each entry should ideally include a tag and
the Github issue reference in the following format:
* (<tag>) \#<issue-number> message
The issue numbers will later be link-ified during the release process so you do
not have to worry about including a link manually, but you can if you wish.
Types of changes (Stanzas):
"Features" for new features.
"Improvements" for changes in existing functionality.
"Deprecated" for soon-to-be removed features.
"Bug Fixes" for any bug fixes.
"Client Breaking" for breaking Protobuf, gRPC and REST routes used by end-users.
"CLI Breaking" for breaking CLI commands.
"API Breaking" for breaking exported APIs used by developers building on SDK.
Ref: https://keepachangelog.com/en/1.0.0/
-->

# Changelog

## [Unreleased]
41 changes: 41 additions & 0 deletions indexer/postgres/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# PostgreSQL Indexer

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

## Table, Column and Enum Naming

`ObjectType`s 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` `Kind`s 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 nano-seconds 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 with module name it pertains to |


3 changes: 3 additions & 0 deletions indexer/postgres/tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# PostgreSQL Indexer Tests

The majority of tests for the PostgreSQL indexer are stored in this separate `tests` go module to keep the main indexer module free of dependencies on any particular PostgreSQL driver. This allows users to choose their own driver and integrate the indexer free of any dependency conflict concerns.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package testing
package tests

import (
"context"
Expand Down

0 comments on commit 64bf68f

Please sign in to comment.