diff --git a/.gitignore b/.gitignore index 26e9e00..81c9c76 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +migrations/current.sql + *.sw[pno] .envrc @@ -232,3 +234,26 @@ cython_debug/ # vendor/ /.idea/ + +# Logs +yarn-debug.log* +yarn-error.log* + +# Dependency directories +node_modules/ + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz diff --git a/.gmrc b/.gmrc new file mode 100644 index 0000000..2a86f69 --- /dev/null +++ b/.gmrc @@ -0,0 +1,140 @@ +/* + * Graphile Migrate configuration. + * + * If you decide to commit this file (recommended) please ensure that it does + * not contain any secrets (passwords, etc) - we recommend you manage these + * with environmental variables instead. + * + * This file is in JSON5 format, in VSCode you can use "JSON with comments" as + * the file format. + */ +{ + /* + * connectionString: this tells Graphile Migrate where to find the database + * to run the migrations against. + * + * RECOMMENDATION: use `DATABASE_URL` envvar instead. + */ + // "connectionString": "postgres://appuser:apppassword@host:5432/appdb", + + /* + * shadowConnectionString: like connectionString, but this is used for the + * shadow database (which will be reset frequently). + * + * RECOMMENDATION: use `SHADOW_DATABASE_URL` envvar instead. + */ + // "shadowConnectionString": "postgres://appuser:apppassword@host:5432/appdb_shadow", + + /* + * rootConnectionString: like connectionString, but this is used for + * dropping/creating the database in `graphile-migrate reset`. This isn't + * necessary, shouldn't be used in production, but helps during development. + * + * RECOMMENDATION: use `ROOT_DATABASE_URL` envvar instead. + */ + // "rootConnectionString": "postgres://adminuser:adminpassword@host:5432/postgres", + + /* + * pgSettings: key-value settings to be automatically loaded into PostgreSQL + * before running migrations, using an equivalent of `SET LOCAL TO + * ` + */ + "pgSettings": { + // "search_path": "app_public,app_private,app_hidden,public", + }, + + /* + * placeholders: substituted in SQL files when compiled/executed. Placeholder + * keys should be prefixed with a colon and in all caps, like + * `:COLON_PREFIXED_ALL_CAPS`. Placeholder values should be strings. They + * will be replaced verbatim with NO ESCAPING AT ALL (this differs from how + * psql handles placeholders) so should only be used with "safe" values. This + * is useful for committing migrations where certain parameters can change + * between environments (development, staging, production) but you wish to + * use the same signed migration files for all. + * + * The special value "!ENV" can be used to indicate an environmental variable + * of the same name should be used. + * + * Graphile Migrate automatically sets the `:DATABASE_NAME` and + * `:DATABASE_OWNER` placeholders, and you should not attempt to override + * these. + */ + "placeholders": { + // ":DATABASE_VISITOR": "!ENV", // Uses process.env.DATABASE_VISITOR + }, + + /* + * Actions allow you to run scripts or commands at certain points in the + * migration lifecycle. SQL files are ran against the database directly. + * "command" actions are ran with the following environmental variables set: + * + * - GM_DBURL: the PostgreSQL URL of the database being migrated + * - GM_DBNAME: the name of the database from GM_DBURL + * - GM_DBUSER: the user from GM_DBURL + * - GM_SHADOW: set to 1 if the shadow database is being migrated, left unset + * otherwise + * + * If "shadow" is unspecified, the actions will run on events to both shadow + * and normal databases. If "shadow" is true the action will only run on + * actions to the shadow DB, and if false only on actions to the main DB. + */ + + /* + * afterReset: actions executed after a `graphile-migrate reset` command. + */ + "afterReset": [ + // "afterReset.sql", + // { "_": "command", "command": "graphile-worker --schema-only" }, + "initial_schema.sql" + ], + + /* + * afterAllMigrations: actions executed once all migrations are complete. + */ + "afterAllMigrations": [ + { + "_": "command", + "shadow": true, + "command": "pg_dump --no-sync --schema-only --no-owner --file=./migrations/schema_snapshot.sql $SHADOW_DATABASE_URL", + }, + ], + + /* + * afterCurrent: actions executed once the current migration has been + * evaluated (i.e. in watch mode). + */ + "afterCurrent": [ + // { + // "_": "command", + // "shadow": true, + // "command": "if [ \"$IN_TESTS\" = \"1\" ]; then ./scripts/test-seed; fi", + // }, + ], + + /* + * blankMigrationContent: content to be written to the current migration + * after commit. NOTE: this should only contain comments. + */ + // "blankMigrationContent": "-- Write your migration here\n", + + /****************************************************************************\ + *** *** + *** You probably don't want to edit anything below here. *** + *** *** + \****************************************************************************/ + + /* + * manageGraphileMigrateSchema: if you set this false, you must be sure to + * keep the graphile_migrate schema up to date yourself. We recommend you + * leave it at its default. + */ + // "manageGraphileMigrateSchema": true, + + /* + * migrationsFolder: path to the folder in which to store your migrations. + */ + // migrationsFolder: "./migrations", + + "//generatedWith": "1.4.1" +} diff --git a/docker-compose.yml b/docker-compose.yml index 6e8bb8b..b9c199d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,7 +37,9 @@ services: dockerfile: docker/indexer.Dockerfile container_name: indexer_container environment: - DATABASE_URL: postgres://postgres:password@localhost:5432 + DATABASE_URL: postgres://postgres:password@localhost:5432/indexer + SHADOW_DATABASE_URL: postgres://postgres:password@localhost:5432/indexer_shadow + ROOT_DATABASE_URL: postgres://postgres:password@localhost:5432/postgres REGEN_API: http://localhost:1317 REGEN_RPC: http://localhost:26657 entrypoint: ["/bin/sh", "-c", "./docker/scripts/indexer_start.sh"] diff --git a/docker/indexer.Dockerfile b/docker/indexer.Dockerfile index 6908d98..44af46b 100644 --- a/docker/indexer.Dockerfile +++ b/docker/indexer.Dockerfile @@ -2,7 +2,7 @@ FROM python:3.9 # Install dependencies RUN apt-get update -RUN apt-get install libpq-dev postgresql-client python3-poetry -y +RUN apt-get install libpq-dev postgresql-client nodejs python3-poetry yarnpkg -y # Set working directory WORKDIR /home/indexer @@ -12,3 +12,4 @@ COPY . . # Install indexer RUN poetry install +RUN yarnpkg install diff --git a/docker/scripts/indexer_init.sh b/docker/scripts/indexer_init.sh index 2739906..19172c7 100755 --- a/docker/scripts/indexer_init.sh +++ b/docker/scripts/indexer_init.sh @@ -1,7 +1,10 @@ #!/bin/bash +psql "$DATABASE_URL" -c "CREATE DATABASE indexer" +psql "$DATABASE_URL" -c "CREATE DATABASE indexer_shadow" + # run migrations -(cd sql && ./run_all_migrations.sh) +yarnpkg run db-init # workaround for indexer starting with new chain psql "$DATABASE_URL" -c "INSERT INTO chain ( diff --git a/docker/tester.Dockerfile b/docker/tester.Dockerfile index b455c53..f15b56d 100644 --- a/docker/tester.Dockerfile +++ b/docker/tester.Dockerfile @@ -8,7 +8,7 @@ RUN apt-get install jq libpq-dev postgresql-client -y ENV GIT_CHECKOUT='v5.1.2' # Set database url -ENV DATABASE_URL='postgres://postgres:password@localhost:5432/postgres' +ENV DATABASE_URL='postgres://postgres:password@localhost:5432/indexer' # Set test addresses ENV TEST_USER_ADDRESS_1=regen1l2pwmzk96ftmmt5egpjulyqtneygmmzndf7csk diff --git a/migrations/README.md b/migrations/README.md new file mode 100644 index 0000000..1228d1e --- /dev/null +++ b/migrations/README.md @@ -0,0 +1,72 @@ +# Migrations + +This readme provides info about how to work with migrations in this repo. + +## Local development + +In order to develop this project locally we must use the following commands. +If this is your first time setting up the project locally, we need to initialize your database. +First, you must run the local database: + +``` +$ pwd +/Users/kyle/regen/indexer +$ docker-compose up --build postgres +``` + +Then, you must initialize the database: + +``` +$ export DATABASE_URL="postgres://postgres:postgres@localhost:5432/indexer" +$ export SHADOW_DATABASE_URL="postgres://postgres:postgres@localhost:5432/indexer_shadow" +$ export ROOT_DATABASE_URL="postgres://postgres:postgres@localhost:5432/postgres" +$ yarn run graphile-migrate reset --erase +``` + +Now, we set up a watch process that will monitor `migrations/current.sql` for your changes as well as apply them to your local database: + +``` +$ yarn run graphile-migrate watch +``` + +When you are satisfied with the changes in `migration/current.sql`, you commit them: + +``` +$ yarn run graphile-migrate commit +``` + +By committing your changes you should see a new SQL file in `migration/committed/`. + +## Schema Snapshot + +The schema snapshot is stored and tracked in version control as `migrations/schema_snapshot.sql`. +Each time you apply a migration in local development this snapshot will be automatically updated. +See `.gmrc` and `afterAllMigrations` from [the `graphile-migrate` configuration docs](https://github.com/graphile/migrate#configuration) for how this is done. +This allows us to keep track of the changes being introduced to the schema. +You must commit your changes to this file. + +This is a helpful file to keep in mind when you have questions about entities in the database. +For example, it allows you to also view the functions in the database being used in various RLS policies. +Similarly, you can view the various policies in the database or which tables have RLS enabled. + +## Deploying to staging or production + +The migrations are always automatically run in Heroku for staging and production. +See the `migrate` command in `package.json` and `Procfile` for Heroku. + +## Debugging + +This section contains some notes that may be useful for debugging common scenarios. + +### Viewing migrations applied in a particular database + +Our migration tool tracks which migrations have been applied in the following table: + +``` +regen_registry=# select * from graphile_migrate.migrations; + hash | previous_hash | filename | date +-----------------------------------------------+---------------+------------+------------------------------- + sha1:28ab5499d9a4520daa9428681a9bf1152f9887af | | 000001.sql | 2023-05-08 20:20:31.213547+00 +``` + +This is one way that you can track the migrations that will be deployed to staging or production. diff --git a/migrations/current.sql b/migrations/current.sql new file mode 100644 index 0000000..8da5339 --- /dev/null +++ b/migrations/current.sql @@ -0,0 +1 @@ +-- Enter migration here diff --git a/migrations/initial_schema.sql b/migrations/initial_schema.sql new file mode 100644 index 0000000..a8c9f15 --- /dev/null +++ b/migrations/initial_schema.sql @@ -0,0 +1,668 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 13.11 (Ubuntu 13.11-1.pgdg20.04+1) +-- Dumped by pg_dump version 14.9 (Homebrew) + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', 'public', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + + +-- +-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public; + + +-- +-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION pg_stat_statements IS 'track planning and execution statistics of all SQL statements executed'; + + +-- +-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public; + + +-- +-- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions'; + + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +-- +-- Name: tx; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.tx ( + chain_num smallint NOT NULL, + block_height bigint NOT NULL, + tx_idx smallint NOT NULL, + hash bytea NOT NULL, + data jsonb NOT NULL +); + + +-- +-- Name: all_ecocredit_txes(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.all_ecocredit_txes() RETURNS SETOF public.tx + LANGUAGE sql STABLE + AS $$ + select tx.* + from tx + natural join msg_event as me + where + data ->'tx_response'->'code' = '0' + and me.type like 'regen.ecocredit.%' + order by tx.block_height desc +$$; + + +-- +-- Name: block; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.block ( + chain_num smallint NOT NULL, + height bigint NOT NULL, + data jsonb NOT NULL, + "time" timestamp with time zone NOT NULL +); + + +-- +-- Name: chain; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.chain ( + num smallint NOT NULL, + chain_id text NOT NULL +); + + +-- +-- Name: chain_num_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.chain_num_seq + AS smallint + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: chain_num_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.chain_num_seq OWNED BY public.chain.num; + + +-- +-- Name: class_issuers; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.class_issuers ( + type text NOT NULL, + block_height bigint NOT NULL, + tx_idx smallint NOT NULL, + msg_idx smallint NOT NULL, + chain_num smallint NOT NULL, + "timestamp" timestamp with time zone, + tx_hash text NOT NULL, + class_id text NOT NULL, + issuer text NOT NULL, + latest boolean DEFAULT true NOT NULL +); + + +-- +-- Name: msg_event_attr; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.msg_event_attr ( + chain_num smallint NOT NULL, + block_height bigint NOT NULL, + tx_idx smallint NOT NULL, + msg_idx smallint NOT NULL, + type text NOT NULL, + key text NOT NULL, + value text NOT NULL, + value_hash bytea NOT NULL +); + + +-- +-- Name: event_retire_v1; Type: VIEW; Schema: public; Owner: - +-- + +CREATE VIEW public.event_retire_v1 AS + SELECT msg_event_attr.chain_num, + msg_event_attr.block_height, + msg_event_attr.tx_idx, + msg_event_attr.msg_idx, + max( + CASE + WHEN (msg_event_attr.key = 'owner'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS owner, + max( + CASE + WHEN (msg_event_attr.key = 'batch_denom'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS batch_denom, + max( + CASE + WHEN (msg_event_attr.key = 'amount'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS amount, + max( + CASE + WHEN (msg_event_attr.key = 'jurisdiction'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS jurisdiction, + max( + CASE + WHEN (msg_event_attr.key = 'reason'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS reason, + (sum( + CASE + WHEN (msg_event_attr.key = 'amount'::text) THEN 1 + ELSE 0 + END) > 1) AS has_duplicates + FROM public.msg_event_attr + WHERE (msg_event_attr.type ~~ 'regen.ecocredit.v1.EventRetire'::text) + GROUP BY msg_event_attr.chain_num, msg_event_attr.block_height, msg_event_attr.tx_idx, msg_event_attr.msg_idx; + + +-- +-- Name: event_retire_v1alpha1; Type: VIEW; Schema: public; Owner: - +-- + +CREATE VIEW public.event_retire_v1alpha1 AS + SELECT msg_event_attr.chain_num, + msg_event_attr.block_height, + msg_event_attr.tx_idx, + msg_event_attr.msg_idx, + max( + CASE + WHEN (msg_event_attr.key = 'retirer'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS retirer, + max( + CASE + WHEN (msg_event_attr.key = 'batch_denom'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS batch_denom, + max( + CASE + WHEN (msg_event_attr.key = 'amount'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS amount, + max( + CASE + WHEN (msg_event_attr.key = 'location'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS location, + (sum( + CASE + WHEN (msg_event_attr.key = 'amount'::text) THEN 1 + ELSE 0 + END) > 1) AS has_duplicates + FROM public.msg_event_attr + WHERE (msg_event_attr.type ~~ 'regen.ecocredit.v1alpha1.EventRetire'::text) + GROUP BY msg_event_attr.chain_num, msg_event_attr.block_height, msg_event_attr.tx_idx, msg_event_attr.msg_idx; + + +-- +-- Name: event_retire; Type: VIEW; Schema: public; Owner: - +-- + +CREATE VIEW public.event_retire AS + SELECT event_retire_v1.chain_num, + event_retire_v1.block_height, + event_retire_v1.tx_idx, + event_retire_v1.msg_idx, + event_retire_v1.owner, + event_retire_v1.batch_denom, + event_retire_v1.amount, + event_retire_v1.jurisdiction, + event_retire_v1.reason, + event_retire_v1.has_duplicates + FROM public.event_retire_v1 +UNION + SELECT event_retire_v1alpha1.chain_num, + event_retire_v1alpha1.block_height, + event_retire_v1alpha1.tx_idx, + event_retire_v1alpha1.msg_idx, + event_retire_v1alpha1.retirer AS owner, + event_retire_v1alpha1.batch_denom, + event_retire_v1alpha1.amount, + event_retire_v1alpha1.location AS jurisdiction, + ''::text AS reason, + event_retire_v1alpha1.has_duplicates + FROM public.event_retire_v1alpha1; + + +-- +-- Name: flyway_schema_history; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.flyway_schema_history ( + installed_rank integer NOT NULL, + version character varying(50), + description character varying(200) NOT NULL, + type character varying(20) NOT NULL, + script character varying(1000) NOT NULL, + checksum integer, + installed_by character varying(100) NOT NULL, + installed_on timestamp without time zone DEFAULT now() NOT NULL, + execution_time integer NOT NULL, + success boolean NOT NULL +); + + +-- +-- Name: msg; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.msg ( + chain_num smallint NOT NULL, + block_height bigint NOT NULL, + tx_idx smallint NOT NULL, + msg_idx smallint NOT NULL, + data jsonb NOT NULL +); + + +-- +-- Name: msg_event; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.msg_event ( + chain_num smallint NOT NULL, + block_height bigint NOT NULL, + tx_idx smallint NOT NULL, + msg_idx smallint NOT NULL, + type text NOT NULL +); + + +-- +-- Name: proposals; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.proposals ( + type text NOT NULL, + block_height bigint NOT NULL, + tx_idx smallint NOT NULL, + msg_idx smallint NOT NULL, + chain_num smallint NOT NULL, + "timestamp" timestamp with time zone, + tx_hash text NOT NULL, + proposal_id bigint NOT NULL, + status text NOT NULL, + group_policy_address text NOT NULL, + metadata text NOT NULL, + proposers text[] NOT NULL, + submit_time timestamp with time zone, + group_version bigint NOT NULL, + group_policy_version bigint NOT NULL, + final_tally_result jsonb NOT NULL, + voting_period_end timestamp with time zone NOT NULL, + executor_result text NOT NULL, + messages jsonb NOT NULL +); + + +-- +-- Name: retirements; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.retirements ( + type text NOT NULL, + amount text NOT NULL, + batch_denom text NOT NULL, + jurisdiction text NOT NULL, + owner text NOT NULL, + reason text NOT NULL, + "timestamp" timestamp with time zone, + block_height bigint NOT NULL, + chain_num smallint NOT NULL, + tx_idx smallint NOT NULL, + msg_idx smallint NOT NULL, + tx_hash text NOT NULL +); + + +-- +-- Name: votes; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.votes ( + type text NOT NULL, + block_height bigint NOT NULL, + tx_idx smallint NOT NULL, + msg_idx smallint NOT NULL, + chain_num smallint NOT NULL, + "timestamp" timestamp with time zone, + tx_hash text NOT NULL, + proposal_id bigint NOT NULL, + voter text NOT NULL, + option text NOT NULL, + metadata text NOT NULL, + submit_time timestamp with time zone NOT NULL +); + + +-- +-- Name: chain num; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.chain ALTER COLUMN num SET DEFAULT nextval('public.chain_num_seq'::regclass); + + +-- +-- Name: block block_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.block + ADD CONSTRAINT block_pkey PRIMARY KEY (chain_num, height); + + +-- +-- Name: chain chain_chain_id_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.chain + ADD CONSTRAINT chain_chain_id_key UNIQUE (chain_id); + + +-- +-- Name: chain chain_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.chain + ADD CONSTRAINT chain_pkey PRIMARY KEY (num); + + +-- +-- Name: class_issuers class_issuers_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.class_issuers + ADD CONSTRAINT class_issuers_pkey PRIMARY KEY (chain_num, block_height, tx_idx, msg_idx, class_id, issuer); + + +-- +-- Name: flyway_schema_history flyway_schema_history_pk; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.flyway_schema_history + ADD CONSTRAINT flyway_schema_history_pk PRIMARY KEY (installed_rank); + + +-- +-- Name: msg_event_attr msg_event_attr_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.msg_event_attr + ADD CONSTRAINT msg_event_attr_pkey PRIMARY KEY (chain_num, block_height, tx_idx, msg_idx, type, key, value_hash); + + +-- +-- Name: msg_event msg_event_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.msg_event + ADD CONSTRAINT msg_event_pkey PRIMARY KEY (chain_num, block_height, tx_idx, msg_idx, type); + + +-- +-- Name: msg msg_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.msg + ADD CONSTRAINT msg_pkey PRIMARY KEY (chain_num, block_height, tx_idx, msg_idx); + + +-- +-- Name: proposals proposals_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.proposals + ADD CONSTRAINT proposals_pkey PRIMARY KEY (chain_num, block_height, tx_idx, msg_idx); + + +-- +-- Name: retirements retirements_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.retirements + ADD CONSTRAINT retirements_pkey PRIMARY KEY (chain_num, block_height, tx_idx, msg_idx); + + +-- +-- Name: tx tx_hash_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.tx + ADD CONSTRAINT tx_hash_key UNIQUE (hash); + + +-- +-- Name: tx tx_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.tx + ADD CONSTRAINT tx_pkey PRIMARY KEY (chain_num, block_height, tx_idx); + + +-- +-- Name: votes votes_chain_num_proposal_id_voter_ux; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.votes + ADD CONSTRAINT votes_chain_num_proposal_id_voter_ux UNIQUE (chain_num, proposal_id, voter); + + +-- +-- Name: votes votes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.votes + ADD CONSTRAINT votes_pkey PRIMARY KEY (chain_num, block_height, tx_idx, msg_idx); + + +-- +-- Name: class_issuers_credit_class_id_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX class_issuers_credit_class_id_idx ON public.class_issuers USING btree (class_id); + + +-- +-- Name: class_issuers_issuer_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX class_issuers_issuer_idx ON public.class_issuers USING btree (issuer); + + +-- +-- Name: class_issuers_latest_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX class_issuers_latest_idx ON public.class_issuers USING btree (latest); + + +-- +-- Name: flyway_schema_history_s_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX flyway_schema_history_s_idx ON public.flyway_schema_history USING btree (success); + + +-- +-- Name: msg_event_attr_type_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX msg_event_attr_type_idx ON public.msg_event_attr USING btree (type); + + +-- +-- Name: msg_event_type_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX msg_event_type_idx ON public.msg_event USING btree (type); + + +-- +-- Name: msg_expr_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX msg_expr_idx ON public.msg USING gin (((data -> '@type'::text))); + + +-- +-- Name: proposals_group_policy_address_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX proposals_group_policy_address_idx ON public.proposals USING btree (group_policy_address); + + +-- +-- Name: proposals_proposal_id_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX proposals_proposal_id_idx ON public.proposals USING btree (proposal_id); + + +-- +-- Name: retirements_owner_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX retirements_owner_idx ON public.retirements USING btree (owner); + + +-- +-- Name: tx_data_tx_response_code_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX tx_data_tx_response_code_idx ON public.tx USING btree ((((data -> 'tx_response'::text) -> 'code'::text))); + + +-- +-- Name: votes_proposal_id_chain_num_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX votes_proposal_id_chain_num_idx ON public.votes USING btree (proposal_id, chain_num); + + +-- +-- Name: block block_chain_num_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.block + ADD CONSTRAINT block_chain_num_fkey FOREIGN KEY (chain_num) REFERENCES public.chain(num); + + +-- +-- Name: class_issuers class_issuers_chain_num_block_height_tx_idx_msg_idx_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.class_issuers + ADD CONSTRAINT class_issuers_chain_num_block_height_tx_idx_msg_idx_type_fkey FOREIGN KEY (chain_num, block_height, tx_idx, msg_idx, type) REFERENCES public.msg_event(chain_num, block_height, tx_idx, msg_idx, type); + + +-- +-- Name: msg msg_chain_num_block_height_tx_idx_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.msg + ADD CONSTRAINT msg_chain_num_block_height_tx_idx_fkey FOREIGN KEY (chain_num, block_height, tx_idx) REFERENCES public.tx(chain_num, block_height, tx_idx); + + +-- +-- Name: msg_event_attr msg_event_attr_chain_num_block_height_tx_idx_msg_idx_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.msg_event_attr + ADD CONSTRAINT msg_event_attr_chain_num_block_height_tx_idx_msg_idx_fkey FOREIGN KEY (chain_num, block_height, tx_idx, msg_idx) REFERENCES public.msg(chain_num, block_height, tx_idx, msg_idx); + + +-- +-- Name: msg_event msg_event_chain_num_block_height_tx_idx_msg_idx_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.msg_event + ADD CONSTRAINT msg_event_chain_num_block_height_tx_idx_msg_idx_fkey FOREIGN KEY (chain_num, block_height, tx_idx, msg_idx) REFERENCES public.msg(chain_num, block_height, tx_idx, msg_idx); + + +-- +-- Name: proposals proposals_chain_num_block_height_tx_idx_msg_idx_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.proposals + ADD CONSTRAINT proposals_chain_num_block_height_tx_idx_msg_idx_type_fkey FOREIGN KEY (chain_num, block_height, tx_idx, msg_idx, type) REFERENCES public.msg_event(chain_num, block_height, tx_idx, msg_idx, type); + + +-- +-- Name: retirements retirements_chain_num_block_height_tx_idx_msg_idx_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.retirements + ADD CONSTRAINT retirements_chain_num_block_height_tx_idx_msg_idx_type_fkey FOREIGN KEY (chain_num, block_height, tx_idx, msg_idx, type) REFERENCES public.msg_event(chain_num, block_height, tx_idx, msg_idx, type); + + +-- +-- Name: tx tx_chain_num_block_height_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.tx + ADD CONSTRAINT tx_chain_num_block_height_fkey FOREIGN KEY (chain_num, block_height) REFERENCES public.block(chain_num, height); + + +-- +-- Name: votes votes_chain_num_block_height_tx_idx_msg_idx_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.votes + ADD CONSTRAINT votes_chain_num_block_height_tx_idx_msg_idx_type_fkey FOREIGN KEY (chain_num, block_height, tx_idx, msg_idx, type) REFERENCES public.msg_event(chain_num, block_height, tx_idx, msg_idx, type); + + +-- +-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: - +-- + +REVOKE ALL ON SCHEMA public FROM postgres; +REVOKE ALL ON SCHEMA public FROM PUBLIC; + + +-- +-- PostgreSQL database dump complete +-- + diff --git a/migrations/schema_snapshot.sql b/migrations/schema_snapshot.sql new file mode 100644 index 0000000..a2f66ec --- /dev/null +++ b/migrations/schema_snapshot.sql @@ -0,0 +1,720 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 14.9 (Homebrew) +-- Dumped by pg_dump version 14.9 (Homebrew) + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +-- +-- Name: graphile_migrate; Type: SCHEMA; Schema: -; Owner: - +-- + +CREATE SCHEMA graphile_migrate; + + +-- +-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public; + + +-- +-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION pg_stat_statements IS 'track planning and execution statistics of all SQL statements executed'; + + +-- +-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public; + + +-- +-- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions'; + + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +-- +-- Name: tx; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.tx ( + chain_num smallint NOT NULL, + block_height bigint NOT NULL, + tx_idx smallint NOT NULL, + hash bytea NOT NULL, + data jsonb NOT NULL +); + + +-- +-- Name: all_ecocredit_txes(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.all_ecocredit_txes() RETURNS SETOF public.tx + LANGUAGE sql STABLE + AS $$ + select tx.* + from tx + natural join msg_event as me + where + data ->'tx_response'->'code' = '0' + and me.type like 'regen.ecocredit.%' + order by tx.block_height desc +$$; + + +-- +-- Name: current; Type: TABLE; Schema: graphile_migrate; Owner: - +-- + +CREATE TABLE graphile_migrate.current ( + filename text DEFAULT 'current.sql'::text NOT NULL, + content text NOT NULL, + date timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: migrations; Type: TABLE; Schema: graphile_migrate; Owner: - +-- + +CREATE TABLE graphile_migrate.migrations ( + hash text NOT NULL, + previous_hash text, + filename text NOT NULL, + date timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: block; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.block ( + chain_num smallint NOT NULL, + height bigint NOT NULL, + data jsonb NOT NULL, + "time" timestamp with time zone NOT NULL +); + + +-- +-- Name: chain; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.chain ( + num smallint NOT NULL, + chain_id text NOT NULL +); + + +-- +-- Name: chain_num_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.chain_num_seq + AS smallint + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: chain_num_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.chain_num_seq OWNED BY public.chain.num; + + +-- +-- Name: class_issuers; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.class_issuers ( + type text NOT NULL, + block_height bigint NOT NULL, + tx_idx smallint NOT NULL, + msg_idx smallint NOT NULL, + chain_num smallint NOT NULL, + "timestamp" timestamp with time zone, + tx_hash text NOT NULL, + class_id text NOT NULL, + issuer text NOT NULL, + latest boolean DEFAULT true NOT NULL +); + + +-- +-- Name: msg_event_attr; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.msg_event_attr ( + chain_num smallint NOT NULL, + block_height bigint NOT NULL, + tx_idx smallint NOT NULL, + msg_idx smallint NOT NULL, + type text NOT NULL, + key text NOT NULL, + value text NOT NULL, + value_hash bytea NOT NULL +); + + +-- +-- Name: event_retire_v1; Type: VIEW; Schema: public; Owner: - +-- + +CREATE VIEW public.event_retire_v1 AS + SELECT msg_event_attr.chain_num, + msg_event_attr.block_height, + msg_event_attr.tx_idx, + msg_event_attr.msg_idx, + max( + CASE + WHEN (msg_event_attr.key = 'owner'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS owner, + max( + CASE + WHEN (msg_event_attr.key = 'batch_denom'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS batch_denom, + max( + CASE + WHEN (msg_event_attr.key = 'amount'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS amount, + max( + CASE + WHEN (msg_event_attr.key = 'jurisdiction'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS jurisdiction, + max( + CASE + WHEN (msg_event_attr.key = 'reason'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS reason, + (sum( + CASE + WHEN (msg_event_attr.key = 'amount'::text) THEN 1 + ELSE 0 + END) > 1) AS has_duplicates + FROM public.msg_event_attr + WHERE (msg_event_attr.type ~~ 'regen.ecocredit.v1.EventRetire'::text) + GROUP BY msg_event_attr.chain_num, msg_event_attr.block_height, msg_event_attr.tx_idx, msg_event_attr.msg_idx; + + +-- +-- Name: event_retire_v1alpha1; Type: VIEW; Schema: public; Owner: - +-- + +CREATE VIEW public.event_retire_v1alpha1 AS + SELECT msg_event_attr.chain_num, + msg_event_attr.block_height, + msg_event_attr.tx_idx, + msg_event_attr.msg_idx, + max( + CASE + WHEN (msg_event_attr.key = 'retirer'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS retirer, + max( + CASE + WHEN (msg_event_attr.key = 'batch_denom'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS batch_denom, + max( + CASE + WHEN (msg_event_attr.key = 'amount'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS amount, + max( + CASE + WHEN (msg_event_attr.key = 'location'::text) THEN msg_event_attr.value + ELSE NULL::text + END) AS location, + (sum( + CASE + WHEN (msg_event_attr.key = 'amount'::text) THEN 1 + ELSE 0 + END) > 1) AS has_duplicates + FROM public.msg_event_attr + WHERE (msg_event_attr.type ~~ 'regen.ecocredit.v1alpha1.EventRetire'::text) + GROUP BY msg_event_attr.chain_num, msg_event_attr.block_height, msg_event_attr.tx_idx, msg_event_attr.msg_idx; + + +-- +-- Name: event_retire; Type: VIEW; Schema: public; Owner: - +-- + +CREATE VIEW public.event_retire AS + SELECT event_retire_v1.chain_num, + event_retire_v1.block_height, + event_retire_v1.tx_idx, + event_retire_v1.msg_idx, + event_retire_v1.owner, + event_retire_v1.batch_denom, + event_retire_v1.amount, + event_retire_v1.jurisdiction, + event_retire_v1.reason, + event_retire_v1.has_duplicates + FROM public.event_retire_v1 +UNION + SELECT event_retire_v1alpha1.chain_num, + event_retire_v1alpha1.block_height, + event_retire_v1alpha1.tx_idx, + event_retire_v1alpha1.msg_idx, + event_retire_v1alpha1.retirer AS owner, + event_retire_v1alpha1.batch_denom, + event_retire_v1alpha1.amount, + event_retire_v1alpha1.location AS jurisdiction, + ''::text AS reason, + event_retire_v1alpha1.has_duplicates + FROM public.event_retire_v1alpha1; + + +-- +-- Name: flyway_schema_history; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.flyway_schema_history ( + installed_rank integer NOT NULL, + version character varying(50), + description character varying(200) NOT NULL, + type character varying(20) NOT NULL, + script character varying(1000) NOT NULL, + checksum integer, + installed_by character varying(100) NOT NULL, + installed_on timestamp without time zone DEFAULT now() NOT NULL, + execution_time integer NOT NULL, + success boolean NOT NULL +); + + +-- +-- Name: msg; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.msg ( + chain_num smallint NOT NULL, + block_height bigint NOT NULL, + tx_idx smallint NOT NULL, + msg_idx smallint NOT NULL, + data jsonb NOT NULL +); + + +-- +-- Name: msg_event; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.msg_event ( + chain_num smallint NOT NULL, + block_height bigint NOT NULL, + tx_idx smallint NOT NULL, + msg_idx smallint NOT NULL, + type text NOT NULL +); + + +-- +-- Name: proposals; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.proposals ( + type text NOT NULL, + block_height bigint NOT NULL, + tx_idx smallint NOT NULL, + msg_idx smallint NOT NULL, + chain_num smallint NOT NULL, + "timestamp" timestamp with time zone, + tx_hash text NOT NULL, + proposal_id bigint NOT NULL, + status text NOT NULL, + group_policy_address text NOT NULL, + metadata text NOT NULL, + proposers text[] NOT NULL, + submit_time timestamp with time zone, + group_version bigint NOT NULL, + group_policy_version bigint NOT NULL, + final_tally_result jsonb NOT NULL, + voting_period_end timestamp with time zone NOT NULL, + executor_result text NOT NULL, + messages jsonb NOT NULL +); + + +-- +-- Name: retirements; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.retirements ( + type text NOT NULL, + amount text NOT NULL, + batch_denom text NOT NULL, + jurisdiction text NOT NULL, + owner text NOT NULL, + reason text NOT NULL, + "timestamp" timestamp with time zone, + block_height bigint NOT NULL, + chain_num smallint NOT NULL, + tx_idx smallint NOT NULL, + msg_idx smallint NOT NULL, + tx_hash text NOT NULL +); + + +-- +-- Name: votes; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.votes ( + type text NOT NULL, + block_height bigint NOT NULL, + tx_idx smallint NOT NULL, + msg_idx smallint NOT NULL, + chain_num smallint NOT NULL, + "timestamp" timestamp with time zone, + tx_hash text NOT NULL, + proposal_id bigint NOT NULL, + voter text NOT NULL, + option text NOT NULL, + metadata text NOT NULL, + submit_time timestamp with time zone NOT NULL +); + + +-- +-- Name: chain num; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.chain ALTER COLUMN num SET DEFAULT nextval('public.chain_num_seq'::regclass); + + +-- +-- Name: current current_pkey; Type: CONSTRAINT; Schema: graphile_migrate; Owner: - +-- + +ALTER TABLE ONLY graphile_migrate.current + ADD CONSTRAINT current_pkey PRIMARY KEY (filename); + + +-- +-- Name: migrations migrations_pkey; Type: CONSTRAINT; Schema: graphile_migrate; Owner: - +-- + +ALTER TABLE ONLY graphile_migrate.migrations + ADD CONSTRAINT migrations_pkey PRIMARY KEY (hash); + + +-- +-- Name: block block_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.block + ADD CONSTRAINT block_pkey PRIMARY KEY (chain_num, height); + + +-- +-- Name: chain chain_chain_id_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.chain + ADD CONSTRAINT chain_chain_id_key UNIQUE (chain_id); + + +-- +-- Name: chain chain_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.chain + ADD CONSTRAINT chain_pkey PRIMARY KEY (num); + + +-- +-- Name: class_issuers class_issuers_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.class_issuers + ADD CONSTRAINT class_issuers_pkey PRIMARY KEY (chain_num, block_height, tx_idx, msg_idx, class_id, issuer); + + +-- +-- Name: flyway_schema_history flyway_schema_history_pk; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.flyway_schema_history + ADD CONSTRAINT flyway_schema_history_pk PRIMARY KEY (installed_rank); + + +-- +-- Name: msg_event_attr msg_event_attr_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.msg_event_attr + ADD CONSTRAINT msg_event_attr_pkey PRIMARY KEY (chain_num, block_height, tx_idx, msg_idx, type, key, value_hash); + + +-- +-- Name: msg_event msg_event_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.msg_event + ADD CONSTRAINT msg_event_pkey PRIMARY KEY (chain_num, block_height, tx_idx, msg_idx, type); + + +-- +-- Name: msg msg_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.msg + ADD CONSTRAINT msg_pkey PRIMARY KEY (chain_num, block_height, tx_idx, msg_idx); + + +-- +-- Name: proposals proposals_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.proposals + ADD CONSTRAINT proposals_pkey PRIMARY KEY (chain_num, block_height, tx_idx, msg_idx); + + +-- +-- Name: retirements retirements_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.retirements + ADD CONSTRAINT retirements_pkey PRIMARY KEY (chain_num, block_height, tx_idx, msg_idx); + + +-- +-- Name: tx tx_hash_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.tx + ADD CONSTRAINT tx_hash_key UNIQUE (hash); + + +-- +-- Name: tx tx_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.tx + ADD CONSTRAINT tx_pkey PRIMARY KEY (chain_num, block_height, tx_idx); + + +-- +-- Name: votes votes_chain_num_proposal_id_voter_ux; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.votes + ADD CONSTRAINT votes_chain_num_proposal_id_voter_ux UNIQUE (chain_num, proposal_id, voter); + + +-- +-- Name: votes votes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.votes + ADD CONSTRAINT votes_pkey PRIMARY KEY (chain_num, block_height, tx_idx, msg_idx); + + +-- +-- Name: class_issuers_credit_class_id_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX class_issuers_credit_class_id_idx ON public.class_issuers USING btree (class_id); + + +-- +-- Name: class_issuers_issuer_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX class_issuers_issuer_idx ON public.class_issuers USING btree (issuer); + + +-- +-- Name: class_issuers_latest_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX class_issuers_latest_idx ON public.class_issuers USING btree (latest); + + +-- +-- Name: flyway_schema_history_s_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX flyway_schema_history_s_idx ON public.flyway_schema_history USING btree (success); + + +-- +-- Name: msg_event_attr_type_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX msg_event_attr_type_idx ON public.msg_event_attr USING btree (type); + + +-- +-- Name: msg_event_type_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX msg_event_type_idx ON public.msg_event USING btree (type); + + +-- +-- Name: msg_expr_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX msg_expr_idx ON public.msg USING gin (((data -> '@type'::text))); + + +-- +-- Name: proposals_group_policy_address_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX proposals_group_policy_address_idx ON public.proposals USING btree (group_policy_address); + + +-- +-- Name: proposals_proposal_id_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX proposals_proposal_id_idx ON public.proposals USING btree (proposal_id); + + +-- +-- Name: retirements_owner_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX retirements_owner_idx ON public.retirements USING btree (owner); + + +-- +-- Name: tx_data_tx_response_code_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX tx_data_tx_response_code_idx ON public.tx USING btree ((((data -> 'tx_response'::text) -> 'code'::text))); + + +-- +-- Name: votes_proposal_id_chain_num_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX votes_proposal_id_chain_num_idx ON public.votes USING btree (proposal_id, chain_num); + + +-- +-- Name: migrations migrations_previous_hash_fkey; Type: FK CONSTRAINT; Schema: graphile_migrate; Owner: - +-- + +ALTER TABLE ONLY graphile_migrate.migrations + ADD CONSTRAINT migrations_previous_hash_fkey FOREIGN KEY (previous_hash) REFERENCES graphile_migrate.migrations(hash); + + +-- +-- Name: block block_chain_num_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.block + ADD CONSTRAINT block_chain_num_fkey FOREIGN KEY (chain_num) REFERENCES public.chain(num); + + +-- +-- Name: class_issuers class_issuers_chain_num_block_height_tx_idx_msg_idx_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.class_issuers + ADD CONSTRAINT class_issuers_chain_num_block_height_tx_idx_msg_idx_type_fkey FOREIGN KEY (chain_num, block_height, tx_idx, msg_idx, type) REFERENCES public.msg_event(chain_num, block_height, tx_idx, msg_idx, type); + + +-- +-- Name: msg msg_chain_num_block_height_tx_idx_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.msg + ADD CONSTRAINT msg_chain_num_block_height_tx_idx_fkey FOREIGN KEY (chain_num, block_height, tx_idx) REFERENCES public.tx(chain_num, block_height, tx_idx); + + +-- +-- Name: msg_event_attr msg_event_attr_chain_num_block_height_tx_idx_msg_idx_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.msg_event_attr + ADD CONSTRAINT msg_event_attr_chain_num_block_height_tx_idx_msg_idx_fkey FOREIGN KEY (chain_num, block_height, tx_idx, msg_idx) REFERENCES public.msg(chain_num, block_height, tx_idx, msg_idx); + + +-- +-- Name: msg_event msg_event_chain_num_block_height_tx_idx_msg_idx_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.msg_event + ADD CONSTRAINT msg_event_chain_num_block_height_tx_idx_msg_idx_fkey FOREIGN KEY (chain_num, block_height, tx_idx, msg_idx) REFERENCES public.msg(chain_num, block_height, tx_idx, msg_idx); + + +-- +-- Name: proposals proposals_chain_num_block_height_tx_idx_msg_idx_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.proposals + ADD CONSTRAINT proposals_chain_num_block_height_tx_idx_msg_idx_type_fkey FOREIGN KEY (chain_num, block_height, tx_idx, msg_idx, type) REFERENCES public.msg_event(chain_num, block_height, tx_idx, msg_idx, type); + + +-- +-- Name: retirements retirements_chain_num_block_height_tx_idx_msg_idx_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.retirements + ADD CONSTRAINT retirements_chain_num_block_height_tx_idx_msg_idx_type_fkey FOREIGN KEY (chain_num, block_height, tx_idx, msg_idx, type) REFERENCES public.msg_event(chain_num, block_height, tx_idx, msg_idx, type); + + +-- +-- Name: tx tx_chain_num_block_height_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.tx + ADD CONSTRAINT tx_chain_num_block_height_fkey FOREIGN KEY (chain_num, block_height) REFERENCES public.block(chain_num, height); + + +-- +-- Name: votes votes_chain_num_block_height_tx_idx_msg_idx_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.votes + ADD CONSTRAINT votes_chain_num_block_height_tx_idx_msg_idx_type_fkey FOREIGN KEY (chain_num, block_height, tx_idx, msg_idx, type) REFERENCES public.msg_event(chain_num, block_height, tx_idx, msg_idx, type); + + +-- +-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: - +-- + +REVOKE ALL ON SCHEMA public FROM PUBLIC; + + +-- +-- PostgreSQL database dump complete +-- + diff --git a/package.json b/package.json new file mode 100644 index 0000000..86e6dd1 --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name": "indexer", + "version": "1.0.0", + "scripts": { + "migrate": "graphile-migrate migrate", + "db-init": "graphile-migrate reset --erase" + }, + "license": "Apache-2.0", + "dependencies": { + "graphile-migrate": "^1.4.1" + } +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..785e876 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,509 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@graphile/logger@^0.2.0": + version "0.2.0" + resolved "https://registry.yarnpkg.com/@graphile/logger/-/logger-0.2.0.tgz#e484ec420162157c6e6f0cfb080fa29ef3a714ba" + integrity sha512-jjcWBokl9eb1gVJ85QmoaQ73CQ52xAaOCF29ukRbYNl6lY+ts0ErTaDYOBlejcbUs2OpaiqYLO5uDhyLFzWw4w== + +"@types/json5@^0.0.30": + version "0.0.30" + resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.30.tgz#44cb52f32a809734ca562e685c6473b5754a7818" + integrity sha512-sqm9g7mHlPY/43fcSNrCYfOeX9zkTTK+euO5E6+CVijSMm5tTjkVdwdqRkY3ljjIAf8679vps5jKUoJBCLsMDA== + +"@types/node@*": + version "20.7.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.7.1.tgz#06d732ead0bd5ad978ef0ea9cbdeb24dc8717514" + integrity sha512-LT+OIXpp2kj4E2S/p91BMe+VgGX2+lfO+XTpfXhh+bCk2LkQtHZSub8ewFBMGP5ClysPjTDFa4sMI8Q3n4T0wg== + +"@types/node@^14.6.0": + version "14.18.63" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.63.tgz#1788fa8da838dbb5f9ea994b834278205db6ca2b" + integrity sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ== + +"@types/pg@>=6 <9": + version "8.10.3" + resolved "https://registry.yarnpkg.com/@types/pg/-/pg-8.10.3.tgz#39b3acba4f313a65c8fbb4b241fcb21cc1ba4126" + integrity sha512-BACzsw64lCZesclRpZGu55tnqgFAYcrCBP92xLh1KLypZLCOsvJTSTgaoFVTy3lCys/aZTQzfeDxtjwrvdzL2g== + dependencies: + "@types/node" "*" + pg-protocol "*" + pg-types "^4.0.1" + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-styles@^4.0.0, ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +anymatch@~3.1.2: + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +binary-extensions@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" + integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== + +braces@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +buffer-writer@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/buffer-writer/-/buffer-writer-2.0.0.tgz#ce7eb81a38f7829db09c873f2fbb792c0c98ec04" + integrity sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw== + +camelcase@^5.0.0: + version "5.3.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" + integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== + +chalk@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4" + integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +chokidar@^3.5.1: + version "3.5.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + +cliui@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1" + integrity sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^6.2.0" + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +decamelize@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + integrity sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA== + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +find-up@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" + integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== + dependencies: + locate-path "^5.0.0" + path-exists "^4.0.0" + +fsevents@~2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + +get-caller-file@^2.0.1: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +glob-parent@~5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +graphile-migrate@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/graphile-migrate/-/graphile-migrate-1.4.1.tgz#bd98d397310f0b68e5f5a8c7f050d9f2ba4409f9" + integrity sha512-yupLO7kPC8tPu9QjZbbd740bKvKjziZROhpsSVOBmIM4KKXpir9j1uOpekj6WzxQ+L1VlL3r/C6VgjYPP6QnqA== + dependencies: + "@graphile/logger" "^0.2.0" + "@types/json5" "^0.0.30" + "@types/node" "^14.6.0" + "@types/pg" ">=6 <9" + chalk "^3.0.0" + chokidar "^3.5.1" + json5 "^2.1.2" + pg ">=6.5 <9" + pg-connection-string "^2.1.0" + pg-minify "^1.5.2" + tslib "^1.10.0" + yargs "^15.3.1" + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +json5@^2.1.2: + version "2.2.3" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" + integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== + +locate-path@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" + integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== + dependencies: + p-locate "^4.1.0" + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +obuf@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/obuf/-/obuf-1.1.2.tgz#09bea3343d41859ebd446292d11c9d4db619084e" + integrity sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg== + +p-limit@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" + integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== + dependencies: + p-try "^2.0.0" + +p-locate@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" + integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== + dependencies: + p-limit "^2.2.0" + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + +packet-reader@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/packet-reader/-/packet-reader-1.0.0.tgz#9238e5480dedabacfe1fe3f2771063f164157d74" + integrity sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ== + +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + +pg-cloudflare@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/pg-cloudflare/-/pg-cloudflare-1.1.1.tgz#e6d5833015b170e23ae819e8c5d7eaedb472ca98" + integrity sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q== + +pg-connection-string@^2.1.0, pg-connection-string@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.6.2.tgz#713d82053de4e2bd166fab70cd4f26ad36aab475" + integrity sha512-ch6OwaeaPYcova4kKZ15sbJ2hKb/VP48ZD2gE7i1J+L4MspCtBMAx8nMgz7bksc7IojCIIWuEhHibSMFH8m8oA== + +pg-int8@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/pg-int8/-/pg-int8-1.0.1.tgz#943bd463bf5b71b4170115f80f8efc9a0c0eb78c" + integrity sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw== + +pg-minify@^1.5.2: + version "1.6.3" + resolved "https://registry.yarnpkg.com/pg-minify/-/pg-minify-1.6.3.tgz#3def4c876a2d258da20cfdb0e387373d41c7a4dc" + integrity sha512-NoSsPqXxbkD8RIe+peQCqiea4QzXgosdTKY8p7PsbbGsh2F8TifDj/vJxfuR8qJwNYrijdSs7uf0tAe6WOyCsQ== + +pg-numeric@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pg-numeric/-/pg-numeric-1.0.2.tgz#816d9a44026086ae8ae74839acd6a09b0636aa3a" + integrity sha512-BM/Thnrw5jm2kKLE5uJkXqqExRUY/toLHda65XgFTBTFYZyopbKjBe29Ii3RbkvlsMoFwD+tHeGaCjjv0gHlyw== + +pg-pool@^3.6.1: + version "3.6.1" + resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.6.1.tgz#5a902eda79a8d7e3c928b77abf776b3cb7d351f7" + integrity sha512-jizsIzhkIitxCGfPRzJn1ZdcosIt3pz9Sh3V01fm1vZnbnCMgmGl5wvGGdNN2EL9Rmb0EcFoCkixH4Pu+sP9Og== + +pg-protocol@*, pg-protocol@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.6.0.tgz#4c91613c0315349363af2084608db843502f8833" + integrity sha512-M+PDm637OY5WM307051+bsDia5Xej6d9IR4GwJse1qA1DIhiKlksvrneZOYQq42OM+spubpcNYEo2FcKQrDk+Q== + +pg-types@^2.1.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-2.2.0.tgz#2d0250d636454f7cfa3b6ae0382fdfa8063254a3" + integrity sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA== + dependencies: + pg-int8 "1.0.1" + postgres-array "~2.0.0" + postgres-bytea "~1.0.0" + postgres-date "~1.0.4" + postgres-interval "^1.1.0" + +pg-types@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-4.0.1.tgz#31857e89d00a6c66b06a14e907c3deec03889542" + integrity sha512-hRCSDuLII9/LE3smys1hRHcu5QGcLs9ggT7I/TCs0IE+2Eesxi9+9RWAAwZ0yaGjxoWICF/YHLOEjydGujoJ+g== + dependencies: + pg-int8 "1.0.1" + pg-numeric "1.0.2" + postgres-array "~3.0.1" + postgres-bytea "~3.0.0" + postgres-date "~2.0.1" + postgres-interval "^3.0.0" + postgres-range "^1.1.1" + +"pg@>=6.5 <9": + version "8.11.3" + resolved "https://registry.yarnpkg.com/pg/-/pg-8.11.3.tgz#d7db6e3fe268fcedd65b8e4599cda0b8b4bf76cb" + integrity sha512-+9iuvG8QfaaUrrph+kpF24cXkH1YOOUeArRNYIxq1viYHZagBxrTno7cecY1Fa44tJeZvaoG+Djpkc3JwehN5g== + dependencies: + buffer-writer "2.0.0" + packet-reader "1.0.0" + pg-connection-string "^2.6.2" + pg-pool "^3.6.1" + pg-protocol "^1.6.0" + pg-types "^2.1.0" + pgpass "1.x" + optionalDependencies: + pg-cloudflare "^1.1.1" + +pgpass@1.x: + version "1.0.5" + resolved "https://registry.yarnpkg.com/pgpass/-/pgpass-1.0.5.tgz#9b873e4a564bb10fa7a7dbd55312728d422a223d" + integrity sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug== + dependencies: + split2 "^4.1.0" + +picomatch@^2.0.4, picomatch@^2.2.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +postgres-array@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/postgres-array/-/postgres-array-2.0.0.tgz#48f8fce054fbc69671999329b8834b772652d82e" + integrity sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA== + +postgres-array@~3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/postgres-array/-/postgres-array-3.0.2.tgz#68d6182cb0f7f152a7e60dc6a6889ed74b0a5f98" + integrity sha512-6faShkdFugNQCLwucjPcY5ARoW1SlbnrZjmGl0IrrqewpvxvhSLHimCVzqeuULCbG0fQv7Dtk1yDbG3xv7Veog== + +postgres-bytea@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/postgres-bytea/-/postgres-bytea-1.0.0.tgz#027b533c0aa890e26d172d47cf9ccecc521acd35" + integrity sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w== + +postgres-bytea@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/postgres-bytea/-/postgres-bytea-3.0.0.tgz#9048dc461ac7ba70a6a42d109221619ecd1cb089" + integrity sha512-CNd4jim9RFPkObHSjVHlVrxoVQXz7quwNFpz7RY1okNNme49+sVyiTvTRobiLV548Hx/hb1BG+iE7h9493WzFw== + dependencies: + obuf "~1.1.2" + +postgres-date@~1.0.4: + version "1.0.7" + resolved "https://registry.yarnpkg.com/postgres-date/-/postgres-date-1.0.7.tgz#51bc086006005e5061c591cee727f2531bf641a8" + integrity sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q== + +postgres-date@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/postgres-date/-/postgres-date-2.0.1.tgz#638b62e5c33764c292d37b08f5257ecb09231457" + integrity sha512-YtMKdsDt5Ojv1wQRvUhnyDJNSr2dGIC96mQVKz7xufp07nfuFONzdaowrMHjlAzY6GDLd4f+LUHHAAM1h4MdUw== + +postgres-interval@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/postgres-interval/-/postgres-interval-1.2.0.tgz#b460c82cb1587507788819a06aa0fffdb3544695" + integrity sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ== + dependencies: + xtend "^4.0.0" + +postgres-interval@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/postgres-interval/-/postgres-interval-3.0.0.tgz#baf7a8b3ebab19b7f38f07566c7aab0962f0c86a" + integrity sha512-BSNDnbyZCXSxgA+1f5UU2GmwhoI0aU5yMxRGO8CdFEcY2BQF9xm/7MqKnYoM1nJDk8nONNWDk9WeSmePFhQdlw== + +postgres-range@^1.1.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/postgres-range/-/postgres-range-1.1.3.tgz#9ccd7b01ca2789eb3c2e0888b3184225fa859f76" + integrity sha512-VdlZoocy5lCP0c/t66xAfclglEapXPCIVhqqJRncYpvbCgImF0w67aPKfbqUMr72tO2k5q0TdTZwCLjPTI6C9g== + +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== + dependencies: + picomatch "^2.2.1" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== + +require-main-filename@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" + integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== + +set-blocking@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + integrity sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw== + +split2@^4.1.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/split2/-/split2-4.2.0.tgz#c9c5920904d148bab0b9f67145f245a86aadbfa4" + integrity sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg== + +string-width@^4.1.0, string-width@^4.2.0: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +tslib@^1.10.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" + integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== + +which-module@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.1.tgz#776b1fe35d90aebe99e8ac15eb24093389a4a409" + integrity sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ== + +wrap-ansi@^6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53" + integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +xtend@^4.0.0: + version "4.0.2" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" + integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== + +y18n@^4.0.0: + version "4.0.3" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf" + integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ== + +yargs-parser@^18.1.2: + version "18.1.3" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" + integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ== + dependencies: + camelcase "^5.0.0" + decamelize "^1.2.0" + +yargs@^15.3.1: + version "15.4.1" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8" + integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A== + dependencies: + cliui "^6.0.0" + decamelize "^1.2.0" + find-up "^4.1.0" + get-caller-file "^2.0.1" + require-directory "^2.1.1" + require-main-filename "^2.0.0" + set-blocking "^2.0.0" + string-width "^4.2.0" + which-module "^2.0.0" + y18n "^4.0.0" + yargs-parser "^18.1.2"