diff --git a/Makefile b/Makefile index 25108217..927ae78e 100644 --- a/Makefile +++ b/Makefile @@ -41,8 +41,8 @@ apidiff:: open http://localhost:1323/apidiff.html test-schema:: - @set -a; \ - writeDbUrl=postgresql://postgres:example@localhost:21300/postgres; \ + @set -a -e; \ + writeDbUrl='postgresql://postgres:example@localhost:21300/postgres?sslmode=disable'; \ echo "\033[0;32mBringing down any existing containers to start fresh...\033[0m"; \ docker compose down --volumes; \ docker compose up -d --wait; \ diff --git a/ddl/migrations/0236_saves_reposts_album_to_playlist.sql b/ddl/migrations/0236_saves_reposts_album_to_playlist.sql new file mode 100644 index 00000000..837e1418 --- /dev/null +++ b/ddl/migrations/0236_saves_reposts_album_to_playlist.sql @@ -0,0 +1,164 @@ +-- Collapse save_type / repost_type 'album' back into 'playlist'. +-- +-- An album is a playlist with is_album = true. The indexer briefly derived a +-- separate 'album' type by reading playlists.is_album at index time — a side +-- effect of a fix for entity-id collisions, live from 2026-05-28. It no longer +-- does (OpenAudio/go-openaudio#428). is_album is mutable while save_type is +-- written once, so the same chain history indexed at different times produced +-- different rows. Nothing reads the distinction: every consumer is +-- track / not-track, or ORs the two together. +-- +-- THE BINDING CONSTRAINT IS NOT THE PRIMARY KEY. saves_pkey is +-- (user_id, save_item_id, save_type, txhash) and no two rows collide on it. But +-- pkg/etl migration 0030 also added +-- +-- saves_current_uniq_idx ON saves (user_id, save_item_id, save_type) WHERE is_current +-- reposts_current_uniq_idx ON reposts (user_id, repost_item_id, repost_type) WHERE is_current +-- +-- which carry no txhash. Two current rows for the same (user, item) are legal +-- today precisely because one is 'album' and one is 'playlist'; collapsing the +-- type makes them duplicates. A blind UPDATE therefore aborts with +-- +-- duplicate key value violates unique constraint "saves_current_uniq_idx" +-- +-- taking the whole pre-roll migrate Job with it. 43 save pairs and 34 repost +-- pairs collide this way, so the pairs are resolved first and the remainder +-- retyped. +-- +-- Winner is the highest blocknumber. Verified against a production clone that +-- this is decidable wherever it matters: of the 43 save pairs, 38 agree on +-- is_delete (either row would do) and 5 disagree — and in every disagreeing +-- pair the blocknumbers differ, with the later row holding the correct state +-- (e.g. user 9014 unfavourited item 613011280 in 2026; the newer row is the +-- delete). Blocknumber ties occur only among pairs that agree, where the choice +-- is immaterial: zero rows both disagree and tie. Reposts are the same shape — +-- 33 agree, 1 disagrees, no tie coincides with a disagreement. The created_at / +-- type tiebreaks below are therefore never load-bearing; they exist only to +-- make the statement deterministic. +-- +-- Losers are demoted, not deleted: unlike users these tables do keep superseded +-- history (344 saves, 161 reposts on the clone), so is_current = false is the +-- shape they already use. +-- +-- Aggregates: this is a net correction. reconcile_aggregates counts these rows +-- with count(*) and ORs both types, so every colliding pair has been +-- double-counting aggregate_playlist.save_count / repost_count. +-- +-- Triggers: on_save / on_repost are suppressed for the whole operation. Their +-- notification group_id embeds the type ('save::type:'), so both +-- the demote and the retype would emit fresh favourite/repost notifications +-- that ON CONFLICT could not dedupe against the existing ':type:album' rows. +-- trg_saves / trg_reposts stay enabled so the search indexer sees the change. +-- Aggregate counts are unaffected by the retype either way: handle_save's delta +-- is transition-aware and evaluates to 0 when is_delete does not change. +-- +-- ALTER TABLE ... DISABLE TRIGGER takes ShareRowExclusiveLock — it blocks +-- concurrent writes but not reads, and is held until commit. Blocking writers +-- is the property we want: they wait rather than silently running trigger-free. +-- Each table gets its own transaction so the two locks are never held at once. +-- +-- The DO blocks guard on the trigger existing: pg_migrate.sh applies +-- migrations/ before functions/, so on a database bootstrapped from ddl/ alone +-- these triggers do not exist yet. +-- +-- Re-running is a no-op once no 'album' rows remain. + +BEGIN; +SET LOCAL lock_timeout = '5s'; + +DO $$ +BEGIN + IF EXISTS (SELECT 1 FROM pg_trigger + WHERE tgrelid = 'saves'::regclass AND tgname = 'on_save' AND NOT tgisinternal) THEN + ALTER TABLE saves DISABLE TRIGGER on_save; + END IF; +END $$; + +-- 1. demote the older row of each (user, item) pair holding both types +WITH ranked AS ( + SELECT + user_id, save_item_id, save_type, txhash, + row_number() OVER ( + PARTITION BY user_id, save_item_id + ORDER BY blocknumber DESC NULLS LAST, created_at DESC NULLS LAST, save_type DESC + ) AS rn + FROM saves + WHERE is_current = true + AND save_type IN ('playlist', 'album') + AND (user_id, save_item_id) IN ( + SELECT user_id, save_item_id FROM saves + WHERE is_current = true AND save_type IN ('playlist', 'album') + GROUP BY user_id, save_item_id + HAVING count(DISTINCT save_type) > 1 + ) +) +UPDATE saves s +SET is_current = false +FROM ranked r +WHERE s.user_id = r.user_id + AND s.save_item_id = r.save_item_id + AND s.save_type = r.save_type + AND s.txhash = r.txhash + AND r.rn > 1; + +-- 2. retype the survivors +UPDATE saves SET save_type = 'playlist' WHERE is_current = true AND save_type = 'album'; + +DO $$ +BEGIN + IF EXISTS (SELECT 1 FROM pg_trigger + WHERE tgrelid = 'saves'::regclass AND tgname = 'on_save' AND NOT tgisinternal) THEN + ALTER TABLE saves ENABLE TRIGGER on_save; + END IF; +END $$; + +COMMIT; + +BEGIN; +SET LOCAL lock_timeout = '5s'; + +DO $$ +BEGIN + IF EXISTS (SELECT 1 FROM pg_trigger + WHERE tgrelid = 'reposts'::regclass AND tgname = 'on_repost' AND NOT tgisinternal) THEN + ALTER TABLE reposts DISABLE TRIGGER on_repost; + END IF; +END $$; + +WITH ranked AS ( + SELECT + user_id, repost_item_id, repost_type, txhash, + row_number() OVER ( + PARTITION BY user_id, repost_item_id + ORDER BY blocknumber DESC NULLS LAST, created_at DESC NULLS LAST, repost_type DESC + ) AS rn + FROM reposts + WHERE is_current = true + AND repost_type IN ('playlist', 'album') + AND (user_id, repost_item_id) IN ( + SELECT user_id, repost_item_id FROM reposts + WHERE is_current = true AND repost_type IN ('playlist', 'album') + GROUP BY user_id, repost_item_id + HAVING count(DISTINCT repost_type) > 1 + ) +) +UPDATE reposts s +SET is_current = false +FROM ranked r +WHERE s.user_id = r.user_id + AND s.repost_item_id = r.repost_item_id + AND s.repost_type = r.repost_type + AND s.txhash = r.txhash + AND r.rn > 1; + +UPDATE reposts SET repost_type = 'playlist' WHERE is_current = true AND repost_type = 'album'; + +DO $$ +BEGIN + IF EXISTS (SELECT 1 FROM pg_trigger + WHERE tgrelid = 'reposts'::regclass AND tgname = 'on_repost' AND NOT tgisinternal) THEN + ALTER TABLE reposts ENABLE TRIGGER on_repost; + END IF; +END $$; + +COMMIT; diff --git a/ddl/migrations/0237_users_one_current_row_backfill.sql b/ddl/migrations/0237_users_one_current_row_backfill.sql new file mode 100644 index 00000000..606da9c5 --- /dev/null +++ b/ddl/migrations/0237_users_one_current_row_backfill.sql @@ -0,0 +1,77 @@ +-- Remove duplicate is_current rows from users. +-- +-- users_pkey is (user_id, txhash), which admits a second is_current row under a +-- different txhash. Five users have one, spread from 2025-06 to 2026-06 — a +-- slow drip, not a one-off. Each pair shares created_at and sits a few blocks +-- apart. +-- +-- How is not established. Both indexer create paths reject an existing user +-- (validateUserCreate and migratedUserCreateHandler both call userExists, which +-- tests is_current), so a single writer cannot produce these: its check and its +-- insert share a transaction. A second writer can, since check-then-act is not +-- atomic across transactions. Three of the five pairs put a bare-hex txhash +-- next to a 0x-prefixed one, which fits that reading without proving it. +-- +-- Five rows, but the blast radius is not five rows: anything joining an entity +-- to its owner's wallet fans out and silently duplicates every entity those +-- users own — measured at 18 extra tracks and 787 extra follows on a clone. +-- +-- This is the backfill half of pkg/etl migration 0035, which adds +-- users_current_uniq_idx to stop it recurring. That index cannot be created +-- while duplicates exist, so this must run first. It does: ddl migrations run +-- in the pre-roll `migrate` Job that every serving Deployment depends on, while +-- the ETL's run at indexer start, after the Job has completed. The delete lives +-- here rather than in the ETL migration so that bumping a Go module can never +-- silently remove rows from this database. +-- +-- Deleted rather than demoted: users keeps no versioned history — the indexer +-- writes it in place, and production has zero is_current = false rows — so +-- demoting would leave a category of row nothing reads. Deleting is safe here: +-- no foreign key references users, and its triggers are INSERT (on_user) or +-- INSERT OR UPDATE (trg_users), so neither fires. +-- +-- Winner is the highest blocknumber, matching how consumers already pick the +-- live row. Verified against a production clone: in all five cases blocknumber +-- and updated_at agree, and for user 666149592 it keeps is_deactivated = true, +-- the later of that pair's two states. Re-running is a no-op. + +BEGIN; +SET LOCAL lock_timeout = '5s'; + +-- Restricted to the offending user_ids so row_number() is computed over a +-- handful of rows rather than all 3.15M current ones. Identifying them still +-- costs a scan of users: this runs before users_current_uniq_idx exists (that +-- is pkg/etl 0035, which runs later, at indexer start) and no other index +-- covers is_current. A few seconds in a one-time pre-roll migration, and it +-- takes only RowExclusiveLock, so concurrent DML is not blocked. +-- +-- txhash is compared under the C collation so the tiebreak cannot vary with +-- database collation. It never fires in practice — blocknumber decides every +-- real case — but should be deterministic if it ever does. +WITH dupes AS MATERIALIZED ( + SELECT user_id + FROM users + WHERE is_current = true + GROUP BY user_id + HAVING count(*) > 1 +), +ranked AS ( + SELECT + user_id, + txhash, + row_number() OVER ( + PARTITION BY user_id + ORDER BY blocknumber DESC NULLS LAST, updated_at DESC NULLS LAST, + txhash COLLATE "C" DESC + ) AS rn + FROM users + WHERE is_current = true + AND user_id IN (SELECT user_id FROM dupes) +) +DELETE FROM users u +USING ranked r +WHERE u.user_id = r.user_id + AND u.txhash = r.txhash + AND r.rn > 1; + +COMMIT; diff --git a/go.mod b/go.mod index a36d4571..189d16bd 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/AlecAivazis/survey/v2 v2.3.7 github.com/Doist/unfurlist v0.0.0-20250409100812-515f2735f8e5 github.com/OpenAudio/go-openaudio v1.8.2-0.20260727214803-1d9f69772e87 - github.com/OpenAudio/go-openaudio/pkg/etl v1.6.3-0.20260727214803-1d9f69772e87 + github.com/OpenAudio/go-openaudio/pkg/etl v1.6.4 github.com/aquasecurity/esquery v0.2.0 github.com/axiomhq/axiom-go v0.23.0 github.com/axiomhq/hyperloglog v0.2.5 @@ -45,6 +45,7 @@ require ( github.com/urfave/cli/v3 v3.5.0 go.uber.org/zap v1.27.0 golang.org/x/crypto v0.48.0 + golang.org/x/net v0.50.0 golang.org/x/sync v0.19.0 google.golang.org/grpc v1.71.1 google.golang.org/protobuf v1.36.11 @@ -219,7 +220,6 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/ratelimit v0.2.0 // indirect golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect - golang.org/x/net v0.50.0 // indirect golang.org/x/sys v0.41.0 // indirect golang.org/x/term v0.40.0 // indirect golang.org/x/text v0.34.0 // indirect diff --git a/go.sum b/go.sum index 14f5f9bf..bf99cd52 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEV github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OpenAudio/go-openaudio v1.8.2-0.20260727214803-1d9f69772e87 h1:HiLw4qrUkVWRADJjGsdHLlFMdJjhU5WCVNAfeKfww4s= github.com/OpenAudio/go-openaudio v1.8.2-0.20260727214803-1d9f69772e87/go.mod h1:lLRvUF5oWkxOyZx8rp/ecqxuMo3yzPvuvJbLSfvxguQ= -github.com/OpenAudio/go-openaudio/pkg/etl v1.6.3-0.20260727214803-1d9f69772e87 h1:E3HoYAxTNrZ0x1H+PJ+sijy1yh3jMtnO6JTyZqWHJ9U= -github.com/OpenAudio/go-openaudio/pkg/etl v1.6.3-0.20260727214803-1d9f69772e87/go.mod h1:6MIJhF06djJvPl6sfv3Vqp0f4IsyBsWPB4F+BsIamTc= +github.com/OpenAudio/go-openaudio/pkg/etl v1.6.4 h1:SkKNhfvPWOlEGBw6i1LvAF1iNA0Gdf5rf/9izr2Kbro= +github.com/OpenAudio/go-openaudio/pkg/etl v1.6.4/go.mod h1:z7X/5RziXEpASGTz7tD+P3pg4W5iCA1cKW7ogw8GShY= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= diff --git a/indexer/indexer.go b/indexer/indexer.go index 4e458296..77c6f7ba 100644 --- a/indexer/indexer.go +++ b/indexer/indexer.go @@ -53,12 +53,27 @@ func NewIndexer(cfg config.Config) *CoreIndexer { aggregatesCalculator := NewAggregatesCalculator(cfg) // ETL needs the Connect/gRPC Core client (for block fetching) and a DB URL. - // SkipMigrations stays false (default): ETL's migrations are idempotent - // against api/'s schema — every migration uses CREATE TABLE IF NOT EXISTS / - // ADD COLUMN IF NOT EXISTS, and tracks state in its own `etl_db_migrations` - // table separate from api/'s `schema_version`. Verified by applying all 21 - // current ETL migrations to a fresh DB seeded with api/'s schema: zero - // errors, only NOTICE messages for already-existing relations. + // SkipMigrations stays false (default), so bumping the pkg/etl module runs + // whatever migrations it brought with it against api/'s database, on the + // next indexer start. They track state in their own `etl_db_migrations` + // table, separate from api/'s `schema_version`, and only up-migrations run + // (RunDownMigrations is left false). + // + // None of them touches row data, which is the line being held: a module bump + // reaches this database automatically, so anything that repairs data belongs + // in ddl/, where it goes through review and the pre-roll migrate Job. 0035 + // is the worked example — it adds users_current_uniq_idx, while the delete + // that makes that index creatable lives in ddl 0237. + // + // They are not, however, purely additive: 0026 drops a constraint and 0027 + // drops and recreates playlist_seen's primary key. A bump can alter the + // schema here, so read what a version brings before taking it. + // + // The corollary is that an ETL migration can depend on a ddl one having + // run. 0035 fails with a unique violation if ddl 0237 has not removed the + // duplicates yet, which would stop the indexer starting. That ordering + // holds because ddl migrations run in the pre-roll Job that every serving + // Deployment depends on, and the ETL's run later, at indexer start. // // Two optional ETL components are disabled here because they don't fit // api/'s deployment: diff --git a/main.go b/main.go index cb0695d7..f2bc159e 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,9 @@ import ( "api.audius.co/esindexer" eth_indexer "api.audius.co/eth/indexer" core_indexer "api.audius.co/indexer" + "api.audius.co/logging" solana_indexer "api.audius.co/solana/indexer" + etldb "github.com/OpenAudio/go-openaudio/pkg/etl/db" ) func main() { @@ -108,7 +110,29 @@ func main() { } case "migrate": { - // no-op, handled prior to switch/case + // ddl migrations already ran above. Apply the ETL module's too, so a + // database migrated by this command matches a deployed one. + // + // They are otherwise only ever applied at indexer start, which left + // `make test-schema` unable to produce them: that target seeds from + // sql/01_schema.sql, runs this command, and dumps the result, so + // ETL-created objects could never enter the loop no matter how often + // it was regenerated. The four partial unique indexes from pkg/etl + // 0030 were consequently absent under test while present in every + // deployment — which is how ddl 0236 came to be written against the + // wrong constraint and still passed CI. + // + // Ordering is the useful side effect: ddl migrations run before these, + // in one process, so a ddl migration that has to precede an ETL one + // (0237 before 0035) is sequenced here rather than across two pods. + // + // Idempotent and tracked separately in etl_db_migrations, so the + // indexer applying them again at startup is a no-op. + logger := logging.NewZapLogger(config.Cfg).Named("migrate") + if err := etldb.RunMigrations(logger, config.Cfg.WriteDbUrl, false); err != nil { + fmt.Println("etl migration failed:", err) + os.Exit(1) + } os.Exit(0) } default: diff --git a/sql/01_schema.sql b/sql/01_schema.sql index b946a522..8ec65688 100644 --- a/sql/01_schema.sql +++ b/sql/01_schema.sql @@ -129,6 +129,17 @@ CREATE TYPE public.delist_user_reason AS ENUM ( ); +-- +-- Name: etl_proof_status; Type: TYPE; Schema: public; Owner: - +-- + +CREATE TYPE public.etl_proof_status AS ENUM ( + 'unresolved', + 'pass', + 'fail' +); + + -- -- Name: event_entity_type; Type: TYPE; Schema: public; Owner: - -- @@ -5810,6 +5821,44 @@ END; $$; +-- +-- Name: notify_new_block(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.notify_new_block() RETURNS trigger + LANGUAGE plpgsql + AS $$ +begin + perform pg_notify('new_block', json_build_object( + 'block_height', new.block_height, + 'proposer_address', new.proposer_address + )::text); + return new; +end; +$$; + + +-- +-- Name: notify_new_plays(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.notify_new_plays() RETURNS trigger + LANGUAGE plpgsql + AS $$ +begin + perform pg_notify('new_plays', json_build_object( + 'user_id', new.user_id, + 'track_id', new.track_id, + 'city', new.city, + 'region', new.region, + 'country', new.country, + 'block_height', new.block_height + )::text); + return new; +end; +$$; + + -- -- Name: notify_pending_purchase_revalidation(); Type: FUNCTION; Schema: public; Owner: - -- @@ -8403,162 +8452,145 @@ COMMENT ON TABLE public.eth_wallet_balances IS 'AUDIO ERC-20 balances (in wei) f -- --- Name: event_routes; Type: TABLE; Schema: public; Owner: - +-- Name: etl_addresses; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.event_routes ( - slug character varying NOT NULL, - owner_id integer NOT NULL, - event_id integer NOT NULL, - is_current boolean NOT NULL, - blockhash character varying NOT NULL, - blocknumber integer NOT NULL, - txhash character varying NOT NULL +CREATE TABLE public.etl_addresses ( + id integer NOT NULL, + address text NOT NULL, + pub_key bytea, + first_seen_block_height bigint, + created_at timestamp without time zone NOT NULL ); -- --- Name: events; Type: TABLE; Schema: public; Owner: - +-- Name: etl_addresses_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE TABLE public.events ( - event_id integer NOT NULL, - event_type public.event_type NOT NULL, - user_id integer NOT NULL, - entity_type public.event_entity_type, - entity_id integer, - end_date timestamp without time zone, - is_deleted boolean DEFAULT false, - event_data jsonb, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - txhash text NOT NULL, - blockhash text NOT NULL, - blocknumber integer -); +CREATE SEQUENCE public.etl_addresses_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; -- --- Name: follows; Type: TABLE; Schema: public; Owner: - +-- Name: etl_addresses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -CREATE TABLE public.follows ( - blockhash character varying, - blocknumber integer, - follower_user_id integer NOT NULL, - followee_user_id integer NOT NULL, - is_current boolean NOT NULL, - is_delete boolean NOT NULL, - created_at timestamp without time zone NOT NULL, - txhash character varying DEFAULT ''::character varying NOT NULL, - slot integer -); +ALTER SEQUENCE public.etl_addresses_id_seq OWNED BY public.etl_addresses.id; -- --- Name: grants; Type: TABLE; Schema: public; Owner: - +-- Name: etl_blocks; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.grants ( - blockhash character varying, - blocknumber integer, - grantee_address character varying NOT NULL, - user_id integer NOT NULL, - is_revoked boolean DEFAULT false NOT NULL, - is_current boolean NOT NULL, - is_approved boolean, - updated_at timestamp without time zone NOT NULL, - created_at timestamp without time zone NOT NULL, - txhash character varying NOT NULL +CREATE TABLE public.etl_blocks ( + id integer NOT NULL, + proposer_address text NOT NULL, + block_height bigint NOT NULL, + block_time timestamp without time zone NOT NULL ); -- --- Name: hourly_play_counts; Type: TABLE; Schema: public; Owner: - +-- Name: etl_blocks_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE TABLE public.hourly_play_counts ( - hourly_timestamp timestamp without time zone NOT NULL, - play_count integer NOT NULL -); +CREATE SEQUENCE public.etl_blocks_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; -- --- Name: indexing_checkpoints; Type: TABLE; Schema: public; Owner: - +-- Name: etl_blocks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -CREATE TABLE public.indexing_checkpoints ( - tablename character varying NOT NULL, - last_checkpoint integer NOT NULL, - signature character varying +ALTER SEQUENCE public.etl_blocks_id_seq OWNED BY public.etl_blocks.id; + + +-- +-- Name: etl_db_migrations; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.etl_db_migrations ( + version bigint NOT NULL, + dirty boolean NOT NULL ); -- --- Name: milestones; Type: TABLE; Schema: public; Owner: - +-- Name: etl_manage_entities; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.milestones ( +CREATE TABLE public.etl_manage_entities ( id integer NOT NULL, - name character varying NOT NULL, - threshold integer NOT NULL, - blocknumber integer, - slot integer, - "timestamp" timestamp without time zone NOT NULL + address text NOT NULL, + entity_type text NOT NULL, + entity_id bigint NOT NULL, + action text NOT NULL, + metadata text, + signature text NOT NULL, + signer text NOT NULL, + nonce text NOT NULL, + block_height bigint NOT NULL, + tx_hash text NOT NULL, + created_at timestamp without time zone NOT NULL ); -- --- Name: muted_users; Type: TABLE; Schema: public; Owner: - +-- Name: etl_manage_entities_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE TABLE public.muted_users ( - muted_user_id integer NOT NULL, - user_id integer NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - is_delete boolean DEFAULT false, - txhash text NOT NULL, - blockhash text NOT NULL, - blocknumber integer -); +CREATE SEQUENCE public.etl_manage_entities_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; -- --- Name: notification; Type: TABLE; Schema: public; Owner: - +-- Name: etl_manage_entities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -CREATE TABLE public.notification ( - id bigint NOT NULL, - specifier character varying NOT NULL, - group_id character varying NOT NULL, - type character varying NOT NULL, - slot integer, - blocknumber integer, - "timestamp" timestamp without time zone NOT NULL, - data jsonb, - user_ids integer[], - type_v2 character varying -); +ALTER SEQUENCE public.etl_manage_entities_id_seq OWNED BY public.etl_manage_entities.id; -- --- Name: notification_campaign_push_open; Type: TABLE; Schema: public; Owner: - +-- Name: etl_plays; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.notification_campaign_push_open ( - campaign_id uuid NOT NULL, - user_id integer NOT NULL, - opened_at timestamp with time zone DEFAULT now() NOT NULL +CREATE TABLE public.etl_plays ( + id integer NOT NULL, + user_id text NOT NULL, + track_id text NOT NULL, + city text NOT NULL, + region text NOT NULL, + country text NOT NULL, + played_at timestamp without time zone NOT NULL, + block_height bigint NOT NULL, + tx_hash text NOT NULL, + listened_at timestamp without time zone NOT NULL, + recorded_at timestamp without time zone NOT NULL ); -- --- Name: notification_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- Name: etl_plays_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE public.notification_id_seq - AS bigint +CREATE SEQUENCE public.etl_plays_id_seq + AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -8567,59 +8599,72 @@ CREATE SEQUENCE public.notification_id_seq -- --- Name: notification_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- Name: etl_plays_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE public.notification_id_seq OWNED BY public.notification.id; +ALTER SEQUENCE public.etl_plays_id_seq OWNED BY public.etl_plays.id; -- --- Name: notification_seen; Type: TABLE; Schema: public; Owner: - +-- Name: etl_sla_node_reports; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.notification_seen ( - user_id integer NOT NULL, - seen_at timestamp without time zone NOT NULL, - blocknumber integer, - blockhash character varying, - txhash character varying +CREATE TABLE public.etl_sla_node_reports ( + id integer NOT NULL, + sla_rollup_id integer NOT NULL, + address text NOT NULL, + num_blocks_proposed integer NOT NULL, + challenges_received integer NOT NULL, + challenges_failed integer NOT NULL, + block_height bigint NOT NULL, + tx_hash text NOT NULL, + created_at timestamp without time zone NOT NULL ); -- --- Name: oauth_authorization_codes; Type: TABLE; Schema: public; Owner: - +-- Name: etl_sla_node_reports_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE TABLE public.oauth_authorization_codes ( - code character varying(255) NOT NULL, - client_id character varying(255) NOT NULL, - user_id integer NOT NULL, - redirect_uri text NOT NULL, - code_challenge character varying(255) NOT NULL, - code_challenge_method character varying(10) DEFAULT 'S256'::character varying NOT NULL, - scope character varying(50) NOT NULL, - expires_at timestamp with time zone DEFAULT (now() + '00:10:00'::interval) NOT NULL, - used boolean DEFAULT false NOT NULL -); +CREATE SEQUENCE public.etl_sla_node_reports_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; -- --- Name: oauth_redirect_uris; Type: TABLE; Schema: public; Owner: - +-- Name: etl_sla_node_reports_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -CREATE TABLE public.oauth_redirect_uris ( +ALTER SEQUENCE public.etl_sla_node_reports_id_seq OWNED BY public.etl_sla_node_reports.id; + + +-- +-- Name: etl_sla_rollups; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.etl_sla_rollups ( id integer NOT NULL, - client_id character varying(255) NOT NULL, - redirect_uri text NOT NULL, - created_at timestamp with time zone DEFAULT now() NOT NULL + block_start bigint NOT NULL, + block_end bigint NOT NULL, + block_height bigint NOT NULL, + validator_count integer NOT NULL, + block_quota integer NOT NULL, + bps double precision NOT NULL, + tps double precision NOT NULL, + tx_hash text NOT NULL, + created_at timestamp without time zone NOT NULL ); -- --- Name: oauth_redirect_uris_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- Name: etl_sla_rollups_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE public.oauth_redirect_uris_id_seq +CREATE SEQUENCE public.etl_sla_rollups_id_seq AS integer START WITH 1 INCREMENT BY 1 @@ -8629,144 +8674,105 @@ CREATE SEQUENCE public.oauth_redirect_uris_id_seq -- --- Name: oauth_redirect_uris_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- Name: etl_sla_rollups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE public.oauth_redirect_uris_id_seq OWNED BY public.oauth_redirect_uris.id; +ALTER SEQUENCE public.etl_sla_rollups_id_seq OWNED BY public.etl_sla_rollups.id; -- --- Name: oauth_tokens; Type: TABLE; Schema: public; Owner: - +-- Name: etl_storage_proof_verifications; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.oauth_tokens ( - token character varying(255) NOT NULL, - token_type character varying(10) NOT NULL, - client_id character varying(255) NOT NULL, - user_id integer NOT NULL, - scope character varying(50) NOT NULL, - expires_at timestamp with time zone NOT NULL, - is_revoked boolean DEFAULT false NOT NULL, - created_at timestamp with time zone DEFAULT now() NOT NULL, - refresh_token_id character varying(255), - family_id character varying(255) NOT NULL +CREATE TABLE public.etl_storage_proof_verifications ( + id integer NOT NULL, + height bigint NOT NULL, + proof bytea NOT NULL, + block_height bigint NOT NULL, + tx_hash text NOT NULL, + created_at timestamp without time zone NOT NULL ); -- --- Name: payment_router_txs; Type: TABLE; Schema: public; Owner: - +-- Name: etl_storage_proof_verifications_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE TABLE public.payment_router_txs ( - signature character varying NOT NULL, - slot integer NOT NULL, - created_at timestamp without time zone NOT NULL -); +CREATE SEQUENCE public.etl_storage_proof_verifications_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; -- --- Name: playlist_routes; Type: TABLE; Schema: public; Owner: - +-- Name: etl_storage_proof_verifications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -CREATE TABLE public.playlist_routes ( - slug character varying NOT NULL, - title_slug character varying NOT NULL, - collision_id integer NOT NULL, - owner_id integer NOT NULL, - playlist_id integer NOT NULL, - is_current boolean NOT NULL, - blockhash character varying NOT NULL, - blocknumber integer NOT NULL, - txhash character varying NOT NULL -); +ALTER SEQUENCE public.etl_storage_proof_verifications_id_seq OWNED BY public.etl_storage_proof_verifications.id; -- --- Name: playlist_seen; Type: TABLE; Schema: public; Owner: - +-- Name: etl_storage_proofs; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.playlist_seen ( - user_id integer NOT NULL, - playlist_id integer NOT NULL, - seen_at timestamp without time zone NOT NULL, - is_current boolean NOT NULL, - blocknumber integer, - blockhash character varying, - txhash character varying +CREATE TABLE public.etl_storage_proofs ( + id integer NOT NULL, + height bigint NOT NULL, + address text NOT NULL, + prover_addresses text[] NOT NULL, + cid text NOT NULL, + proof_signature bytea, + proof bytea, + status public.etl_proof_status DEFAULT 'unresolved'::public.etl_proof_status NOT NULL, + block_height bigint NOT NULL, + tx_hash text NOT NULL, + created_at timestamp without time zone NOT NULL ); -- --- Name: playlist_tracks; Type: TABLE; Schema: public; Owner: - +-- Name: etl_storage_proofs_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE TABLE public.playlist_tracks ( - playlist_id integer NOT NULL, - track_id integer NOT NULL, - is_removed boolean NOT NULL, - created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); +CREATE SEQUENCE public.etl_storage_proofs_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; -- --- Name: playlist_trending_scores; Type: TABLE; Schema: public; Owner: - +-- Name: etl_storage_proofs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -CREATE TABLE public.playlist_trending_scores ( - playlist_id integer NOT NULL, - type character varying NOT NULL, - version character varying NOT NULL, - time_range character varying NOT NULL, - score double precision NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); +ALTER SEQUENCE public.etl_storage_proofs_id_seq OWNED BY public.etl_storage_proofs.id; -- --- Name: playlists; Type: TABLE; Schema: public; Owner: - +-- Name: etl_transactions; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.playlists ( - blockhash character varying, - blocknumber integer, - playlist_id integer NOT NULL, - playlist_owner_id integer NOT NULL, - is_album boolean NOT NULL, - is_private boolean NOT NULL, - playlist_name character varying, - playlist_contents jsonb NOT NULL, - playlist_image_multihash character varying, - is_current boolean NOT NULL, - is_delete boolean NOT NULL, - description character varying, - created_at timestamp without time zone NOT NULL, - upc character varying, - updated_at timestamp without time zone NOT NULL, - playlist_image_sizes_multihash character varying, - txhash character varying DEFAULT ''::character varying NOT NULL, - last_added_to timestamp without time zone, - slot integer, - metadata_multihash character varying, - is_image_autogenerated boolean DEFAULT false NOT NULL, - is_stream_gated boolean DEFAULT false NOT NULL, - stream_conditions jsonb, - ddex_app character varying, - ddex_release_ids jsonb, - artists jsonb, - copyright_line jsonb, - producer_copyright_line jsonb, - parental_warning_type character varying, - is_scheduled_release boolean DEFAULT false NOT NULL, - release_date timestamp without time zone +CREATE TABLE public.etl_transactions ( + id integer NOT NULL, + tx_hash text NOT NULL, + block_height bigint NOT NULL, + tx_index integer NOT NULL, + tx_type text NOT NULL, + address text, + created_at timestamp without time zone NOT NULL ); -- --- Name: plays_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- Name: etl_transactions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE public.plays_id_seq +CREATE SEQUENCE public.etl_transactions_id_seq AS integer START WITH 1 INCREMENT BY 1 @@ -8776,41 +8782,30 @@ CREATE SEQUENCE public.plays_id_seq -- --- Name: plays_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- Name: etl_transactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE public.plays_id_seq OWNED BY public.plays.id; +ALTER SEQUENCE public.etl_transactions_id_seq OWNED BY public.etl_transactions.id; -- --- Name: prizes; Type: TABLE; Schema: public; Owner: - +-- Name: etl_validator_deregistrations; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.prizes ( +CREATE TABLE public.etl_validator_deregistrations ( id integer NOT NULL, - prize_id character varying NOT NULL, - name character varying NOT NULL, - description text, - weight integer DEFAULT 1 NOT NULL, - is_active boolean DEFAULT true NOT NULL, - metadata jsonb, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL + comet_address text NOT NULL, + comet_pubkey bytea NOT NULL, + block_height bigint NOT NULL, + tx_hash text NOT NULL ); -- --- Name: TABLE prizes; Type: COMMENT; Schema: public; Owner: - --- - -COMMENT ON TABLE public.prizes IS 'Defines prizes available for claiming. Prizes are selected randomly based on weight.'; - - --- --- Name: prizes_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- Name: etl_validator_deregistrations_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE public.prizes_id_seq +CREATE SEQUENCE public.etl_validator_deregistrations_id_seq AS integer START WITH 1 INCREMENT BY 1 @@ -8820,42 +8815,70 @@ CREATE SEQUENCE public.prizes_id_seq -- --- Name: prizes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- Name: etl_validator_deregistrations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE public.prizes_id_seq OWNED BY public.prizes.id; +ALTER SEQUENCE public.etl_validator_deregistrations_id_seq OWNED BY public.etl_validator_deregistrations.id; -- --- Name: pubkeys; Type: TABLE; Schema: public; Owner: - +-- Name: etl_validator_misbehavior_deregistrations; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.pubkeys ( - wallet text NOT NULL, - pubkey text +CREATE TABLE public.etl_validator_misbehavior_deregistrations ( + id integer NOT NULL, + comet_address text NOT NULL, + pub_key bytea NOT NULL, + block_height bigint NOT NULL, + tx_hash text NOT NULL, + created_at timestamp without time zone NOT NULL ); -- --- Name: reactions; Type: TABLE; Schema: public; Owner: - +-- Name: etl_validator_misbehavior_deregistrations_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE TABLE public.reactions ( +CREATE SEQUENCE public.etl_validator_misbehavior_deregistrations_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: etl_validator_misbehavior_deregistrations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.etl_validator_misbehavior_deregistrations_id_seq OWNED BY public.etl_validator_misbehavior_deregistrations.id; + + +-- +-- Name: etl_validator_registrations; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.etl_validator_registrations ( id integer NOT NULL, - reaction_value integer NOT NULL, - sender_wallet character varying NOT NULL, - reaction_type character varying NOT NULL, - reacted_to character varying NOT NULL, - "timestamp" timestamp without time zone NOT NULL, - blocknumber integer + address text NOT NULL, + endpoint text NOT NULL, + comet_address text NOT NULL, + eth_block text NOT NULL, + node_type text NOT NULL, + spid text NOT NULL, + comet_pubkey bytea NOT NULL, + voting_power bigint NOT NULL, + block_height bigint NOT NULL, + tx_hash text NOT NULL ); -- --- Name: reactions_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- Name: etl_validator_registrations_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE public.reactions_id_seq +CREATE SEQUENCE public.etl_validator_registrations_id_seq AS integer START WITH 1 INCREMENT BY 1 @@ -8865,41 +8888,80 @@ CREATE SEQUENCE public.reactions_id_seq -- --- Name: reactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- Name: etl_validator_registrations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE public.reactions_id_seq OWNED BY public.reactions.id; +ALTER SEQUENCE public.etl_validator_registrations_id_seq OWNED BY public.etl_validator_registrations.id; -- --- Name: related_artists; Type: TABLE; Schema: public; Owner: - +-- Name: etl_validators; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.related_artists ( - user_id integer NOT NULL, - related_artist_user_id integer NOT NULL, - score double precision NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +CREATE TABLE public.etl_validators ( + id integer NOT NULL, + address text NOT NULL, + endpoint text NOT NULL, + comet_address text NOT NULL, + node_type text NOT NULL, + spid text NOT NULL, + voting_power bigint NOT NULL, + status text NOT NULL, + registered_at bigint NOT NULL, + deregistered_at bigint, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); -- --- Name: remixes; Type: TABLE; Schema: public; Owner: - +-- Name: etl_validators_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE TABLE public.remixes ( - parent_track_id integer NOT NULL, - child_track_id integer NOT NULL +CREATE SEQUENCE public.etl_validators_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: etl_validators_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.etl_validators_id_seq OWNED BY public.etl_validators.id; + + +-- +-- Name: event_routes; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.event_routes ( + slug character varying NOT NULL, + owner_id integer NOT NULL, + event_id integer NOT NULL, + is_current boolean NOT NULL, + blockhash character varying NOT NULL, + blocknumber integer NOT NULL, + txhash character varying NOT NULL ); -- --- Name: reported_comments; Type: TABLE; Schema: public; Owner: - +-- Name: events; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.reported_comments ( - reported_comment_id integer NOT NULL, +CREATE TABLE public.events ( + event_id integer NOT NULL, + event_type public.event_type NOT NULL, user_id integer NOT NULL, + entity_type public.event_entity_type, + entity_id integer, + end_date timestamp without time zone, + is_deleted boolean DEFAULT false, + event_data jsonb, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, txhash text NOT NULL, @@ -8909,3695 +8971,4848 @@ CREATE TABLE public.reported_comments ( -- --- Name: reposts; Type: TABLE; Schema: public; Owner: - +-- Name: follows; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.reposts ( +CREATE TABLE public.follows ( blockhash character varying, blocknumber integer, - user_id integer NOT NULL, - repost_item_id integer NOT NULL, - repost_type public.reposttype NOT NULL, + follower_user_id integer NOT NULL, + followee_user_id integer NOT NULL, is_current boolean NOT NULL, is_delete boolean NOT NULL, created_at timestamp without time zone NOT NULL, txhash character varying DEFAULT ''::character varying NOT NULL, - slot integer, - is_repost_of_repost boolean DEFAULT false NOT NULL + slot integer ); -- --- Name: revert_blocks; Type: TABLE; Schema: public; Owner: - +-- Name: grants; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.revert_blocks ( - blocknumber integer NOT NULL, - prev_records jsonb NOT NULL +CREATE TABLE public.grants ( + blockhash character varying, + blocknumber integer, + grantee_address character varying NOT NULL, + user_id integer NOT NULL, + is_revoked boolean DEFAULT false NOT NULL, + is_current boolean NOT NULL, + is_approved boolean, + updated_at timestamp without time zone NOT NULL, + created_at timestamp without time zone NOT NULL, + txhash character varying NOT NULL ); -- --- Name: reward_codes; Type: TABLE; Schema: public; Owner: - +-- Name: hourly_play_counts; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.reward_codes ( - code text NOT NULL, - mint text NOT NULL, - reward_address text NOT NULL, - amount bigint NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - remaining_uses integer DEFAULT 1 NOT NULL, - signature text +CREATE TABLE public.hourly_play_counts ( + hourly_timestamp timestamp without time zone NOT NULL, + play_count integer NOT NULL ); -- --- Name: TABLE reward_codes; Type: COMMENT; Schema: public; Owner: - +-- Name: indexing_checkpoints; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON TABLE public.reward_codes IS 'Stores reward codes for distributing coins'; +CREATE TABLE public.indexing_checkpoints ( + tablename character varying NOT NULL, + last_checkpoint integer NOT NULL, + signature character varying +); -- --- Name: COLUMN reward_codes.code; Type: COMMENT; Schema: public; Owner: - +-- Name: milestones; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON COLUMN public.reward_codes.code IS 'Unique code for redemption'; +CREATE TABLE public.milestones ( + id integer NOT NULL, + name character varying NOT NULL, + threshold integer NOT NULL, + blocknumber integer, + slot integer, + "timestamp" timestamp without time zone NOT NULL +); -- --- Name: COLUMN reward_codes.mint; Type: COMMENT; Schema: public; Owner: - +-- Name: muted_users; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON COLUMN public.reward_codes.mint IS 'Coin mint address'; +CREATE TABLE public.muted_users ( + muted_user_id integer NOT NULL, + user_id integer NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + is_delete boolean DEFAULT false, + txhash text NOT NULL, + blockhash text NOT NULL, + blocknumber integer +); -- --- Name: COLUMN reward_codes.reward_address; Type: COMMENT; Schema: public; Owner: - +-- Name: mv_dashboard_transaction_stats; Type: MATERIALIZED VIEW; Schema: public; Owner: - -- -COMMENT ON COLUMN public.reward_codes.reward_address IS 'Address of the reward instance onchain'; +CREATE MATERIALIZED VIEW public.mv_dashboard_transaction_stats AS + WITH latest_block_time AS ( + SELECT etl_blocks.block_time + FROM public.etl_blocks + ORDER BY etl_blocks.block_height DESC + LIMIT 1 + ), time_periods AS ( + SELECT lbt.block_time AS now_time, + (lbt.block_time - '24:00:00'::interval) AS h24_ago, + (lbt.block_time - '48:00:00'::interval) AS h48_ago, + (lbt.block_time - '7 days'::interval) AS d7_ago, + (lbt.block_time - '30 days'::interval) AS d30_ago + FROM latest_block_time lbt + ) + SELECT count(*) FILTER (WHERE (t.created_at >= tp.h24_ago)) AS transactions_24h, + count(*) FILTER (WHERE ((t.created_at >= tp.h48_ago) AND (t.created_at < tp.h24_ago))) AS transactions_previous_24h, + count(*) FILTER (WHERE (t.created_at >= tp.d7_ago)) AS transactions_7d, + count(*) FILTER (WHERE (t.created_at >= tp.d30_ago)) AS transactions_30d, + count(*) AS total_transactions + FROM (time_periods tp + CROSS JOIN public.etl_transactions t) + WHERE (t.created_at <= tp.now_time) + WITH NO DATA; -- --- Name: COLUMN reward_codes.amount; Type: COMMENT; Schema: public; Owner: - +-- Name: mv_dashboard_transaction_types; Type: MATERIALIZED VIEW; Schema: public; Owner: - -- -COMMENT ON COLUMN public.reward_codes.amount IS 'Amount of coins to reward'; +CREATE MATERIALIZED VIEW public.mv_dashboard_transaction_types AS + WITH latest_block_time AS ( + SELECT etl_blocks.block_time + FROM public.etl_blocks + ORDER BY etl_blocks.block_height DESC + LIMIT 1 + ) + SELECT t.tx_type, + count(*) AS transaction_count + FROM (public.etl_transactions t + CROSS JOIN latest_block_time lbt) + WHERE (t.created_at <= lbt.block_time) + GROUP BY t.tx_type + ORDER BY (count(*)) DESC + WITH NO DATA; -- --- Name: COLUMN reward_codes.remaining_uses; Type: COMMENT; Schema: public; Owner: - +-- Name: new_chain_queue; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON COLUMN public.reward_codes.remaining_uses IS 'Number of times the code can still be redeemed'; +CREATE TABLE public.new_chain_queue ( + id bigint NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + tx_data bytea NOT NULL, + confirmed_block bigint +); -- --- Name: COLUMN reward_codes.signature; Type: COMMENT; Schema: public; Owner: - +-- Name: TABLE new_chain_queue; Type: COMMENT; Schema: public; Owner: - -- -COMMENT ON COLUMN public.reward_codes.signature IS 'Signature used to generate the reward code'; +COMMENT ON TABLE public.new_chain_queue IS 'Queue of ManageEntity transactions to be forwarded to the new Core chain (audius-mainnet-v2) during genesis migration.'; -- --- Name: reward_manager_txs; Type: TABLE; Schema: public; Owner: - +-- Name: COLUMN new_chain_queue.tx_data; Type: COMMENT; Schema: public; Owner: - -- -CREATE TABLE public.reward_manager_txs ( - signature character varying NOT NULL, - slot integer NOT NULL, - created_at timestamp without time zone NOT NULL -); +COMMENT ON COLUMN public.new_chain_queue.tx_data IS 'Protobuf-serialized ManageEntityLegacy message.'; -- --- Name: route_metrics; Type: TABLE; Schema: public; Owner: - +-- Name: COLUMN new_chain_queue.confirmed_block; Type: COMMENT; Schema: public; Owner: - -- -CREATE TABLE public.route_metrics ( - route_path character varying NOT NULL, - version character varying NOT NULL, - query_string character varying DEFAULT ''::character varying NOT NULL, - count integer NOT NULL, - "timestamp" timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - id bigint NOT NULL, - ip character varying -); +COMMENT ON COLUMN public.new_chain_queue.confirmed_block IS 'Block height on the old chain where this transaction was confirmed. NULL if confirmation was not recorded (e.g. relay restart).'; -- --- Name: route_metrics_all_time; Type: MATERIALIZED VIEW; Schema: public; Owner: - +-- Name: new_chain_queue_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE MATERIALIZED VIEW public.route_metrics_all_time AS - SELECT count(DISTINCT ip) AS unique_count, - sum(count) AS count - FROM public.route_metrics - WITH NO DATA; +CREATE SEQUENCE public.new_chain_queue_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; -- --- Name: route_metrics_day_bucket; Type: MATERIALIZED VIEW; Schema: public; Owner: - +-- Name: new_chain_queue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -CREATE MATERIALIZED VIEW public.route_metrics_day_bucket AS - SELECT count(DISTINCT ip) AS unique_count, - sum(count) AS count, - date_trunc('day'::text, "timestamp") AS "time" - FROM public.route_metrics - GROUP BY (date_trunc('day'::text, "timestamp")) - WITH NO DATA; +ALTER SEQUENCE public.new_chain_queue_id_seq OWNED BY public.new_chain_queue.id; -- --- Name: route_metrics_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- Name: notification; Type: TABLE; Schema: public; Owner: - -- -ALTER TABLE public.route_metrics ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( - SEQUENCE NAME public.route_metrics_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1 +CREATE TABLE public.notification ( + id bigint NOT NULL, + specifier character varying NOT NULL, + group_id character varying NOT NULL, + type character varying NOT NULL, + slot integer, + blocknumber integer, + "timestamp" timestamp without time zone NOT NULL, + data jsonb, + user_ids integer[], + type_v2 character varying ); -- --- Name: route_metrics_month_bucket; Type: MATERIALIZED VIEW; Schema: public; Owner: - +-- Name: notification_campaign_push_open; Type: TABLE; Schema: public; Owner: - -- -CREATE MATERIALIZED VIEW public.route_metrics_month_bucket AS - SELECT count(DISTINCT ip) AS unique_count, - sum(count) AS count, - date_trunc('month'::text, "timestamp") AS "time" - FROM public.route_metrics - GROUP BY (date_trunc('month'::text, "timestamp")) - WITH NO DATA; +CREATE TABLE public.notification_campaign_push_open ( + campaign_id uuid NOT NULL, + user_id integer NOT NULL, + opened_at timestamp with time zone DEFAULT now() NOT NULL +); -- --- Name: route_metrics_trailing_month; Type: MATERIALIZED VIEW; Schema: public; Owner: - +-- Name: notification_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE MATERIALIZED VIEW public.route_metrics_trailing_month AS - SELECT count(DISTINCT ip) AS unique_count, - sum(count) AS count - FROM public.route_metrics - WHERE ("timestamp" > (now() - '1 mon'::interval)) - WITH NO DATA; +CREATE SEQUENCE public.notification_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; -- --- Name: route_metrics_trailing_week; Type: MATERIALIZED VIEW; Schema: public; Owner: - +-- Name: notification_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -CREATE MATERIALIZED VIEW public.route_metrics_trailing_week AS - SELECT count(DISTINCT ip) AS unique_count, - sum(count) AS count - FROM public.route_metrics - WHERE ("timestamp" > (now() - '7 days'::interval)) - WITH NO DATA; +ALTER SEQUENCE public.notification_id_seq OWNED BY public.notification.id; -- --- Name: rpc_cursor; Type: TABLE; Schema: public; Owner: - +-- Name: notification_seen; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.rpc_cursor ( - relayed_by text NOT NULL, - relayed_at timestamp without time zone NOT NULL +CREATE TABLE public.notification_seen ( + user_id integer NOT NULL, + seen_at timestamp without time zone NOT NULL, + blocknumber integer, + blockhash character varying, + txhash character varying ); -- --- Name: rpc_error; Type: TABLE; Schema: public; Owner: - +-- Name: oauth_authorization_codes; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.rpc_error ( - sig text NOT NULL, - rpc_log_json jsonb NOT NULL, - error_text text NOT NULL, - error_count integer DEFAULT 0 NOT NULL, - last_attempt timestamp without time zone NOT NULL +CREATE TABLE public.oauth_authorization_codes ( + code character varying(255) NOT NULL, + client_id character varying(255) NOT NULL, + user_id integer NOT NULL, + redirect_uri text NOT NULL, + code_challenge character varying(255) NOT NULL, + code_challenge_method character varying(10) DEFAULT 'S256'::character varying NOT NULL, + scope character varying(50) NOT NULL, + expires_at timestamp with time zone DEFAULT (now() + '00:10:00'::interval) NOT NULL, + used boolean DEFAULT false NOT NULL ); -- --- Name: rpc_log; Type: TABLE; Schema: public; Owner: - +-- Name: oauth_redirect_uris; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.rpc_log ( - relayed_at timestamp without time zone NOT NULL, - from_wallet text NOT NULL, - rpc json NOT NULL, - sig text NOT NULL, - relayed_by text NOT NULL, - applied_at timestamp without time zone NOT NULL +CREATE TABLE public.oauth_redirect_uris ( + id integer NOT NULL, + client_id character varying(255) NOT NULL, + redirect_uri text NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL ); -- --- Name: rpclog; Type: TABLE; Schema: public; Owner: - +-- Name: oauth_redirect_uris_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE TABLE public.rpclog ( - cuid text NOT NULL, - wallet text, - method text, - params jsonb, - jetstream_seq integer -); +CREATE SEQUENCE public.oauth_redirect_uris_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; -- --- Name: saves; Type: TABLE; Schema: public; Owner: - +-- Name: oauth_redirect_uris_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -CREATE TABLE public.saves ( - blockhash character varying, - blocknumber integer, +ALTER SEQUENCE public.oauth_redirect_uris_id_seq OWNED BY public.oauth_redirect_uris.id; + + +-- +-- Name: oauth_tokens; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.oauth_tokens ( + token character varying(255) NOT NULL, + token_type character varying(10) NOT NULL, + client_id character varying(255) NOT NULL, user_id integer NOT NULL, - save_item_id integer NOT NULL, - save_type public.savetype NOT NULL, - is_current boolean NOT NULL, - is_delete boolean NOT NULL, - created_at timestamp without time zone NOT NULL, - txhash character varying DEFAULT ''::character varying NOT NULL, - slot integer, - is_save_of_repost boolean DEFAULT false NOT NULL + scope character varying(50) NOT NULL, + expires_at timestamp with time zone NOT NULL, + is_revoked boolean DEFAULT false NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + refresh_token_id character varying(255), + family_id character varying(255) NOT NULL ); -- --- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - +-- Name: payment_router_txs; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.schema_migrations ( - version character varying(255) NOT NULL +CREATE TABLE public.payment_router_txs ( + signature character varying NOT NULL, + slot integer NOT NULL, + created_at timestamp without time zone NOT NULL ); -- --- Name: schema_version; Type: TABLE; Schema: public; Owner: - +-- Name: playlist_routes; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.schema_version ( - file_name text NOT NULL, - md5 text, - applied_at timestamp with time zone DEFAULT now() NOT NULL +CREATE TABLE public.playlist_routes ( + slug character varying NOT NULL, + title_slug character varying NOT NULL, + collision_id integer NOT NULL, + owner_id integer NOT NULL, + playlist_id integer NOT NULL, + is_current boolean NOT NULL, + blockhash character varying NOT NULL, + blocknumber integer NOT NULL, + txhash character varying NOT NULL ); -- --- Name: shares; Type: TABLE; Schema: public; Owner: - +-- Name: playlist_seen; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.shares ( - blockhash character varying, - blocknumber integer, +CREATE TABLE public.playlist_seen ( user_id integer NOT NULL, - share_item_id integer NOT NULL, - share_type public.sharetype NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - txhash character varying DEFAULT ''::character varying NOT NULL, - slot integer + playlist_id integer NOT NULL, + seen_at timestamp without time zone NOT NULL, + is_current boolean NOT NULL, + blocknumber integer, + blockhash character varying, + txhash character varying ); -- --- Name: skipped_transactions; Type: TABLE; Schema: public; Owner: - +-- Name: playlist_tracks; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.skipped_transactions ( - id integer NOT NULL, - blocknumber integer NOT NULL, - blockhash character varying NOT NULL, - txhash character varying NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - level public.skippedtransactionlevel DEFAULT 'node'::public.skippedtransactionlevel +CREATE TABLE public.playlist_tracks ( + playlist_id integer NOT NULL, + track_id integer NOT NULL, + is_removed boolean NOT NULL, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL ); -- --- Name: skipped_transactions_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- Name: playlist_trending_scores; Type: TABLE; Schema: public; Owner: - -- -CREATE SEQUENCE public.skipped_transactions_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; +CREATE TABLE public.playlist_trending_scores ( + playlist_id integer NOT NULL, + type character varying NOT NULL, + version character varying NOT NULL, + time_range character varying NOT NULL, + score double precision NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); -- --- Name: skipped_transactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- Name: playlists; Type: TABLE; Schema: public; Owner: - -- -ALTER SEQUENCE public.skipped_transactions_id_seq OWNED BY public.skipped_transactions.id; +CREATE TABLE public.playlists ( + blockhash character varying, + blocknumber integer, + playlist_id integer NOT NULL, + playlist_owner_id integer NOT NULL, + is_album boolean NOT NULL, + is_private boolean NOT NULL, + playlist_name character varying, + playlist_contents jsonb NOT NULL, + playlist_image_multihash character varying, + is_current boolean NOT NULL, + is_delete boolean NOT NULL, + description character varying, + created_at timestamp without time zone NOT NULL, + upc character varying, + updated_at timestamp without time zone NOT NULL, + playlist_image_sizes_multihash character varying, + txhash character varying DEFAULT ''::character varying NOT NULL, + last_added_to timestamp without time zone, + slot integer, + metadata_multihash character varying, + is_image_autogenerated boolean DEFAULT false NOT NULL, + is_stream_gated boolean DEFAULT false NOT NULL, + stream_conditions jsonb, + ddex_app character varying, + ddex_release_ids jsonb, + artists jsonb, + copyright_line jsonb, + producer_copyright_line jsonb, + parental_warning_type character varying, + is_scheduled_release boolean DEFAULT false NOT NULL, + release_date timestamp without time zone +); -- --- Name: sol_claimable_account_transfers; Type: TABLE; Schema: public; Owner: - +-- Name: plays_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE TABLE public.sol_claimable_account_transfers ( - signature character varying NOT NULL, - instruction_index integer NOT NULL, - amount bigint NOT NULL, - slot bigint NOT NULL, - from_account character varying NOT NULL, - to_account character varying NOT NULL, - sender_eth_address character varying NOT NULL -); +CREATE SEQUENCE public.plays_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; -- --- Name: TABLE sol_claimable_account_transfers; Type: COMMENT; Schema: public; Owner: - +-- Name: plays_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_claimable_account_transfers IS 'Stores claimable tokens program Transfer instructions for tracked mints.'; +ALTER SEQUENCE public.plays_id_seq OWNED BY public.plays.id; -- --- Name: sol_claimable_accounts; Type: TABLE; Schema: public; Owner: - +-- Name: prizes; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.sol_claimable_accounts ( - signature character varying NOT NULL, - instruction_index integer NOT NULL, - slot bigint NOT NULL, - mint character varying NOT NULL, - ethereum_address character varying NOT NULL, - account character varying NOT NULL +CREATE TABLE public.prizes ( + id integer NOT NULL, + prize_id character varying NOT NULL, + name character varying NOT NULL, + description text, + weight integer DEFAULT 1 NOT NULL, + is_active boolean DEFAULT true NOT NULL, + metadata jsonb, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL ); -- --- Name: TABLE sol_claimable_accounts; Type: COMMENT; Schema: public; Owner: - +-- Name: TABLE prizes; Type: COMMENT; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_claimable_accounts IS 'Stores claimable tokens program Create instructions for tracked mints.'; +COMMENT ON TABLE public.prizes IS 'Defines prizes available for claiming. Prizes are selected randomly based on weight.'; -- --- Name: sol_keypairs; Type: TABLE; Schema: public; Owner: - +-- Name: prizes_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE TABLE public.sol_keypairs ( - public_key character varying NOT NULL, - private_key bytea NOT NULL -); +CREATE SEQUENCE public.prizes_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; -- --- Name: sol_locker_vesting_escrows; Type: TABLE; Schema: public; Owner: - +-- Name: prizes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -CREATE TABLE public.sol_locker_vesting_escrows ( - account text NOT NULL, - slot bigint NOT NULL, - recipient text NOT NULL, - token_mint text NOT NULL, - creator text NOT NULL, - base text NOT NULL, - escrow_bump smallint NOT NULL, - update_recipient_mode smallint NOT NULL, - cancel_mode smallint NOT NULL, - token_program_flag smallint NOT NULL, - cliff_time bigint NOT NULL, - frequency bigint NOT NULL, - cliff_unlock_amount bigint NOT NULL, - amount_per_period bigint NOT NULL, - number_of_period bigint NOT NULL, - total_claimed_amount bigint NOT NULL, - vesting_start_time bigint NOT NULL, - cancelled_at bigint NOT NULL, - created_at timestamp without time zone DEFAULT now(), - updated_at timestamp without time zone DEFAULT now() -); +ALTER SEQUENCE public.prizes_id_seq OWNED BY public.prizes.id; -- --- Name: sol_meteora_damm_v2_initialize_custom_pool_instructions; Type: TABLE; Schema: public; Owner: - +-- Name: pubkeys; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.sol_meteora_damm_v2_initialize_custom_pool_instructions ( - signature text NOT NULL, - instruction_index integer NOT NULL, - slot bigint NOT NULL, - creator text, - position_nft_mint text, - position_nft_account text, - payer text, - pool_authority text, - pool text, - "position" text, - token_a_mint text, - token_b_mint text, - token_a_vault text, - token_b_vault text, - payer_token_a text, - payer_token_b text, - token_a_program text, - token_b_program text, - token_2022_program text, - system_program text, - event_authority text, - program text, - remaining_accounts jsonb DEFAULT '[]'::jsonb, - base_fee_cliff_fee_numerator bigint, - base_fee_first_factor integer, - base_fee_second_factor_max_limiter_duration integer, - base_fee_second_factor_max_fee_bps integer, - base_fee_third_factor bigint, - base_fee_mode smallint, - dynamic_fee_bin_step smallint, - dynamic_fee_bin_step_u128 numeric, - dynamic_fee_filter_period smallint, - dynamic_fee_decay_period smallint, - dynamic_fee_reduction_factor smallint, - dynamic_fee_max_volatility_accumulator integer, - dynamic_fee_variable_fee_control integer, - created_at timestamp with time zone DEFAULT now(), - updated_at timestamp with time zone DEFAULT now() +CREATE TABLE public.pubkeys ( + wallet text NOT NULL, + pubkey text ); -- --- Name: TABLE sol_meteora_damm_v2_initialize_custom_pool_instructions; Type: COMMENT; Schema: public; Owner: - +-- Name: reactions; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_meteora_damm_v2_initialize_custom_pool_instructions IS 'Tracks InitializeCustomPool instructions for DAMM V2 pools.'; +CREATE TABLE public.reactions ( + id integer NOT NULL, + reaction_value integer NOT NULL, + sender_wallet character varying NOT NULL, + reaction_type character varying NOT NULL, + reacted_to character varying NOT NULL, + "timestamp" timestamp without time zone NOT NULL, + blocknumber integer +); -- --- Name: sol_meteora_damm_v2_pool_base_fees; Type: TABLE; Schema: public; Owner: - +-- Name: reactions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE TABLE public.sol_meteora_damm_v2_pool_base_fees ( - pool text NOT NULL, - slot bigint NOT NULL, - cliff_fee_numerator bigint NOT NULL, - fee_scheduler_mode smallint NOT NULL, - number_of_period smallint NOT NULL, - period_frequency bigint NOT NULL, - reduction_factor bigint NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); +CREATE SEQUENCE public.reactions_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; -- --- Name: TABLE sol_meteora_damm_v2_pool_base_fees; Type: COMMENT; Schema: public; Owner: - +-- Name: reactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_meteora_damm_v2_pool_base_fees IS 'Tracks base fee configuration for DAMM V2 pools. A slice of the DAMM V2 pool state.'; +ALTER SEQUENCE public.reactions_id_seq OWNED BY public.reactions.id; -- --- Name: sol_meteora_damm_v2_pool_dynamic_fees; Type: TABLE; Schema: public; Owner: - +-- Name: related_artists; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.sol_meteora_damm_v2_pool_dynamic_fees ( - pool text NOT NULL, - slot bigint NOT NULL, - initialized smallint NOT NULL, - max_volatility_accumulator integer NOT NULL, - variable_fee_control integer NOT NULL, - bin_step smallint NOT NULL, - filter_period smallint NOT NULL, - decay_period smallint NOT NULL, - reduction_factor smallint NOT NULL, - last_update_timestamp bigint NOT NULL, - bin_step_u128 numeric NOT NULL, - sqrt_price_reference numeric NOT NULL, - volatility_accumulator numeric NOT NULL, - volatility_reference numeric NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +CREATE TABLE public.related_artists ( + user_id integer NOT NULL, + related_artist_user_id integer NOT NULL, + score double precision NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL ); -- --- Name: TABLE sol_meteora_damm_v2_pool_dynamic_fees; Type: COMMENT; Schema: public; Owner: - +-- Name: remixes; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_meteora_damm_v2_pool_dynamic_fees IS 'Tracks dynamic fee configuration for DAMM V2 pools. A slice of the DAMM V2 pool state.'; +CREATE TABLE public.remixes ( + parent_track_id integer NOT NULL, + child_track_id integer NOT NULL +); -- --- Name: sol_meteora_damm_v2_pool_fees; Type: TABLE; Schema: public; Owner: - +-- Name: reported_comments; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.sol_meteora_damm_v2_pool_fees ( - pool text NOT NULL, - slot bigint NOT NULL, - protocol_fee_percent smallint NOT NULL, - partner_fee_percent smallint NOT NULL, - referral_fee_percent smallint NOT NULL, +CREATE TABLE public.reported_comments ( + reported_comment_id integer NOT NULL, + user_id integer NOT NULL, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + txhash text NOT NULL, + blockhash text NOT NULL, + blocknumber integer ); -- --- Name: TABLE sol_meteora_damm_v2_pool_fees; Type: COMMENT; Schema: public; Owner: - --- - -COMMENT ON TABLE public.sol_meteora_damm_v2_pool_fees IS 'Tracks fee configuration for DAMM V2 pools. A slice of the DAMM V2 pool state.'; - - --- --- Name: sol_meteora_damm_v2_pool_metrics; Type: TABLE; Schema: public; Owner: - +-- Name: reposts; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.sol_meteora_damm_v2_pool_metrics ( - pool text NOT NULL, - slot bigint NOT NULL, - total_lp_a_fee numeric NOT NULL, - total_lp_b_fee numeric NOT NULL, - total_protocol_a_fee numeric NOT NULL, - total_protocol_b_fee numeric NOT NULL, - total_partner_a_fee numeric NOT NULL, - total_partner_b_fee numeric NOT NULL, - total_position bigint NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +CREATE TABLE public.reposts ( + blockhash character varying, + blocknumber integer, + user_id integer NOT NULL, + repost_item_id integer NOT NULL, + repost_type public.reposttype NOT NULL, + is_current boolean NOT NULL, + is_delete boolean NOT NULL, + created_at timestamp without time zone NOT NULL, + txhash character varying DEFAULT ''::character varying NOT NULL, + slot integer, + is_repost_of_repost boolean DEFAULT false NOT NULL ); -- --- Name: TABLE sol_meteora_damm_v2_pool_metrics; Type: COMMENT; Schema: public; Owner: - +-- Name: revert_blocks; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_meteora_damm_v2_pool_metrics IS 'Tracks aggregated metrics for DAMM V2 pools. A slice of the DAMM V2 pool state.'; +CREATE TABLE public.revert_blocks ( + blocknumber integer NOT NULL, + prev_records jsonb NOT NULL +); -- --- Name: sol_meteora_damm_v2_position_metrics; Type: TABLE; Schema: public; Owner: - +-- Name: reward_codes; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.sol_meteora_damm_v2_position_metrics ( - "position" text NOT NULL, - slot bigint NOT NULL, - total_claimed_a_fee bigint NOT NULL, - total_claimed_b_fee bigint NOT NULL, +CREATE TABLE public.reward_codes ( + code text NOT NULL, + mint text NOT NULL, + reward_address text NOT NULL, + amount bigint NOT NULL, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL + remaining_uses integer DEFAULT 1 NOT NULL, + signature text ); -- --- Name: TABLE sol_meteora_damm_v2_position_metrics; Type: COMMENT; Schema: public; Owner: - +-- Name: TABLE reward_codes; Type: COMMENT; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_meteora_damm_v2_position_metrics IS 'Tracks aggregated metrics for DAMM V2 positions. A slice of the DAMM V2 position state.'; +COMMENT ON TABLE public.reward_codes IS 'Stores reward codes for distributing coins'; -- --- Name: sol_meteora_damm_v2_positions; Type: TABLE; Schema: public; Owner: - +-- Name: COLUMN reward_codes.code; Type: COMMENT; Schema: public; Owner: - -- -CREATE TABLE public.sol_meteora_damm_v2_positions ( - account text NOT NULL, - slot bigint NOT NULL, - pool text NOT NULL, - nft_mint text NOT NULL, - fee_a_per_token_checkpoint bigint NOT NULL, - fee_b_per_token_checkpoint bigint NOT NULL, - fee_a_pending bigint NOT NULL, - fee_b_pending bigint NOT NULL, - unlocked_liquidity numeric NOT NULL, - vested_liquidity numeric NOT NULL, - permanent_locked_liquidity numeric NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); +COMMENT ON COLUMN public.reward_codes.code IS 'Unique code for redemption'; -- --- Name: TABLE sol_meteora_damm_v2_positions; Type: COMMENT; Schema: public; Owner: - +-- Name: COLUMN reward_codes.mint; Type: COMMENT; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_meteora_damm_v2_positions IS 'Tracks DAMM V2 positions representing a claim to the liquidity and associated fees in a DAMM V2 pool. Join with sol_meteora_damm_v2_position_metrics for full position state.'; +COMMENT ON COLUMN public.reward_codes.mint IS 'Coin mint address'; -- --- Name: sol_meteora_dbc_config_fees; Type: TABLE; Schema: public; Owner: - +-- Name: COLUMN reward_codes.reward_address; Type: COMMENT; Schema: public; Owner: - -- -CREATE TABLE public.sol_meteora_dbc_config_fees ( - config text NOT NULL, - slot bigint NOT NULL, - base_fee_cliff_fee_numerator bigint, - base_fee_period_frequency bigint, - base_fee_reduction_factor bigint, - base_fee_number_of_period smallint, - base_fee_fee_scheduler_mode smallint, - dynamic_fee_initialized smallint, - dynamic_fee_max_volatility_accumulator integer, - dynamic_fee_variable_fee_control integer, - dynamic_fee_bin_step smallint, - dynamic_fee_filter_period smallint, - dynamic_fee_decay_period smallint, - dynamic_fee_reduction_factor smallint, - dynamic_fee_bin_step_u128 numeric, - protocol_fee_percent smallint, - referral_fee_percent smallint -); +COMMENT ON COLUMN public.reward_codes.reward_address IS 'Address of the reward instance onchain'; -- --- Name: sol_meteora_dbc_config_vestings; Type: TABLE; Schema: public; Owner: - +-- Name: COLUMN reward_codes.amount; Type: COMMENT; Schema: public; Owner: - -- -CREATE TABLE public.sol_meteora_dbc_config_vestings ( - config text NOT NULL, - slot bigint NOT NULL, - amount_per_period bigint, - cliff_duration_from_migration_time bigint, - frequency bigint, - number_of_period bigint, - cliff_unlock_amount bigint -); +COMMENT ON COLUMN public.reward_codes.amount IS 'Amount of coins to reward'; -- --- Name: sol_meteora_dbc_migrations; Type: TABLE; Schema: public; Owner: - +-- Name: COLUMN reward_codes.remaining_uses; Type: COMMENT; Schema: public; Owner: - -- -CREATE TABLE public.sol_meteora_dbc_migrations ( - signature text NOT NULL, - instruction_index integer NOT NULL, - slot bigint NOT NULL, - dbc_pool text NOT NULL, - migration_metadata text NOT NULL, - config text NOT NULL, - dbc_pool_authority text NOT NULL, - damm_v2_pool text NOT NULL, - first_position_nft_mint text NOT NULL, - first_position_nft_account text NOT NULL, - first_position text NOT NULL, - second_position_nft_mint text NOT NULL, - second_position_nft_account text NOT NULL, - second_position text NOT NULL, - damm_pool_authority text NOT NULL, - base_mint text NOT NULL, - quote_mint text NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); +COMMENT ON COLUMN public.reward_codes.remaining_uses IS 'Number of times the code can still be redeemed'; -- --- Name: TABLE sol_meteora_dbc_migrations; Type: COMMENT; Schema: public; Owner: - +-- Name: COLUMN reward_codes.signature; Type: COMMENT; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_meteora_dbc_migrations IS 'Tracks migrations from DBC pools to DAMM V2 pools.'; +COMMENT ON COLUMN public.reward_codes.signature IS 'Signature used to generate the reward code'; -- --- Name: sol_meteora_dbc_pool_metrics; Type: TABLE; Schema: public; Owner: - +-- Name: reward_manager_txs; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.sol_meteora_dbc_pool_metrics ( - pool text NOT NULL, - slot bigint NOT NULL, - total_protocol_base_fee bigint NOT NULL, - total_protocol_quote_fee bigint NOT NULL, - total_trading_base_fee bigint NOT NULL, - total_trading_quote_fee bigint NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +CREATE TABLE public.reward_manager_txs ( + signature character varying NOT NULL, + slot integer NOT NULL, + created_at timestamp without time zone NOT NULL ); -- --- Name: sol_meteora_dbc_pool_volatility_trackers; Type: TABLE; Schema: public; Owner: - +-- Name: route_metrics; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.sol_meteora_dbc_pool_volatility_trackers ( - pool text NOT NULL, - slot bigint NOT NULL, - last_update_timestamp bigint NOT NULL, - volatility_accumulator numeric NOT NULL, - volatility_reference numeric NOT NULL, +CREATE TABLE public.route_metrics ( + route_path character varying NOT NULL, + version character varying NOT NULL, + query_string character varying DEFAULT ''::character varying NOT NULL, + count integer NOT NULL, + "timestamp" timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + id bigint NOT NULL, + ip character varying ); -- --- Name: sol_payments; Type: TABLE; Schema: public; Owner: - +-- Name: route_metrics_all_time; Type: MATERIALIZED VIEW; Schema: public; Owner: - -- -CREATE TABLE public.sol_payments ( - signature character varying NOT NULL, - instruction_index integer NOT NULL, - amount bigint NOT NULL, - slot bigint NOT NULL, - route_index integer NOT NULL, - to_account character varying NOT NULL -); +CREATE MATERIALIZED VIEW public.route_metrics_all_time AS + SELECT count(DISTINCT ip) AS unique_count, + sum(count) AS count + FROM public.route_metrics + WITH NO DATA; -- --- Name: TABLE sol_payments; Type: COMMENT; Schema: public; Owner: - +-- Name: route_metrics_day_bucket; Type: MATERIALIZED VIEW; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_payments IS 'Stores payment router program Route instruction recipients and amounts for tracked mints.'; +CREATE MATERIALIZED VIEW public.route_metrics_day_bucket AS + SELECT count(DISTINCT ip) AS unique_count, + sum(count) AS count, + date_trunc('day'::text, "timestamp") AS "time" + FROM public.route_metrics + GROUP BY (date_trunc('day'::text, "timestamp")) + WITH NO DATA; -- --- Name: sol_purchases; Type: TABLE; Schema: public; Owner: - +-- Name: route_metrics_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE TABLE public.sol_purchases ( - signature character varying NOT NULL, - instruction_index integer NOT NULL, - amount bigint NOT NULL, - slot bigint NOT NULL, - from_account character varying NOT NULL, - content_type character varying NOT NULL, - content_id integer NOT NULL, - buyer_user_id integer NOT NULL, - access_type character varying NOT NULL, - valid_after_blocknumber bigint NOT NULL, - is_valid boolean, - city character varying, - region character varying, - country character varying, - created_at timestamp without time zone DEFAULT now() +ALTER TABLE public.route_metrics ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME public.route_metrics_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 ); -- --- Name: TABLE sol_purchases; Type: COMMENT; Schema: public; Owner: - +-- Name: route_metrics_month_bucket; Type: MATERIALIZED VIEW; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_purchases IS 'Stores payment router program Route instructions that are paired with purchase information for tracked mints.'; +CREATE MATERIALIZED VIEW public.route_metrics_month_bucket AS + SELECT count(DISTINCT ip) AS unique_count, + sum(count) AS count, + date_trunc('month'::text, "timestamp") AS "time" + FROM public.route_metrics + GROUP BY (date_trunc('month'::text, "timestamp")) + WITH NO DATA; -- --- Name: COLUMN sol_purchases.valid_after_blocknumber; Type: COMMENT; Schema: public; Owner: - +-- Name: route_metrics_trailing_month; Type: MATERIALIZED VIEW; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_purchases.valid_after_blocknumber IS 'Purchase transactions include the blocknumber that the content was most recently updated in order to ensure that the relevant pricing information has been indexed before evaluating whether the purchase is valid.'; +CREATE MATERIALIZED VIEW public.route_metrics_trailing_month AS + SELECT count(DISTINCT ip) AS unique_count, + sum(count) AS count + FROM public.route_metrics + WHERE ("timestamp" > (now() - '1 mon'::interval)) + WITH NO DATA; -- --- Name: COLUMN sol_purchases.is_valid; Type: COMMENT; Schema: public; Owner: - +-- Name: route_metrics_trailing_week; Type: MATERIALIZED VIEW; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_purchases.is_valid IS 'A purchase is valid if it meets the pricing information set by the artist. If the pricing information is not available yet (as indicated by the valid_after_blocknumber), then is_valid will be NULL which indicates a "pending" state.'; +CREATE MATERIALIZED VIEW public.route_metrics_trailing_week AS + SELECT count(DISTINCT ip) AS unique_count, + sum(count) AS count + FROM public.route_metrics + WHERE ("timestamp" > (now() - '7 days'::interval)) + WITH NO DATA; -- --- Name: sol_retry_queue; Type: TABLE; Schema: public; Owner: - +-- Name: rpc_cursor; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.sol_retry_queue ( - id uuid DEFAULT gen_random_uuid() NOT NULL, - indexer text NOT NULL, - update_message jsonb NOT NULL, - error text NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +CREATE TABLE public.rpc_cursor ( + relayed_by text NOT NULL, + relayed_at timestamp without time zone NOT NULL ); -- --- Name: TABLE sol_retry_queue; Type: COMMENT; Schema: public; Owner: - +-- Name: rpc_error; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_retry_queue IS 'Queue for retrying failed indexer updates.'; +CREATE TABLE public.rpc_error ( + sig text NOT NULL, + rpc_log_json jsonb NOT NULL, + error_text text NOT NULL, + error_count integer DEFAULT 0 NOT NULL, + last_attempt timestamp without time zone NOT NULL +); -- --- Name: COLUMN sol_retry_queue.indexer; Type: COMMENT; Schema: public; Owner: - +-- Name: rpc_log; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_retry_queue.indexer IS 'The name of the indexer that failed (e.g., token_indexer, damm_v2_indexer).'; +CREATE TABLE public.rpc_log ( + relayed_at timestamp without time zone NOT NULL, + from_wallet text NOT NULL, + rpc json NOT NULL, + sig text NOT NULL, + relayed_by text NOT NULL, + applied_at timestamp without time zone NOT NULL +); -- --- Name: COLUMN sol_retry_queue.update_message; Type: COMMENT; Schema: public; Owner: - +-- Name: rpclog; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_retry_queue.update_message IS 'The JSONB update data that failed to process.'; +CREATE TABLE public.rpclog ( + cuid text NOT NULL, + wallet text, + method text, + params jsonb, + jetstream_seq integer +); -- --- Name: COLUMN sol_retry_queue.error; Type: COMMENT; Schema: public; Owner: - +-- Name: saves; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_retry_queue.error IS 'The error message from the failure.'; +CREATE TABLE public.saves ( + blockhash character varying, + blocknumber integer, + user_id integer NOT NULL, + save_item_id integer NOT NULL, + save_type public.savetype NOT NULL, + is_current boolean NOT NULL, + is_delete boolean NOT NULL, + created_at timestamp without time zone NOT NULL, + txhash character varying DEFAULT ''::character varying NOT NULL, + slot integer, + is_save_of_repost boolean DEFAULT false NOT NULL +); -- --- Name: COLUMN sol_retry_queue.created_at; Type: COMMENT; Schema: public; Owner: - +-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_retry_queue.created_at IS 'The timestamp when the retry entry was created.'; +CREATE TABLE public.schema_migrations ( + version character varying(255) NOT NULL +); -- --- Name: COLUMN sol_retry_queue.updated_at; Type: COMMENT; Schema: public; Owner: - +-- Name: schema_version; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_retry_queue.updated_at IS 'The timestamp when the retry entry was last updated.'; +CREATE TABLE public.schema_version ( + file_name text NOT NULL, + md5 text, + applied_at timestamp with time zone DEFAULT now() NOT NULL +); -- --- Name: sol_reward_disbursements; Type: TABLE; Schema: public; Owner: - +-- Name: shares; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.sol_reward_disbursements ( - signature character varying NOT NULL, - instruction_index integer NOT NULL, - amount bigint NOT NULL, - slot bigint NOT NULL, - user_bank character varying NOT NULL, - challenge_id character varying NOT NULL, - specifier character varying NOT NULL, - recipient_eth_address text, - created_at timestamp without time zone DEFAULT now() +CREATE TABLE public.shares ( + blockhash character varying, + blocknumber integer, + user_id integer NOT NULL, + share_item_id integer NOT NULL, + share_type public.sharetype NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + txhash character varying DEFAULT ''::character varying NOT NULL, + slot integer ); -- --- Name: TABLE sol_reward_disbursements; Type: COMMENT; Schema: public; Owner: - +-- Name: skipped_transactions; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_reward_disbursements IS 'Stores reward manager program Evaluate instructions for tracked mints.'; +CREATE TABLE public.skipped_transactions ( + id integer NOT NULL, + blocknumber integer NOT NULL, + blockhash character varying NOT NULL, + txhash character varying NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + level public.skippedtransactionlevel DEFAULT 'node'::public.skippedtransactionlevel +); -- --- Name: COLUMN sol_reward_disbursements.recipient_eth_address; Type: COMMENT; Schema: public; Owner: - +-- Name: skipped_transactions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_reward_disbursements.recipient_eth_address IS 'The Ethereum address of the recipient of the reward.'; +CREATE SEQUENCE public.skipped_transactions_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; -- --- Name: sol_reward_manager_inits; Type: TABLE; Schema: public; Owner: - +-- Name: skipped_transactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -CREATE TABLE public.sol_reward_manager_inits ( - signature text NOT NULL, - instruction_index integer NOT NULL, - slot bigint NOT NULL, - min_votes integer NOT NULL, - reward_manager_state text NOT NULL, - token_source text NOT NULL, - mint text NOT NULL, - manager text NOT NULL, - authority text NOT NULL -); +ALTER SEQUENCE public.skipped_transactions_id_seq OWNED BY public.skipped_transactions.id; -- --- Name: TABLE sol_reward_manager_inits; Type: COMMENT; Schema: public; Owner: - +-- Name: sol_claimable_account_transfers; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_reward_manager_inits IS 'Stores Init instructions for the Reward Manager program'; +CREATE TABLE public.sol_claimable_account_transfers ( + signature character varying NOT NULL, + instruction_index integer NOT NULL, + amount bigint NOT NULL, + slot bigint NOT NULL, + from_account character varying NOT NULL, + to_account character varying NOT NULL, + sender_eth_address character varying NOT NULL +); -- --- Name: COLUMN sol_reward_manager_inits.min_votes; Type: COMMENT; Schema: public; Owner: - +-- Name: TABLE sol_claimable_account_transfers; Type: COMMENT; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_reward_manager_inits.min_votes IS 'Minimum number of votes required for reward distribution'; +COMMENT ON TABLE public.sol_claimable_account_transfers IS 'Stores claimable tokens program Transfer instructions for tracked mints.'; -- --- Name: COLUMN sol_reward_manager_inits.reward_manager_state; Type: COMMENT; Schema: public; Owner: - +-- Name: sol_claimable_accounts; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_reward_manager_inits.reward_manager_state IS 'Public key of the Reward Manager state account'; +CREATE TABLE public.sol_claimable_accounts ( + signature character varying NOT NULL, + instruction_index integer NOT NULL, + slot bigint NOT NULL, + mint character varying NOT NULL, + ethereum_address character varying NOT NULL, + account character varying NOT NULL +); -- --- Name: COLUMN sol_reward_manager_inits.token_source; Type: COMMENT; Schema: public; Owner: - +-- Name: TABLE sol_claimable_accounts; Type: COMMENT; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_reward_manager_inits.token_source IS 'Public key of the token source account (Note: Any token account on the authority account is valid)'; +COMMENT ON TABLE public.sol_claimable_accounts IS 'Stores claimable tokens program Create instructions for tracked mints.'; -- --- Name: COLUMN sol_reward_manager_inits.mint; Type: COMMENT; Schema: public; Owner: - +-- Name: sol_keypairs; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_reward_manager_inits.mint IS 'Public key of the mint for the token source account'; +CREATE TABLE public.sol_keypairs ( + public_key character varying NOT NULL, + private_key bytea NOT NULL +); -- --- Name: COLUMN sol_reward_manager_inits.manager; Type: COMMENT; Schema: public; Owner: - +-- Name: sol_locker_vesting_escrows; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_reward_manager_inits.manager IS 'Public key of the manager account that initially has authority to create and remove senders without quorum'; +CREATE TABLE public.sol_locker_vesting_escrows ( + account text NOT NULL, + slot bigint NOT NULL, + recipient text NOT NULL, + token_mint text NOT NULL, + creator text NOT NULL, + base text NOT NULL, + escrow_bump smallint NOT NULL, + update_recipient_mode smallint NOT NULL, + cancel_mode smallint NOT NULL, + token_program_flag smallint NOT NULL, + cliff_time bigint NOT NULL, + frequency bigint NOT NULL, + cliff_unlock_amount bigint NOT NULL, + amount_per_period bigint NOT NULL, + number_of_period bigint NOT NULL, + total_claimed_amount bigint NOT NULL, + vesting_start_time bigint NOT NULL, + cancelled_at bigint NOT NULL, + created_at timestamp without time zone DEFAULT now(), + updated_at timestamp without time zone DEFAULT now() +); -- --- Name: COLUMN sol_reward_manager_inits.authority; Type: COMMENT; Schema: public; Owner: - +-- Name: sol_meteora_damm_v2_initialize_custom_pool_instructions; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_reward_manager_inits.authority IS 'Public key of the authority account, which holds the token accounts that reward manager can disburse from'; +CREATE TABLE public.sol_meteora_damm_v2_initialize_custom_pool_instructions ( + signature text NOT NULL, + instruction_index integer NOT NULL, + slot bigint NOT NULL, + creator text, + position_nft_mint text, + position_nft_account text, + payer text, + pool_authority text, + pool text, + "position" text, + token_a_mint text, + token_b_mint text, + token_a_vault text, + token_b_vault text, + payer_token_a text, + payer_token_b text, + token_a_program text, + token_b_program text, + token_2022_program text, + system_program text, + event_authority text, + program text, + remaining_accounts jsonb DEFAULT '[]'::jsonb, + base_fee_cliff_fee_numerator bigint, + base_fee_first_factor integer, + base_fee_second_factor_max_limiter_duration integer, + base_fee_second_factor_max_fee_bps integer, + base_fee_third_factor bigint, + base_fee_mode smallint, + dynamic_fee_bin_step smallint, + dynamic_fee_bin_step_u128 numeric, + dynamic_fee_filter_period smallint, + dynamic_fee_decay_period smallint, + dynamic_fee_reduction_factor smallint, + dynamic_fee_max_volatility_accumulator integer, + dynamic_fee_variable_fee_control integer, + created_at timestamp with time zone DEFAULT now(), + updated_at timestamp with time zone DEFAULT now() +); -- --- Name: sol_slot_checkpoints; Type: TABLE; Schema: public; Owner: - +-- Name: TABLE sol_meteora_damm_v2_initialize_custom_pool_instructions; Type: COMMENT; Schema: public; Owner: - -- -CREATE TABLE public.sol_slot_checkpoints ( - id uuid DEFAULT gen_random_uuid() NOT NULL, - from_slot bigint NOT NULL, - to_slot bigint NOT NULL, - subscription_hash text NOT NULL, - subscription jsonb NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - name text -); +COMMENT ON TABLE public.sol_meteora_damm_v2_initialize_custom_pool_instructions IS 'Tracks InitializeCustomPool instructions for DAMM V2 pools.'; -- --- Name: TABLE sol_slot_checkpoints; Type: COMMENT; Schema: public; Owner: - +-- Name: sol_meteora_damm_v2_pool_base_fees; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_slot_checkpoints IS 'Stores checkpoints for Solana slots to track indexing progress.'; +CREATE TABLE public.sol_meteora_damm_v2_pool_base_fees ( + pool text NOT NULL, + slot bigint NOT NULL, + cliff_fee_numerator bigint NOT NULL, + fee_scheduler_mode smallint NOT NULL, + number_of_period smallint NOT NULL, + period_frequency bigint NOT NULL, + reduction_factor bigint NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); -- --- Name: COLUMN sol_slot_checkpoints.name; Type: COMMENT; Schema: public; Owner: - +-- Name: TABLE sol_meteora_damm_v2_pool_base_fees; Type: COMMENT; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_slot_checkpoints.name IS 'The name of the indexer this checkpoint is for (e.g., token_indexer, damm_v2_indexer).'; +COMMENT ON TABLE public.sol_meteora_damm_v2_pool_base_fees IS 'Tracks base fee configuration for DAMM V2 pools. A slice of the DAMM V2 pool state.'; -- --- Name: sol_token_account_balance_changes; Type: TABLE; Schema: public; Owner: - +-- Name: sol_meteora_damm_v2_pool_dynamic_fees; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.sol_token_account_balance_changes ( - signature character varying NOT NULL, - mint character varying NOT NULL, - owner character varying NOT NULL, - account character varying NOT NULL, - change bigint NOT NULL, - balance bigint NOT NULL, +CREATE TABLE public.sol_meteora_damm_v2_pool_dynamic_fees ( + pool text NOT NULL, slot bigint NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + initialized smallint NOT NULL, + max_volatility_accumulator integer NOT NULL, + variable_fee_control integer NOT NULL, + bin_step smallint NOT NULL, + filter_period smallint NOT NULL, + decay_period smallint NOT NULL, + reduction_factor smallint NOT NULL, + last_update_timestamp bigint NOT NULL, + bin_step_u128 numeric NOT NULL, + sqrt_price_reference numeric NOT NULL, + volatility_accumulator numeric NOT NULL, + volatility_reference numeric NOT NULL, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - block_timestamp timestamp without time zone NOT NULL, - fee_payer character varying + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL ); -- --- Name: TABLE sol_token_account_balance_changes; Type: COMMENT; Schema: public; Owner: - --- - -COMMENT ON TABLE public.sol_token_account_balance_changes IS 'Stores token balance changes for all accounts of tracked mints.'; - - --- --- Name: COLUMN sol_token_account_balance_changes.fee_payer; Type: COMMENT; Schema: public; Owner: - +-- Name: TABLE sol_meteora_damm_v2_pool_dynamic_fees; Type: COMMENT; Schema: public; Owner: - -- -COMMENT ON COLUMN public.sol_token_account_balance_changes.fee_payer IS 'The public key of the account that paid the fee for the transaction.'; +COMMENT ON TABLE public.sol_meteora_damm_v2_pool_dynamic_fees IS 'Tracks dynamic fee configuration for DAMM V2 pools. A slice of the DAMM V2 pool state.'; -- --- Name: sol_token_account_balances; Type: TABLE; Schema: public; Owner: - +-- Name: sol_meteora_damm_v2_pool_fees; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.sol_token_account_balances ( - account character varying NOT NULL, - mint character varying NOT NULL, - owner character varying NOT NULL, - balance bigint NOT NULL, +CREATE TABLE public.sol_meteora_damm_v2_pool_fees ( + pool text NOT NULL, slot bigint NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL + protocol_fee_percent smallint NOT NULL, + partner_fee_percent smallint NOT NULL, + referral_fee_percent smallint NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL ); -- --- Name: TABLE sol_token_account_balances; Type: COMMENT; Schema: public; Owner: - +-- Name: TABLE sol_meteora_damm_v2_pool_fees; Type: COMMENT; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_token_account_balances IS 'Stores current token balances for all accounts of tracked mints.'; +COMMENT ON TABLE public.sol_meteora_damm_v2_pool_fees IS 'Tracks fee configuration for DAMM V2 pools. A slice of the DAMM V2 pool state.'; -- --- Name: sol_token_transfers; Type: TABLE; Schema: public; Owner: - +-- Name: sol_meteora_damm_v2_pool_metrics; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.sol_token_transfers ( - signature character varying NOT NULL, - instruction_index integer NOT NULL, - amount bigint NOT NULL, +CREATE TABLE public.sol_meteora_damm_v2_pool_metrics ( + pool text NOT NULL, slot bigint NOT NULL, - from_account character varying NOT NULL, - to_account character varying NOT NULL + total_lp_a_fee numeric NOT NULL, + total_lp_b_fee numeric NOT NULL, + total_protocol_a_fee numeric NOT NULL, + total_protocol_b_fee numeric NOT NULL, + total_partner_a_fee numeric NOT NULL, + total_partner_b_fee numeric NOT NULL, + total_position bigint NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL ); -- --- Name: TABLE sol_token_transfers; Type: COMMENT; Schema: public; Owner: - +-- Name: TABLE sol_meteora_damm_v2_pool_metrics; Type: COMMENT; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_token_transfers IS 'Stores SPL token transfers for tracked mints.'; +COMMENT ON TABLE public.sol_meteora_damm_v2_pool_metrics IS 'Tracks aggregated metrics for DAMM V2 pools. A slice of the DAMM V2 pool state.'; -- --- Name: sol_transfer_memo_types; Type: TABLE; Schema: public; Owner: - +-- Name: sol_meteora_damm_v2_position_metrics; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.sol_transfer_memo_types ( - signature character varying NOT NULL, - instruction_index integer NOT NULL, +CREATE TABLE public.sol_meteora_damm_v2_position_metrics ( + "position" text NOT NULL, slot bigint NOT NULL, - memo_type character varying NOT NULL, - created_at timestamp without time zone DEFAULT now() NOT NULL + total_claimed_a_fee bigint NOT NULL, + total_claimed_b_fee bigint NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL ); -- --- Name: TABLE sol_transfer_memo_types; Type: COMMENT; Schema: public; Owner: - +-- Name: TABLE sol_meteora_damm_v2_position_metrics; Type: COMMENT; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_transfer_memo_types IS 'Memo-tagged classifications for claimable_tokens transfers and payment_router routes. memo_type is one of: withdrawal, prepare_withdrawal, internal_transfer, recover_withdrawal.'; +COMMENT ON TABLE public.sol_meteora_damm_v2_position_metrics IS 'Tracks aggregated metrics for DAMM V2 positions. A slice of the DAMM V2 position state.'; -- --- Name: sol_user_balances; Type: TABLE; Schema: public; Owner: - +-- Name: sol_meteora_damm_v2_positions; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.sol_user_balances ( - user_id integer NOT NULL, - mint text NOT NULL, - balance bigint NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +CREATE TABLE public.sol_meteora_damm_v2_positions ( + account text NOT NULL, + slot bigint NOT NULL, + pool text NOT NULL, + nft_mint text NOT NULL, + fee_a_per_token_checkpoint bigint NOT NULL, + fee_b_per_token_checkpoint bigint NOT NULL, + fee_a_pending bigint NOT NULL, + fee_b_pending bigint NOT NULL, + unlocked_liquidity numeric NOT NULL, + vested_liquidity numeric NOT NULL, + permanent_locked_liquidity numeric NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL ); -- --- Name: TABLE sol_user_balances; Type: COMMENT; Schema: public; Owner: - +-- Name: TABLE sol_meteora_damm_v2_positions; Type: COMMENT; Schema: public; Owner: - -- -COMMENT ON TABLE public.sol_user_balances IS 'Stores the balances of Solana tokens for users.'; +COMMENT ON TABLE public.sol_meteora_damm_v2_positions IS 'Tracks DAMM V2 positions representing a claim to the liquidity and associated fees in a DAMM V2 pool. Join with sol_meteora_damm_v2_position_metrics for full position state.'; -- --- Name: spl_token_tx; Type: TABLE; Schema: public; Owner: - +-- Name: sol_meteora_dbc_config_fees; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.spl_token_tx ( - last_scanned_slot integer NOT NULL, - signature character varying NOT NULL, - created_at timestamp with time zone DEFAULT now() NOT NULL, - updated_at timestamp with time zone DEFAULT now() NOT NULL +CREATE TABLE public.sol_meteora_dbc_config_fees ( + config text NOT NULL, + slot bigint NOT NULL, + base_fee_cliff_fee_numerator bigint, + base_fee_period_frequency bigint, + base_fee_reduction_factor bigint, + base_fee_number_of_period smallint, + base_fee_fee_scheduler_mode smallint, + dynamic_fee_initialized smallint, + dynamic_fee_max_volatility_accumulator integer, + dynamic_fee_variable_fee_control integer, + dynamic_fee_bin_step smallint, + dynamic_fee_filter_period smallint, + dynamic_fee_decay_period smallint, + dynamic_fee_reduction_factor smallint, + dynamic_fee_bin_step_u128 numeric, + protocol_fee_percent smallint, + referral_fee_percent smallint ); -- --- Name: stems; Type: TABLE; Schema: public; Owner: - +-- Name: sol_meteora_dbc_config_vestings; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.stems ( - parent_track_id integer NOT NULL, - child_track_id integer NOT NULL +CREATE TABLE public.sol_meteora_dbc_config_vestings ( + config text NOT NULL, + slot bigint NOT NULL, + amount_per_period bigint, + cliff_duration_from_migration_time bigint, + frequency bigint, + number_of_period bigint, + cliff_unlock_amount bigint ); -- --- Name: subscriptions; Type: TABLE; Schema: public; Owner: - +-- Name: sol_meteora_dbc_migrations; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.subscriptions ( - blockhash character varying, - blocknumber integer, - subscriber_id integer NOT NULL, - user_id integer NOT NULL, - is_current boolean NOT NULL, - is_delete boolean NOT NULL, +CREATE TABLE public.sol_meteora_dbc_migrations ( + signature text NOT NULL, + instruction_index integer NOT NULL, + slot bigint NOT NULL, + dbc_pool text NOT NULL, + migration_metadata text NOT NULL, + config text NOT NULL, + dbc_pool_authority text NOT NULL, + damm_v2_pool text NOT NULL, + first_position_nft_mint text NOT NULL, + first_position_nft_account text NOT NULL, + first_position text NOT NULL, + second_position_nft_mint text NOT NULL, + second_position_nft_account text NOT NULL, + second_position text NOT NULL, + damm_pool_authority text NOT NULL, + base_mint text NOT NULL, + quote_mint text NOT NULL, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - txhash character varying DEFAULT ''::character varying NOT NULL, - entity_type text DEFAULT 'User'::text NOT NULL, - entity_id integer + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL ); -- --- Name: supporter_rank_ups; Type: TABLE; Schema: public; Owner: - +-- Name: TABLE sol_meteora_dbc_migrations; Type: COMMENT; Schema: public; Owner: - -- -CREATE TABLE public.supporter_rank_ups ( - slot integer NOT NULL, - sender_user_id integer NOT NULL, - receiver_user_id integer NOT NULL, - rank integer NOT NULL -); +COMMENT ON TABLE public.sol_meteora_dbc_migrations IS 'Tracks migrations from DBC pools to DAMM V2 pools.'; -- --- Name: tag_track_user; Type: MATERIALIZED VIEW; Schema: public; Owner: - +-- Name: sol_meteora_dbc_pool_metrics; Type: TABLE; Schema: public; Owner: - -- -CREATE MATERIALIZED VIEW public.tag_track_user AS - SELECT unnest(tags) AS tag, - track_id, - owner_id - FROM ( SELECT string_to_array(lower((tracks.tags)::text), ','::text) AS tags, - tracks.track_id, - tracks.owner_id - FROM public.tracks - WHERE (((tracks.tags)::text <> ''::text) AND (tracks.tags IS NOT NULL) AND (tracks.is_current IS TRUE) AND (tracks.is_unlisted IS FALSE) AND (tracks.stem_of IS NULL)) - ORDER BY tracks.updated_at DESC) t - GROUP BY (unnest(tags)), track_id, owner_id - WITH NO DATA; +CREATE TABLE public.sol_meteora_dbc_pool_metrics ( + pool text NOT NULL, + slot bigint NOT NULL, + total_protocol_base_fee bigint NOT NULL, + total_protocol_quote_fee bigint NOT NULL, + total_trading_base_fee bigint NOT NULL, + total_trading_quote_fee bigint NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); -- --- Name: track_collaborators; Type: TABLE; Schema: public; Owner: - +-- Name: sol_meteora_dbc_pool_volatility_trackers; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.track_collaborators ( - track_id integer NOT NULL, - collaborator_user_id integer NOT NULL, - invited_by integer NOT NULL, - status text DEFAULT 'pending'::text NOT NULL, - created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL, - txhash character varying NOT NULL, - blocknumber integer, - CONSTRAINT track_collaborators_status_check CHECK ((status = ANY (ARRAY['pending'::text, 'accepted'::text, 'rejected'::text]))) +CREATE TABLE public.sol_meteora_dbc_pool_volatility_trackers ( + pool text NOT NULL, + slot bigint NOT NULL, + last_update_timestamp bigint NOT NULL, + volatility_accumulator numeric NOT NULL, + volatility_reference numeric NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL ); -- --- Name: TABLE track_collaborators; Type: COMMENT; Schema: public; Owner: - +-- Name: sol_payments; Type: TABLE; Schema: public; Owner: - -- -COMMENT ON TABLE public.track_collaborators IS 'Collaborator credits on a track. Owner invites via track metadata (status=pending); the collaborator accepts/declines on-chain (accepted/rejected). Indexed by ETL (go-openaudio).'; +CREATE TABLE public.sol_payments ( + signature character varying NOT NULL, + instruction_index integer NOT NULL, + amount bigint NOT NULL, + slot bigint NOT NULL, + route_index integer NOT NULL, + to_account character varying NOT NULL +); -- --- Name: track_delist_statuses; Type: TABLE; Schema: public; Owner: - +-- Name: TABLE sol_payments; Type: COMMENT; Schema: public; Owner: - -- -CREATE TABLE public.track_delist_statuses ( - created_at timestamp with time zone NOT NULL, - track_id integer NOT NULL, - owner_id integer NOT NULL, - track_cid character varying NOT NULL, - delisted boolean NOT NULL, - reason public.delist_track_reason NOT NULL -); +COMMENT ON TABLE public.sol_payments IS 'Stores payment router program Route instruction recipients and amounts for tracked mints.'; -- --- Name: track_downloads; Type: TABLE; Schema: public; Owner: - +-- Name: sol_purchases; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.track_downloads ( - txhash character varying NOT NULL, - blocknumber integer NOT NULL, - parent_track_id integer NOT NULL, - track_id integer NOT NULL, - user_id integer, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, +CREATE TABLE public.sol_purchases ( + signature character varying NOT NULL, + instruction_index integer NOT NULL, + amount bigint NOT NULL, + slot bigint NOT NULL, + from_account character varying NOT NULL, + content_type character varying NOT NULL, + content_id integer NOT NULL, + buyer_user_id integer NOT NULL, + access_type character varying NOT NULL, + valid_after_blocknumber bigint NOT NULL, + is_valid boolean, city character varying, region character varying, - country character varying + country character varying, + created_at timestamp without time zone DEFAULT now() ); -- --- Name: track_price_history; Type: TABLE; Schema: public; Owner: - +-- Name: TABLE sol_purchases; Type: COMMENT; Schema: public; Owner: - -- -CREATE TABLE public.track_price_history ( - track_id integer NOT NULL, - splits jsonb NOT NULL, - total_price_cents bigint NOT NULL, - blocknumber integer NOT NULL, - block_timestamp timestamp without time zone NOT NULL, +COMMENT ON TABLE public.sol_purchases IS 'Stores payment router program Route instructions that are paired with purchase information for tracked mints.'; + + +-- +-- Name: COLUMN sol_purchases.valid_after_blocknumber; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_purchases.valid_after_blocknumber IS 'Purchase transactions include the blocknumber that the content was most recently updated in order to ensure that the relevant pricing information has been indexed before evaluating whether the purchase is valid.'; + + +-- +-- Name: COLUMN sol_purchases.is_valid; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_purchases.is_valid IS 'A purchase is valid if it meets the pricing information set by the artist. If the pricing information is not available yet (as indicated by the valid_after_blocknumber), then is_valid will be NULL which indicates a "pending" state.'; + + +-- +-- Name: sol_retry_queue; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.sol_retry_queue ( + id uuid DEFAULT gen_random_uuid() NOT NULL, + indexer text NOT NULL, + update_message jsonb NOT NULL, + error text NOT NULL, created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - access public.usdc_purchase_access_type DEFAULT 'stream'::public.usdc_purchase_access_type NOT NULL + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); + + +-- +-- Name: TABLE sol_retry_queue; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.sol_retry_queue IS 'Queue for retrying failed indexer updates.'; + + +-- +-- Name: COLUMN sol_retry_queue.indexer; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_retry_queue.indexer IS 'The name of the indexer that failed (e.g., token_indexer, damm_v2_indexer).'; + + +-- +-- Name: COLUMN sol_retry_queue.update_message; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_retry_queue.update_message IS 'The JSONB update data that failed to process.'; + + +-- +-- Name: COLUMN sol_retry_queue.error; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_retry_queue.error IS 'The error message from the failure.'; + + +-- +-- Name: COLUMN sol_retry_queue.created_at; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_retry_queue.created_at IS 'The timestamp when the retry entry was created.'; + + +-- +-- Name: COLUMN sol_retry_queue.updated_at; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_retry_queue.updated_at IS 'The timestamp when the retry entry was last updated.'; + + +-- +-- Name: sol_reward_disbursements; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.sol_reward_disbursements ( + signature character varying NOT NULL, + instruction_index integer NOT NULL, + amount bigint NOT NULL, + slot bigint NOT NULL, + user_bank character varying NOT NULL, + challenge_id character varying NOT NULL, + specifier character varying NOT NULL, + recipient_eth_address text, + created_at timestamp without time zone DEFAULT now() +); + + +-- +-- Name: TABLE sol_reward_disbursements; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.sol_reward_disbursements IS 'Stores reward manager program Evaluate instructions for tracked mints.'; + + +-- +-- Name: COLUMN sol_reward_disbursements.recipient_eth_address; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_reward_disbursements.recipient_eth_address IS 'The Ethereum address of the recipient of the reward.'; + + +-- +-- Name: sol_reward_manager_inits; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.sol_reward_manager_inits ( + signature text NOT NULL, + instruction_index integer NOT NULL, + slot bigint NOT NULL, + min_votes integer NOT NULL, + reward_manager_state text NOT NULL, + token_source text NOT NULL, + mint text NOT NULL, + manager text NOT NULL, + authority text NOT NULL +); + + +-- +-- Name: TABLE sol_reward_manager_inits; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.sol_reward_manager_inits IS 'Stores Init instructions for the Reward Manager program'; + + +-- +-- Name: COLUMN sol_reward_manager_inits.min_votes; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_reward_manager_inits.min_votes IS 'Minimum number of votes required for reward distribution'; + + +-- +-- Name: COLUMN sol_reward_manager_inits.reward_manager_state; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_reward_manager_inits.reward_manager_state IS 'Public key of the Reward Manager state account'; + + +-- +-- Name: COLUMN sol_reward_manager_inits.token_source; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_reward_manager_inits.token_source IS 'Public key of the token source account (Note: Any token account on the authority account is valid)'; + + +-- +-- Name: COLUMN sol_reward_manager_inits.mint; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_reward_manager_inits.mint IS 'Public key of the mint for the token source account'; + + +-- +-- Name: COLUMN sol_reward_manager_inits.manager; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_reward_manager_inits.manager IS 'Public key of the manager account that initially has authority to create and remove senders without quorum'; + + +-- +-- Name: COLUMN sol_reward_manager_inits.authority; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_reward_manager_inits.authority IS 'Public key of the authority account, which holds the token accounts that reward manager can disburse from'; + + +-- +-- Name: sol_slot_checkpoints; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.sol_slot_checkpoints ( + id uuid DEFAULT gen_random_uuid() NOT NULL, + from_slot bigint NOT NULL, + to_slot bigint NOT NULL, + subscription_hash text NOT NULL, + subscription jsonb NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + name text ); -- --- Name: track_routes; Type: TABLE; Schema: public; Owner: - +-- Name: TABLE sol_slot_checkpoints; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.sol_slot_checkpoints IS 'Stores checkpoints for Solana slots to track indexing progress.'; + + +-- +-- Name: COLUMN sol_slot_checkpoints.name; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_slot_checkpoints.name IS 'The name of the indexer this checkpoint is for (e.g., token_indexer, damm_v2_indexer).'; + + +-- +-- Name: sol_token_account_balance_changes; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.sol_token_account_balance_changes ( + signature character varying NOT NULL, + mint character varying NOT NULL, + owner character varying NOT NULL, + account character varying NOT NULL, + change bigint NOT NULL, + balance bigint NOT NULL, + slot bigint NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + block_timestamp timestamp without time zone NOT NULL, + fee_payer character varying +); + + +-- +-- Name: TABLE sol_token_account_balance_changes; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.sol_token_account_balance_changes IS 'Stores token balance changes for all accounts of tracked mints.'; + + +-- +-- Name: COLUMN sol_token_account_balance_changes.fee_payer; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.sol_token_account_balance_changes.fee_payer IS 'The public key of the account that paid the fee for the transaction.'; + + +-- +-- Name: sol_token_account_balances; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.sol_token_account_balances ( + account character varying NOT NULL, + mint character varying NOT NULL, + owner character varying NOT NULL, + balance bigint NOT NULL, + slot bigint NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); + + +-- +-- Name: TABLE sol_token_account_balances; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.sol_token_account_balances IS 'Stores current token balances for all accounts of tracked mints.'; + + +-- +-- Name: sol_token_transfers; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.sol_token_transfers ( + signature character varying NOT NULL, + instruction_index integer NOT NULL, + amount bigint NOT NULL, + slot bigint NOT NULL, + from_account character varying NOT NULL, + to_account character varying NOT NULL +); + + +-- +-- Name: TABLE sol_token_transfers; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.sol_token_transfers IS 'Stores SPL token transfers for tracked mints.'; + + +-- +-- Name: sol_transfer_memo_types; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.sol_transfer_memo_types ( + signature character varying NOT NULL, + instruction_index integer NOT NULL, + slot bigint NOT NULL, + memo_type character varying NOT NULL, + created_at timestamp without time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: TABLE sol_transfer_memo_types; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.sol_transfer_memo_types IS 'Memo-tagged classifications for claimable_tokens transfers and payment_router routes. memo_type is one of: withdrawal, prepare_withdrawal, internal_transfer, recover_withdrawal.'; + + +-- +-- Name: sol_user_balances; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.sol_user_balances ( + user_id integer NOT NULL, + mint text NOT NULL, + balance bigint NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); + + +-- +-- Name: TABLE sol_user_balances; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.sol_user_balances IS 'Stores the balances of Solana tokens for users.'; + + +-- +-- Name: spl_token_tx; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.spl_token_tx ( + last_scanned_slot integer NOT NULL, + signature character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: stems; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.stems ( + parent_track_id integer NOT NULL, + child_track_id integer NOT NULL +); + + +-- +-- Name: subscriptions; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.subscriptions ( + blockhash character varying, + blocknumber integer, + subscriber_id integer NOT NULL, + user_id integer NOT NULL, + is_current boolean NOT NULL, + is_delete boolean NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + txhash character varying DEFAULT ''::character varying NOT NULL, + entity_type text DEFAULT 'User'::text NOT NULL, + entity_id integer +); + + +-- +-- Name: supporter_rank_ups; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.supporter_rank_ups ( + slot integer NOT NULL, + sender_user_id integer NOT NULL, + receiver_user_id integer NOT NULL, + rank integer NOT NULL +); + + +-- +-- Name: tag_track_user; Type: MATERIALIZED VIEW; Schema: public; Owner: - +-- + +CREATE MATERIALIZED VIEW public.tag_track_user AS + SELECT unnest(tags) AS tag, + track_id, + owner_id + FROM ( SELECT string_to_array(lower((tracks.tags)::text), ','::text) AS tags, + tracks.track_id, + tracks.owner_id + FROM public.tracks + WHERE (((tracks.tags)::text <> ''::text) AND (tracks.tags IS NOT NULL) AND (tracks.is_current IS TRUE) AND (tracks.is_unlisted IS FALSE) AND (tracks.stem_of IS NULL)) + ORDER BY tracks.updated_at DESC) t + GROUP BY (unnest(tags)), track_id, owner_id + WITH NO DATA; + + +-- +-- Name: track_collaborators; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.track_collaborators ( + track_id integer NOT NULL, + collaborator_user_id integer NOT NULL, + invited_by integer NOT NULL, + status text DEFAULT 'pending'::text NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, + txhash character varying NOT NULL, + blocknumber integer, + CONSTRAINT track_collaborators_status_check CHECK ((status = ANY (ARRAY['pending'::text, 'accepted'::text, 'rejected'::text]))) +); + + +-- +-- Name: TABLE track_collaborators; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.track_collaborators IS 'Collaborator credits on a track. Owner invites via track metadata (status=pending); the collaborator accepts/declines on-chain (accepted/rejected). Indexed by ETL (go-openaudio).'; + + +-- +-- Name: track_delist_statuses; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.track_delist_statuses ( + created_at timestamp with time zone NOT NULL, + track_id integer NOT NULL, + owner_id integer NOT NULL, + track_cid character varying NOT NULL, + delisted boolean NOT NULL, + reason public.delist_track_reason NOT NULL +); + + +-- +-- Name: track_downloads; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.track_downloads ( + txhash character varying NOT NULL, + blocknumber integer NOT NULL, + parent_track_id integer NOT NULL, + track_id integer NOT NULL, + user_id integer, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + city character varying, + region character varying, + country character varying +); + + +-- +-- Name: track_price_history; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.track_price_history ( + track_id integer NOT NULL, + splits jsonb NOT NULL, + total_price_cents bigint NOT NULL, + blocknumber integer NOT NULL, + block_timestamp timestamp without time zone NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + access public.usdc_purchase_access_type DEFAULT 'stream'::public.usdc_purchase_access_type NOT NULL +); + + +-- +-- Name: track_routes; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.track_routes ( + slug character varying NOT NULL, + title_slug character varying NOT NULL, + collision_id integer NOT NULL, + owner_id integer NOT NULL, + track_id integer NOT NULL, + is_current boolean NOT NULL, + blockhash character varying NOT NULL, + blocknumber integer NOT NULL, + txhash character varying NOT NULL +); + + +-- +-- Name: track_trending_scores; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.track_trending_scores ( + track_id integer NOT NULL, + type character varying NOT NULL, + genre character varying, + version character varying NOT NULL, + time_range character varying NOT NULL, + score double precision NOT NULL, + created_at timestamp without time zone NOT NULL +); + + +-- +-- Name: users; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.users ( + blockhash character varying, + user_id integer NOT NULL, + is_current boolean NOT NULL, + handle character varying, + wallet character varying, + name text, + profile_picture character varying, + cover_photo character varying, + bio character varying, + location character varying, + metadata_multihash character varying, + creator_node_endpoint character varying, + blocknumber integer, + is_verified boolean DEFAULT false NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + handle_lc character varying, + cover_photo_sizes character varying, + profile_picture_sizes character varying, + primary_id integer, + secondary_ids integer[], + replica_set_update_signer character varying, + has_collectibles boolean DEFAULT false NOT NULL, + txhash character varying DEFAULT ''::character varying NOT NULL, + playlist_library jsonb, + is_deactivated boolean DEFAULT false NOT NULL, + slot integer, + user_storage_account character varying, + user_authority_account character varying, + artist_pick_track_id integer, + is_available boolean DEFAULT true NOT NULL, + is_storage_v2 boolean DEFAULT false NOT NULL, + allow_ai_attribution boolean DEFAULT false NOT NULL, + spl_usdc_payout_wallet character varying, + twitter_handle character varying, + instagram_handle character varying, + tiktok_handle character varying, + verified_with_twitter boolean DEFAULT false, + verified_with_instagram boolean DEFAULT false, + verified_with_tiktok boolean DEFAULT false, + website character varying, + donation character varying, + profile_type public.profile_type_enum, + coin_flair_mint text, + last_active_at timestamp with time zone +); + + +-- +-- Name: COLUMN users.coin_flair_mint; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.users.coin_flair_mint IS 'The mint of the coin which the user has selected as their preferred flair. NULL for auto, empty string for none.'; + + +-- +-- Name: COLUMN users.last_active_at; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.users.last_active_at IS 'Timestamp of the user''s most recent app-open event, updated by POST /v1/users/me/ping.'; + + +-- +-- Name: trending_params; Type: MATERIALIZED VIEW; Schema: public; Owner: - +-- + +CREATE MATERIALIZED VIEW public.trending_params AS + SELECT t.track_id, + t.release_date, + t.genre, + t.owner_id, + ap.play_count, + au.follower_count AS owner_follower_count, + COALESCE(aggregate_track.repost_count, 0) AS repost_count, + COALESCE(aggregate_track.save_count, 0) AS save_count, + COALESCE(repost_week.repost_count, (0)::bigint) AS repost_week_count, + COALESCE(repost_month.repost_count, (0)::bigint) AS repost_month_count, + COALESCE(repost_year.repost_count, (0)::bigint) AS repost_year_count, + COALESCE(save_week.repost_count, (0)::bigint) AS save_week_count, + COALESCE(save_month.repost_count, (0)::bigint) AS save_month_count, + COALESCE(save_year.repost_count, (0)::bigint) AS save_year_count, + COALESCE(karma.karma, (0)::numeric) AS karma + FROM ((((((((((public.tracks t + LEFT JOIN ( SELECT ap_1.count AS play_count, + ap_1.play_item_id + FROM public.aggregate_plays ap_1) ap ON ((ap.play_item_id = t.track_id))) + LEFT JOIN ( SELECT au_1.user_id, + au_1.follower_count + FROM public.aggregate_user au_1) au ON ((au.user_id = t.owner_id))) + LEFT JOIN ( SELECT aggregate_track_1.track_id, + aggregate_track_1.repost_count, + aggregate_track_1.save_count + FROM public.aggregate_track aggregate_track_1) aggregate_track ON ((aggregate_track.track_id = t.track_id))) + LEFT JOIN ( SELECT r.repost_item_id AS track_id, + count(r.repost_item_id) AS repost_count + FROM public.reposts r + WHERE ((r.is_current IS TRUE) AND (r.repost_type = 'track'::public.reposttype) AND (r.is_delete IS FALSE) AND (r.created_at > (now() - '1 year'::interval))) + GROUP BY r.repost_item_id) repost_year ON ((repost_year.track_id = t.track_id))) + LEFT JOIN ( SELECT r.repost_item_id AS track_id, + count(r.repost_item_id) AS repost_count + FROM public.reposts r + WHERE ((r.is_current IS TRUE) AND (r.repost_type = 'track'::public.reposttype) AND (r.is_delete IS FALSE) AND (r.created_at > (now() - '1 mon'::interval))) + GROUP BY r.repost_item_id) repost_month ON ((repost_month.track_id = t.track_id))) + LEFT JOIN ( SELECT r.repost_item_id AS track_id, + count(r.repost_item_id) AS repost_count + FROM public.reposts r + WHERE ((r.is_current IS TRUE) AND (r.repost_type = 'track'::public.reposttype) AND (r.is_delete IS FALSE) AND (r.created_at > (now() - '7 days'::interval))) + GROUP BY r.repost_item_id) repost_week ON ((repost_week.track_id = t.track_id))) + LEFT JOIN ( SELECT r.save_item_id AS track_id, + count(r.save_item_id) AS repost_count + FROM public.saves r + WHERE ((r.is_current IS TRUE) AND (r.save_type = 'track'::public.savetype) AND (r.is_delete IS FALSE) AND (r.created_at > (now() - '1 year'::interval))) + GROUP BY r.save_item_id) save_year ON ((save_year.track_id = t.track_id))) + LEFT JOIN ( SELECT r.save_item_id AS track_id, + count(r.save_item_id) AS repost_count + FROM public.saves r + WHERE ((r.is_current IS TRUE) AND (r.save_type = 'track'::public.savetype) AND (r.is_delete IS FALSE) AND (r.created_at > (now() - '1 mon'::interval))) + GROUP BY r.save_item_id) save_month ON ((save_month.track_id = t.track_id))) + LEFT JOIN ( SELECT r.save_item_id AS track_id, + count(r.save_item_id) AS repost_count + FROM public.saves r + WHERE ((r.is_current IS TRUE) AND (r.save_type = 'track'::public.savetype) AND (r.is_delete IS FALSE) AND (r.created_at > (now() - '7 days'::interval))) + GROUP BY r.save_item_id) save_week ON ((save_week.track_id = t.track_id))) + LEFT JOIN ( SELECT save_and_reposts.item_id AS track_id, + sum(au_1.follower_count) AS karma + FROM (( SELECT r_and_s.user_id, + r_and_s.item_id + FROM (( SELECT reposts.user_id, + reposts.repost_item_id AS item_id + FROM public.reposts + WHERE ((reposts.is_delete IS FALSE) AND (reposts.is_current IS TRUE) AND (reposts.repost_type = 'track'::public.reposttype)) + UNION ALL + SELECT saves.user_id, + saves.save_item_id AS item_id + FROM public.saves + WHERE ((saves.is_delete IS FALSE) AND (saves.is_current IS TRUE) AND (saves.save_type = 'track'::public.savetype))) r_and_s + JOIN public.users ON ((r_and_s.user_id = users.user_id))) + WHERE (((users.cover_photo IS NOT NULL) OR (users.cover_photo_sizes IS NOT NULL)) AND ((users.profile_picture IS NOT NULL) OR (users.profile_picture_sizes IS NOT NULL)) AND (users.bio IS NOT NULL))) save_and_reposts + JOIN public.aggregate_user au_1 ON ((save_and_reposts.user_id = au_1.user_id))) + GROUP BY save_and_reposts.item_id) karma ON ((karma.track_id = t.track_id))) + WHERE ((t.is_current IS TRUE) AND (t.is_delete IS FALSE) AND (t.is_unlisted IS FALSE) AND (t.stem_of IS NULL)) + WITH NO DATA; + + +-- +-- Name: trending_results; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.trending_results ( + user_id integer NOT NULL, + id character varying, + rank integer NOT NULL, + type character varying NOT NULL, + version character varying NOT NULL, + week date NOT NULL +); + + +-- +-- Name: usdc_purchases; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.usdc_purchases ( + slot integer NOT NULL, + signature character varying NOT NULL, + buyer_user_id integer NOT NULL, + seller_user_id integer NOT NULL, + amount bigint NOT NULL, + content_type public.usdc_purchase_content_type NOT NULL, + content_id integer NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + extra_amount bigint DEFAULT 0 NOT NULL, + access public.usdc_purchase_access_type DEFAULT 'stream'::public.usdc_purchase_access_type NOT NULL, + city character varying, + region character varying, + country character varying, + vendor character varying, + splits jsonb NOT NULL +); + + +-- +-- Name: usdc_transactions_history; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.usdc_transactions_history ( + user_bank character varying NOT NULL, + slot integer NOT NULL, + signature character varying NOT NULL, + transaction_type character varying NOT NULL, + method character varying NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + transaction_created_at timestamp without time zone NOT NULL, + change numeric NOT NULL, + balance numeric NOT NULL, + tx_metadata character varying +); + + +-- +-- Name: usdc_user_bank_accounts; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.usdc_user_bank_accounts ( + signature character varying NOT NULL, + ethereum_address character varying NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + bank_account character varying NOT NULL +); + + +-- +-- Name: user_balance_changes; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.user_balance_changes ( + user_id integer NOT NULL, + blocknumber integer NOT NULL, + current_balance character varying NOT NULL, + previous_balance character varying NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); + + +-- +-- Name: user_balance_changes_user_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.user_balance_changes_user_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: user_balance_changes_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.user_balance_changes_user_id_seq OWNED BY public.user_balance_changes.user_id; + + +-- +-- Name: user_balance_history; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.user_balance_history ( + user_id integer NOT NULL, + mint text NOT NULL, + "timestamp" timestamp without time zone NOT NULL, + balance bigint NOT NULL, + balance_usd double precision NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); + + +-- +-- Name: TABLE user_balance_history; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.user_balance_history IS 'Stores historical snapshots of user token balances per mint, binned hourly by timestamp'; + + +-- +-- Name: COLUMN user_balance_history.user_id; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.user_balance_history.user_id IS 'The user ID this balance snapshot belongs to'; + + +-- +-- Name: COLUMN user_balance_history.mint; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.user_balance_history.mint IS 'The token mint address'; + + +-- +-- Name: COLUMN user_balance_history."timestamp"; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.user_balance_history."timestamp" IS 'The binned timestamp (hourly) for this balance snapshot'; + + +-- +-- Name: COLUMN user_balance_history.balance; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.user_balance_history.balance IS 'The raw token balance (in token units, accounting for decimals)'; + + +-- +-- Name: COLUMN user_balance_history.balance_usd; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.user_balance_history.balance_usd IS 'The USD value of this token balance at this timestamp'; + + +-- +-- Name: COLUMN user_balance_history.created_at; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.user_balance_history.created_at IS 'When this record was created'; + + +-- +-- Name: user_balances; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.user_balances ( + user_id integer NOT NULL, + balance character varying NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + associated_wallets_balance character varying DEFAULT '0'::character varying NOT NULL, + waudio character varying DEFAULT '0'::character varying, + associated_sol_wallets_balance character varying DEFAULT '0'::character varying NOT NULL +); + + +-- +-- Name: user_balances_user_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.user_balances_user_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: user_balances_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.user_balances_user_id_seq OWNED BY public.user_balances.user_id; + + +-- +-- Name: user_bank_accounts; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.user_bank_accounts ( + signature character varying NOT NULL, + ethereum_address character varying NOT NULL, + created_at timestamp without time zone NOT NULL, + bank_account character varying NOT NULL +); + + +-- +-- Name: user_bank_txs; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.user_bank_txs ( + signature character varying NOT NULL, + slot integer NOT NULL, + created_at timestamp without time zone NOT NULL +); + + +-- +-- Name: user_challenges; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.user_challenges ( + challenge_id character varying NOT NULL, + user_id integer NOT NULL, + specifier character varying NOT NULL, + is_complete boolean NOT NULL, + current_step_count integer, + completed_blocknumber integer, + amount integer DEFAULT 0 NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + completed_at timestamp without time zone +); + + +-- +-- Name: user_delist_statuses; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.user_delist_statuses ( + created_at timestamp with time zone NOT NULL, + user_id integer NOT NULL, + delisted boolean NOT NULL, + reason public.delist_user_reason NOT NULL +); + + +-- +-- Name: user_distinct_play_hours; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.user_distinct_play_hours ( + user_id integer NOT NULL, + hours_with_play integer DEFAULT 0 NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: TABLE user_distinct_play_hours; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.user_distinct_play_hours IS 'Tracks the number of distinct hours in which a user has listened to a track'; + + +-- +-- Name: user_distinct_play_tracks; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.user_distinct_play_tracks ( + user_id integer NOT NULL, + track_count integer DEFAULT 0 NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: TABLE user_distinct_play_tracks; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.user_distinct_play_tracks IS 'Tracks the number of distinct tracks a user has listened to'; + + +-- +-- Name: user_events; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.user_events ( + id integer NOT NULL, + blockhash character varying, + blocknumber integer, + is_current boolean NOT NULL, + user_id integer NOT NULL, + referrer integer, + is_mobile_user boolean DEFAULT false NOT NULL, + slot integer +); + + +-- +-- Name: user_events_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.user_events_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: user_events_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.user_events_id_seq OWNED BY public.user_events.id; + + +-- +-- Name: user_listening_history; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.user_listening_history ( + user_id integer NOT NULL, + listening_history jsonb NOT NULL +); + + +-- +-- Name: user_listening_history_user_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.user_listening_history_user_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: user_listening_history_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.user_listening_history_user_id_seq OWNED BY public.user_listening_history.user_id; + + +-- +-- Name: user_payout_wallet_history; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.user_payout_wallet_history ( + user_id integer NOT NULL, + spl_usdc_payout_wallet character varying, + blocknumber integer NOT NULL, + block_timestamp timestamp without time zone NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); + + +-- +-- Name: user_pubkeys; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.user_pubkeys ( + user_id integer NOT NULL, + pubkey_base64 text NOT NULL +); + + +-- +-- Name: user_score_features; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.user_score_features ( + user_id integer NOT NULL, + challenge_count integer DEFAULT 0, + updated_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: TABLE user_score_features; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.user_score_features IS 'Tracks some features used in user score calculation'; + + +-- +-- Name: COLUMN user_score_features.challenge_count; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.user_score_features.challenge_count IS 'Tracks the number of fast challenges auser has completed'; + + +-- +-- Name: user_tips; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.user_tips ( + slot integer NOT NULL, + signature character varying NOT NULL, + sender_user_id integer NOT NULL, + receiver_user_id integer NOT NULL, + amount bigint NOT NULL, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); + + +-- +-- Name: v_challenge_disbursements; Type: VIEW; Schema: public; Owner: - +-- + +CREATE VIEW public.v_challenge_disbursements AS + SELECT rd.challenge_id, + rd.specifier, + (rd.amount)::text AS amount, + rd.signature, + rd.slot, + rd.created_at, + users.user_id + FROM (public.sol_reward_disbursements rd + JOIN public.users ON (((lower((users.wallet)::text) = rd.recipient_eth_address) AND (users.is_current = true)))); + + +-- +-- Name: VIEW v_challenge_disbursements; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON VIEW public.v_challenge_disbursements IS 'Compatibility view that exposes sol_reward_disbursements in the column shape the API routes used to read from challenge_disbursements. Resolves user_id via the indexer-populated recipient_eth_address (see migration 0172). Join uses LOWER(users.wallet) because the Go indexer stores recipient_eth_address as lowercase.'; + + +-- +-- Name: v_token_transactions_history; Type: VIEW; Schema: public; Owner: - +-- + +CREATE VIEW public.v_token_transactions_history AS + SELECT bc.signature, + bc.mint, + bc.account AS user_bank, + users.user_id, + bc.block_timestamp AS transaction_date, + bc.created_at, + bc.slot, + (abs(bc.change))::text AS change, + (bc.balance)::text AS balance, + CASE + WHEN (bc.change < 0) THEN 'send'::text + ELSE 'receive'::text + END AS method, + CASE + WHEN (rd.signature IS NOT NULL) THEN + CASE + WHEN (c.type = 'trending'::public.challengetype) THEN 'trending_reward'::text + ELSE 'user_reward'::text + END + WHEN (p.signature IS NOT NULL) THEN 'purchase_content'::text + WHEN (tmt.memo_type IS NOT NULL) THEN (tmt.memo_type)::text + WHEN ((cat.signature IS NOT NULL) AND (from_owner.user_id IS NOT NULL) AND (to_owner.user_id IS NOT NULL) AND (from_owner.user_id <> to_owner.user_id)) THEN 'tip'::text + WHEN (cat.signature IS NOT NULL) THEN 'transfer'::text + ELSE 'transfer'::text + END AS transaction_type, + CASE + WHEN (rd.signature IS NOT NULL) THEN rd.challenge_id + WHEN (((tmt.memo_type)::text = 'withdrawal'::text) AND (cat.to_account IS NOT NULL)) THEN cat.to_account + WHEN ((cat.signature IS NOT NULL) AND (bc.change > 0) AND (from_owner.user_id IS NOT NULL)) THEN ((from_owner.user_id)::text)::character varying + WHEN ((cat.signature IS NOT NULL) AND (bc.change < 0) AND (to_owner.user_id IS NOT NULL)) THEN ((to_owner.user_id)::text)::character varying + ELSE NULL::character varying + END AS tx_metadata + FROM (((((((((((public.sol_token_account_balance_changes bc + JOIN public.sol_claimable_accounts sca ON ((((sca.account)::text = (bc.account)::text) AND ((sca.mint)::text = (bc.mint)::text)))) + LEFT JOIN public.users ON ((((users.wallet)::text = (sca.ethereum_address)::text) AND (users.is_current = true)))) + LEFT JOIN public.sol_claimable_account_transfers cat ON ((((cat.signature)::text = (bc.signature)::text) AND (((cat.from_account)::text = (bc.account)::text) OR ((cat.to_account)::text = (bc.account)::text))))) + LEFT JOIN public.sol_claimable_accounts from_sca ON ((((from_sca.account)::text = (cat.from_account)::text) AND ((from_sca.mint)::text = (bc.mint)::text)))) + LEFT JOIN public.users from_owner ON ((((from_owner.wallet)::text = (from_sca.ethereum_address)::text) AND (from_owner.is_current = true)))) + LEFT JOIN public.sol_claimable_accounts to_sca ON ((((to_sca.account)::text = (cat.to_account)::text) AND ((to_sca.mint)::text = (bc.mint)::text)))) + LEFT JOIN public.users to_owner ON ((((to_owner.wallet)::text = (to_sca.ethereum_address)::text) AND (to_owner.is_current = true)))) + LEFT JOIN public.sol_reward_disbursements rd ON ((((rd.signature)::text = (bc.signature)::text) AND ((rd.user_bank)::text = (bc.account)::text)))) + LEFT JOIN public.challenges c ON (((c.id)::text = (rd.challenge_id)::text))) + LEFT JOIN public.sol_purchases p ON ((((p.signature)::text = (bc.signature)::text) AND ((p.from_account)::text = (bc.account)::text)))) + LEFT JOIN public.sol_transfer_memo_types tmt ON (((tmt.signature)::text = (bc.signature)::text))); + + +-- +-- Name: VIEW v_token_transactions_history; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON VIEW public.v_token_transactions_history IS 'Mint-agnostic transactions history derived from sol_token_account_balance_changes (the hub: only table with both mint and block_timestamp). Per-row transaction_type derived by LEFT JOIN to typed tables (sol_claimable_account_transfers, sol_reward_disbursements, sol_purchases, sol_transfer_memo_types). Callers filter by mint at query time. Vendor purchase types (PURCHASE_STRIPE/COINBASE/UNKNOWN) on AUDIO still degrade to bare transfer until the AUDIO mint subscription + vendor-memo capture land.'; + + +-- +-- Name: v_usdc_purchases; Type: VIEW; Schema: public; Owner: - +-- + +CREATE VIEW public.v_usdc_purchases AS + SELECT sp.signature, + sp.slot, + sp.buyer_user_id, + CASE sp.content_type + WHEN 'track'::text THEN t.owner_id + WHEN 'album'::text THEN p.playlist_owner_id + WHEN 'playlist'::text THEN p.playlist_owner_id + ELSE NULL::integer + END AS seller_user_id, + sp.amount, + (sp.content_type)::public.usdc_purchase_content_type AS content_type, + sp.content_id, + sp.created_at, + sp.created_at AS updated_at, + GREATEST((sp.amount - COALESCE( + CASE sp.content_type + WHEN 'track'::text THEN ( SELECT (tph.total_price_cents * 10000) + FROM public.track_price_history tph + WHERE ((tph.track_id = sp.content_id) AND (tph.block_timestamp <= sp.created_at)) + ORDER BY tph.block_timestamp DESC + LIMIT 1) + ELSE ( SELECT (aph.total_price_cents * 10000) + FROM public.album_price_history aph + WHERE ((aph.playlist_id = sp.content_id) AND (aph.block_timestamp <= sp.created_at)) + ORDER BY aph.block_timestamp DESC + LIMIT 1) + END, sp.amount)), (0)::bigint) AS extra_amount, + (sp.access_type)::public.usdc_purchase_access_type AS access, + sp.city, + sp.region, + sp.country, + ( SELECT COALESCE(jsonb_agg(jsonb_build_object('user_id', COALESCE(u_payout.user_id, u_sca.user_id), 'payout_wallet', pay.to_account, 'amount', pay.amount, 'percentage', (((pay.amount)::numeric * 100.0) / (NULLIF(sp.amount, 0))::numeric)) ORDER BY pay.route_index), '[]'::jsonb) AS "coalesce" + FROM (((public.sol_payments pay + LEFT JOIN LATERAL ( SELECT upwh.user_id + FROM public.user_payout_wallet_history upwh + WHERE (((upwh.spl_usdc_payout_wallet)::text = (pay.to_account)::text) AND (upwh.block_timestamp <= sp.created_at)) + ORDER BY upwh.block_timestamp DESC + LIMIT 1) u_payout ON (true)) + LEFT JOIN public.sol_claimable_accounts sca ON ((((sca.account)::text = (pay.to_account)::text) AND ((sca.mint)::text = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'::text)))) + LEFT JOIN public.users u_sca ON ((((u_sca.wallet)::text = (sca.ethereum_address)::text) AND (u_sca.is_current = true)))) + WHERE (((pay.signature)::text = (sp.signature)::text) AND (pay.instruction_index = sp.instruction_index))) AS splits + FROM ((public.sol_purchases sp + LEFT JOIN public.tracks t ON ((((sp.content_type)::text = 'track'::text) AND (t.track_id = sp.content_id) AND (t.is_current = true)))) + LEFT JOIN public.playlists p ON ((((sp.content_type)::text = ANY (ARRAY[('album'::character varying)::text, ('playlist'::character varying)::text])) AND (p.playlist_id = sp.content_id) AND (p.is_current = true)))) + WHERE (sp.is_valid IS TRUE); + + +-- +-- Name: VIEW v_usdc_purchases; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON VIEW public.v_usdc_purchases IS 'Compatibility view exposing sol_purchases + sol_payments in the column shape API routes used to read from usdc_purchases. seller_user_id is the current content owner (not snapshotted at purchase time). extra_amount is amount paid minus base price from price history. vendor is intentionally dropped.'; + + +-- +-- Name: v_user_balances; Type: VIEW; Schema: public; Owner: - +-- + +CREATE VIEW public.v_user_balances AS + SELECT u.user_id, + (COALESCE(eub.balance, (0)::numeric))::character varying AS eth_balance, + (COALESCE(sub.balance, (0)::bigint))::character varying AS sol_balance, + GREATEST(COALESCE(eub.updated_at, '1970-01-01 00:00:00'::timestamp without time zone), COALESCE(sub.updated_at, '1970-01-01 00:00:00'::timestamp without time zone)) AS updated_at + FROM ((public.users u + LEFT JOIN public.sol_user_balances sub ON (((sub.user_id = u.user_id) AND (sub.mint = '9LzCMqDgTKYz9Drzqnpgee3SGa89up3a247ypMj2xrqM'::text)))) + LEFT JOIN public.eth_user_balances eub ON ((eub.user_id = u.user_id))) + WHERE (u.is_current = true); + + +-- +-- Name: VIEW v_user_balances; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON VIEW public.v_user_balances IS 'Per-user AUDIO/wAUDIO balance totals. One row per current user with eth_balance (wei) and sol_balance (wAUDIO base units, 8 decimals — multiply by 10^10 to compare to wei). eth_balance is eth_user_balances (pre-aggregated across users.wallet + chain=eth associated_wallets, maintained by handle_eth_wallet_balance_change / handle_associated_wallets). sol_balance is sol_user_balances for the wAUDIO mint, pre-aggregated across user_bank PDAs + linked Solana wallets by handle_sol_claimable_accounts / update_sol_user_balance triggers.'; + + +-- +-- Name: volume_leader_exclusions; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.volume_leader_exclusions ( + address text NOT NULL, + description text +); + + +-- +-- Name: aggregate_daily_app_name_metrics id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.aggregate_daily_app_name_metrics ALTER COLUMN id SET DEFAULT nextval('public.aggregate_daily_app_name_metrics_id_seq'::regclass); + + +-- +-- Name: aggregate_daily_total_users_metrics id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.aggregate_daily_total_users_metrics ALTER COLUMN id SET DEFAULT nextval('public.aggregate_daily_total_users_metrics_id_seq'::regclass); + + +-- +-- Name: aggregate_daily_unique_users_metrics id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.aggregate_daily_unique_users_metrics ALTER COLUMN id SET DEFAULT nextval('public.aggregate_daily_unique_users_metrics_id_seq'::regclass); + + +-- +-- Name: aggregate_monthly_app_name_metrics id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.aggregate_monthly_app_name_metrics ALTER COLUMN id SET DEFAULT nextval('public.aggregate_monthly_app_name_metrics_id_seq'::regclass); + + +-- +-- Name: aggregate_monthly_total_users_metrics id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.aggregate_monthly_total_users_metrics ALTER COLUMN id SET DEFAULT nextval('public.aggregate_monthly_total_users_metrics_id_seq'::regclass); + + +-- +-- Name: aggregate_monthly_unique_users_metrics id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.aggregate_monthly_unique_users_metrics ALTER COLUMN id SET DEFAULT nextval('public.aggregate_monthly_unique_users_metrics_id_seq'::regclass); + + +-- +-- Name: associated_wallets id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.associated_wallets ALTER COLUMN id SET DEFAULT nextval('public.associated_wallets_id_seq'::regclass); + + +-- +-- Name: challenge_listen_streak user_id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.challenge_listen_streak ALTER COLUMN user_id SET DEFAULT nextval('public.challenge_listen_streak_user_id_seq'::regclass); + + +-- +-- Name: challenge_profile_completion user_id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.challenge_profile_completion ALTER COLUMN user_id SET DEFAULT nextval('public.challenge_profile_completion_user_id_seq'::regclass); + + +-- +-- Name: claimed_prizes id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.claimed_prizes ALTER COLUMN id SET DEFAULT nextval('public.claimed_prizes_id_seq'::regclass); + + +-- +-- Name: email_access id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.email_access ALTER COLUMN id SET DEFAULT nextval('public.email_access_id_seq'::regclass); + + +-- +-- Name: encrypted_emails id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.encrypted_emails ALTER COLUMN id SET DEFAULT nextval('public.encrypted_emails_id_seq'::regclass); + + +-- +-- Name: eth_blocks last_scanned_block; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.eth_blocks ALTER COLUMN last_scanned_block SET DEFAULT nextval('public.eth_blocks_last_scanned_block_seq'::regclass); + + +-- +-- Name: etl_addresses id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.etl_addresses ALTER COLUMN id SET DEFAULT nextval('public.etl_addresses_id_seq'::regclass); + + +-- +-- Name: etl_blocks id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.etl_blocks ALTER COLUMN id SET DEFAULT nextval('public.etl_blocks_id_seq'::regclass); + + +-- +-- Name: etl_manage_entities id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.etl_manage_entities ALTER COLUMN id SET DEFAULT nextval('public.etl_manage_entities_id_seq'::regclass); + + +-- +-- Name: etl_plays id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.etl_plays ALTER COLUMN id SET DEFAULT nextval('public.etl_plays_id_seq'::regclass); + + +-- +-- Name: etl_sla_node_reports id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.etl_sla_node_reports ALTER COLUMN id SET DEFAULT nextval('public.etl_sla_node_reports_id_seq'::regclass); + + +-- +-- Name: etl_sla_rollups id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.etl_sla_rollups ALTER COLUMN id SET DEFAULT nextval('public.etl_sla_rollups_id_seq'::regclass); + + +-- +-- Name: etl_storage_proof_verifications id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.etl_storage_proof_verifications ALTER COLUMN id SET DEFAULT nextval('public.etl_storage_proof_verifications_id_seq'::regclass); + + +-- +-- Name: etl_storage_proofs id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.etl_storage_proofs ALTER COLUMN id SET DEFAULT nextval('public.etl_storage_proofs_id_seq'::regclass); + + +-- +-- Name: etl_transactions id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.etl_transactions ALTER COLUMN id SET DEFAULT nextval('public.etl_transactions_id_seq'::regclass); + + +-- +-- Name: etl_validator_deregistrations id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.etl_validator_deregistrations ALTER COLUMN id SET DEFAULT nextval('public.etl_validator_deregistrations_id_seq'::regclass); + + +-- +-- Name: etl_validator_misbehavior_deregistrations id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.etl_validator_misbehavior_deregistrations ALTER COLUMN id SET DEFAULT nextval('public.etl_validator_misbehavior_deregistrations_id_seq'::regclass); + + +-- +-- Name: etl_validator_registrations id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.etl_validator_registrations ALTER COLUMN id SET DEFAULT nextval('public.etl_validator_registrations_id_seq'::regclass); + + +-- +-- Name: etl_validators id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.etl_validators ALTER COLUMN id SET DEFAULT nextval('public.etl_validators_id_seq'::regclass); + + +-- +-- Name: new_chain_queue id; Type: DEFAULT; Schema: public; Owner: - -- -CREATE TABLE public.track_routes ( - slug character varying NOT NULL, - title_slug character varying NOT NULL, - collision_id integer NOT NULL, - owner_id integer NOT NULL, - track_id integer NOT NULL, - is_current boolean NOT NULL, - blockhash character varying NOT NULL, - blocknumber integer NOT NULL, - txhash character varying NOT NULL -); +ALTER TABLE ONLY public.new_chain_queue ALTER COLUMN id SET DEFAULT nextval('public.new_chain_queue_id_seq'::regclass); -- --- Name: track_trending_scores; Type: TABLE; Schema: public; Owner: - +-- Name: notification id; Type: DEFAULT; Schema: public; Owner: - -- -CREATE TABLE public.track_trending_scores ( - track_id integer NOT NULL, - type character varying NOT NULL, - genre character varying, - version character varying NOT NULL, - time_range character varying NOT NULL, - score double precision NOT NULL, - created_at timestamp without time zone NOT NULL -); +ALTER TABLE ONLY public.notification ALTER COLUMN id SET DEFAULT nextval('public.notification_id_seq'::regclass); -- --- Name: users; Type: TABLE; Schema: public; Owner: - +-- Name: oauth_redirect_uris id; Type: DEFAULT; Schema: public; Owner: - -- -CREATE TABLE public.users ( - blockhash character varying, - user_id integer NOT NULL, - is_current boolean NOT NULL, - handle character varying, - wallet character varying, - name text, - profile_picture character varying, - cover_photo character varying, - bio character varying, - location character varying, - metadata_multihash character varying, - creator_node_endpoint character varying, - blocknumber integer, - is_verified boolean DEFAULT false NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - handle_lc character varying, - cover_photo_sizes character varying, - profile_picture_sizes character varying, - primary_id integer, - secondary_ids integer[], - replica_set_update_signer character varying, - has_collectibles boolean DEFAULT false NOT NULL, - txhash character varying DEFAULT ''::character varying NOT NULL, - playlist_library jsonb, - is_deactivated boolean DEFAULT false NOT NULL, - slot integer, - user_storage_account character varying, - user_authority_account character varying, - artist_pick_track_id integer, - is_available boolean DEFAULT true NOT NULL, - is_storage_v2 boolean DEFAULT false NOT NULL, - allow_ai_attribution boolean DEFAULT false NOT NULL, - spl_usdc_payout_wallet character varying, - twitter_handle character varying, - instagram_handle character varying, - tiktok_handle character varying, - verified_with_twitter boolean DEFAULT false, - verified_with_instagram boolean DEFAULT false, - verified_with_tiktok boolean DEFAULT false, - website character varying, - donation character varying, - profile_type public.profile_type_enum, - coin_flair_mint text, - last_active_at timestamp with time zone -); +ALTER TABLE ONLY public.oauth_redirect_uris ALTER COLUMN id SET DEFAULT nextval('public.oauth_redirect_uris_id_seq'::regclass); -- --- Name: COLUMN users.coin_flair_mint; Type: COMMENT; Schema: public; Owner: - +-- Name: plays id; Type: DEFAULT; Schema: public; Owner: - -- -COMMENT ON COLUMN public.users.coin_flair_mint IS 'The mint of the coin which the user has selected as their preferred flair. NULL for auto, empty string for none.'; +ALTER TABLE ONLY public.plays ALTER COLUMN id SET DEFAULT nextval('public.plays_id_seq'::regclass); -- --- Name: COLUMN users.last_active_at; Type: COMMENT; Schema: public; Owner: - +-- Name: prizes id; Type: DEFAULT; Schema: public; Owner: - -- -COMMENT ON COLUMN public.users.last_active_at IS 'Timestamp of the user''s most recent app-open event, updated by POST /v1/users/me/ping.'; +ALTER TABLE ONLY public.prizes ALTER COLUMN id SET DEFAULT nextval('public.prizes_id_seq'::regclass); -- --- Name: trending_params; Type: MATERIALIZED VIEW; Schema: public; Owner: - +-- Name: reactions id; Type: DEFAULT; Schema: public; Owner: - -- -CREATE MATERIALIZED VIEW public.trending_params AS - SELECT t.track_id, - t.release_date, - t.genre, - t.owner_id, - ap.play_count, - au.follower_count AS owner_follower_count, - COALESCE(aggregate_track.repost_count, 0) AS repost_count, - COALESCE(aggregate_track.save_count, 0) AS save_count, - COALESCE(repost_week.repost_count, (0)::bigint) AS repost_week_count, - COALESCE(repost_month.repost_count, (0)::bigint) AS repost_month_count, - COALESCE(repost_year.repost_count, (0)::bigint) AS repost_year_count, - COALESCE(save_week.repost_count, (0)::bigint) AS save_week_count, - COALESCE(save_month.repost_count, (0)::bigint) AS save_month_count, - COALESCE(save_year.repost_count, (0)::bigint) AS save_year_count, - COALESCE(karma.karma, (0)::numeric) AS karma - FROM ((((((((((public.tracks t - LEFT JOIN ( SELECT ap_1.count AS play_count, - ap_1.play_item_id - FROM public.aggregate_plays ap_1) ap ON ((ap.play_item_id = t.track_id))) - LEFT JOIN ( SELECT au_1.user_id, - au_1.follower_count - FROM public.aggregate_user au_1) au ON ((au.user_id = t.owner_id))) - LEFT JOIN ( SELECT aggregate_track_1.track_id, - aggregate_track_1.repost_count, - aggregate_track_1.save_count - FROM public.aggregate_track aggregate_track_1) aggregate_track ON ((aggregate_track.track_id = t.track_id))) - LEFT JOIN ( SELECT r.repost_item_id AS track_id, - count(r.repost_item_id) AS repost_count - FROM public.reposts r - WHERE ((r.is_current IS TRUE) AND (r.repost_type = 'track'::public.reposttype) AND (r.is_delete IS FALSE) AND (r.created_at > (now() - '1 year'::interval))) - GROUP BY r.repost_item_id) repost_year ON ((repost_year.track_id = t.track_id))) - LEFT JOIN ( SELECT r.repost_item_id AS track_id, - count(r.repost_item_id) AS repost_count - FROM public.reposts r - WHERE ((r.is_current IS TRUE) AND (r.repost_type = 'track'::public.reposttype) AND (r.is_delete IS FALSE) AND (r.created_at > (now() - '1 mon'::interval))) - GROUP BY r.repost_item_id) repost_month ON ((repost_month.track_id = t.track_id))) - LEFT JOIN ( SELECT r.repost_item_id AS track_id, - count(r.repost_item_id) AS repost_count - FROM public.reposts r - WHERE ((r.is_current IS TRUE) AND (r.repost_type = 'track'::public.reposttype) AND (r.is_delete IS FALSE) AND (r.created_at > (now() - '7 days'::interval))) - GROUP BY r.repost_item_id) repost_week ON ((repost_week.track_id = t.track_id))) - LEFT JOIN ( SELECT r.save_item_id AS track_id, - count(r.save_item_id) AS repost_count - FROM public.saves r - WHERE ((r.is_current IS TRUE) AND (r.save_type = 'track'::public.savetype) AND (r.is_delete IS FALSE) AND (r.created_at > (now() - '1 year'::interval))) - GROUP BY r.save_item_id) save_year ON ((save_year.track_id = t.track_id))) - LEFT JOIN ( SELECT r.save_item_id AS track_id, - count(r.save_item_id) AS repost_count - FROM public.saves r - WHERE ((r.is_current IS TRUE) AND (r.save_type = 'track'::public.savetype) AND (r.is_delete IS FALSE) AND (r.created_at > (now() - '1 mon'::interval))) - GROUP BY r.save_item_id) save_month ON ((save_month.track_id = t.track_id))) - LEFT JOIN ( SELECT r.save_item_id AS track_id, - count(r.save_item_id) AS repost_count - FROM public.saves r - WHERE ((r.is_current IS TRUE) AND (r.save_type = 'track'::public.savetype) AND (r.is_delete IS FALSE) AND (r.created_at > (now() - '7 days'::interval))) - GROUP BY r.save_item_id) save_week ON ((save_week.track_id = t.track_id))) - LEFT JOIN ( SELECT save_and_reposts.item_id AS track_id, - sum(au_1.follower_count) AS karma - FROM (( SELECT r_and_s.user_id, - r_and_s.item_id - FROM (( SELECT reposts.user_id, - reposts.repost_item_id AS item_id - FROM public.reposts - WHERE ((reposts.is_delete IS FALSE) AND (reposts.is_current IS TRUE) AND (reposts.repost_type = 'track'::public.reposttype)) - UNION ALL - SELECT saves.user_id, - saves.save_item_id AS item_id - FROM public.saves - WHERE ((saves.is_delete IS FALSE) AND (saves.is_current IS TRUE) AND (saves.save_type = 'track'::public.savetype))) r_and_s - JOIN public.users ON ((r_and_s.user_id = users.user_id))) - WHERE (((users.cover_photo IS NOT NULL) OR (users.cover_photo_sizes IS NOT NULL)) AND ((users.profile_picture IS NOT NULL) OR (users.profile_picture_sizes IS NOT NULL)) AND (users.bio IS NOT NULL))) save_and_reposts - JOIN public.aggregate_user au_1 ON ((save_and_reposts.user_id = au_1.user_id))) - GROUP BY save_and_reposts.item_id) karma ON ((karma.track_id = t.track_id))) - WHERE ((t.is_current IS TRUE) AND (t.is_delete IS FALSE) AND (t.is_unlisted IS FALSE) AND (t.stem_of IS NULL)) - WITH NO DATA; +ALTER TABLE ONLY public.reactions ALTER COLUMN id SET DEFAULT nextval('public.reactions_id_seq'::regclass); -- --- Name: trending_results; Type: TABLE; Schema: public; Owner: - +-- Name: skipped_transactions id; Type: DEFAULT; Schema: public; Owner: - -- -CREATE TABLE public.trending_results ( - user_id integer NOT NULL, - id character varying, - rank integer NOT NULL, - type character varying NOT NULL, - version character varying NOT NULL, - week date NOT NULL -); +ALTER TABLE ONLY public.skipped_transactions ALTER COLUMN id SET DEFAULT nextval('public.skipped_transactions_id_seq'::regclass); -- --- Name: usdc_purchases; Type: TABLE; Schema: public; Owner: - +-- Name: user_balance_changes user_id; Type: DEFAULT; Schema: public; Owner: - -- -CREATE TABLE public.usdc_purchases ( - slot integer NOT NULL, - signature character varying NOT NULL, - buyer_user_id integer NOT NULL, - seller_user_id integer NOT NULL, - amount bigint NOT NULL, - content_type public.usdc_purchase_content_type NOT NULL, - content_id integer NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - extra_amount bigint DEFAULT 0 NOT NULL, - access public.usdc_purchase_access_type DEFAULT 'stream'::public.usdc_purchase_access_type NOT NULL, - city character varying, - region character varying, - country character varying, - vendor character varying, - splits jsonb NOT NULL -); +ALTER TABLE ONLY public.user_balance_changes ALTER COLUMN user_id SET DEFAULT nextval('public.user_balance_changes_user_id_seq'::regclass); -- --- Name: usdc_transactions_history; Type: TABLE; Schema: public; Owner: - +-- Name: user_balances user_id; Type: DEFAULT; Schema: public; Owner: - -- -CREATE TABLE public.usdc_transactions_history ( - user_bank character varying NOT NULL, - slot integer NOT NULL, - signature character varying NOT NULL, - transaction_type character varying NOT NULL, - method character varying NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - transaction_created_at timestamp without time zone NOT NULL, - change numeric NOT NULL, - balance numeric NOT NULL, - tx_metadata character varying -); +ALTER TABLE ONLY public.user_balances ALTER COLUMN user_id SET DEFAULT nextval('public.user_balances_user_id_seq'::regclass); -- --- Name: usdc_user_bank_accounts; Type: TABLE; Schema: public; Owner: - +-- Name: user_events id; Type: DEFAULT; Schema: public; Owner: - -- -CREATE TABLE public.usdc_user_bank_accounts ( - signature character varying NOT NULL, - ethereum_address character varying NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - bank_account character varying NOT NULL -); +ALTER TABLE ONLY public.user_events ALTER COLUMN id SET DEFAULT nextval('public.user_events_id_seq'::regclass); -- --- Name: user_balance_changes; Type: TABLE; Schema: public; Owner: - +-- Name: user_listening_history user_id; Type: DEFAULT; Schema: public; Owner: - -- -CREATE TABLE public.user_balance_changes ( - user_id integer NOT NULL, - blocknumber integer NOT NULL, - current_balance character varying NOT NULL, - previous_balance character varying NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); +ALTER TABLE ONLY public.user_listening_history ALTER COLUMN user_id SET DEFAULT nextval('public.user_listening_history_user_id_seq'::regclass); -- --- Name: user_balance_changes_user_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- Name: SequelizeMeta SequelizeMeta_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE SEQUENCE public.user_balance_changes_user_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; +ALTER TABLE ONLY public."SequelizeMeta" + ADD CONSTRAINT "SequelizeMeta_pkey" PRIMARY KEY (name); -- --- Name: user_balance_changes_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- Name: aggregate_daily_app_name_metrics aggregate_daily_app_name_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER SEQUENCE public.user_balance_changes_user_id_seq OWNED BY public.user_balance_changes.user_id; +ALTER TABLE ONLY public.aggregate_daily_app_name_metrics + ADD CONSTRAINT aggregate_daily_app_name_metrics_pkey PRIMARY KEY (id); + + +-- +-- Name: aggregate_daily_total_users_metrics aggregate_daily_total_users_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.aggregate_daily_total_users_metrics + ADD CONSTRAINT aggregate_daily_total_users_metrics_pkey PRIMARY KEY (id); -- --- Name: user_balance_history; Type: TABLE; Schema: public; Owner: - +-- Name: aggregate_daily_unique_users_metrics aggregate_daily_unique_users_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE TABLE public.user_balance_history ( - user_id integer NOT NULL, - mint text NOT NULL, - "timestamp" timestamp without time zone NOT NULL, - balance bigint NOT NULL, - balance_usd double precision NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); +ALTER TABLE ONLY public.aggregate_daily_unique_users_metrics + ADD CONSTRAINT aggregate_daily_unique_users_metrics_pkey PRIMARY KEY (id); -- --- Name: TABLE user_balance_history; Type: COMMENT; Schema: public; Owner: - +-- Name: aggregate_monthly_app_name_metrics aggregate_monthly_app_name_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -COMMENT ON TABLE public.user_balance_history IS 'Stores historical snapshots of user token balances per mint, binned hourly by timestamp'; +ALTER TABLE ONLY public.aggregate_monthly_app_name_metrics + ADD CONSTRAINT aggregate_monthly_app_name_metrics_pkey PRIMARY KEY (id); -- --- Name: COLUMN user_balance_history.user_id; Type: COMMENT; Schema: public; Owner: - +-- Name: aggregate_monthly_plays aggregate_monthly_plays_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -COMMENT ON COLUMN public.user_balance_history.user_id IS 'The user ID this balance snapshot belongs to'; +ALTER TABLE ONLY public.aggregate_monthly_plays + ADD CONSTRAINT aggregate_monthly_plays_pkey PRIMARY KEY (play_item_id, "timestamp", country); -- --- Name: COLUMN user_balance_history.mint; Type: COMMENT; Schema: public; Owner: - +-- Name: aggregate_monthly_total_users_metrics aggregate_monthly_total_users_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -COMMENT ON COLUMN public.user_balance_history.mint IS 'The token mint address'; +ALTER TABLE ONLY public.aggregate_monthly_total_users_metrics + ADD CONSTRAINT aggregate_monthly_total_users_metrics_pkey PRIMARY KEY (id); -- --- Name: COLUMN user_balance_history."timestamp"; Type: COMMENT; Schema: public; Owner: - +-- Name: aggregate_monthly_unique_users_metrics aggregate_monthly_unique_users_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -COMMENT ON COLUMN public.user_balance_history."timestamp" IS 'The binned timestamp (hourly) for this balance snapshot'; +ALTER TABLE ONLY public.aggregate_monthly_unique_users_metrics + ADD CONSTRAINT aggregate_monthly_unique_users_metrics_pkey PRIMARY KEY (id); -- --- Name: COLUMN user_balance_history.balance; Type: COMMENT; Schema: public; Owner: - +-- Name: aggregate_playlist aggregate_playlist_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -COMMENT ON COLUMN public.user_balance_history.balance IS 'The raw token balance (in token units, accounting for decimals)'; +ALTER TABLE ONLY public.aggregate_playlist + ADD CONSTRAINT aggregate_playlist_pkey PRIMARY KEY (playlist_id); -- --- Name: COLUMN user_balance_history.balance_usd; Type: COMMENT; Schema: public; Owner: - +-- Name: aggregate_track aggregate_track_table_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -COMMENT ON COLUMN public.user_balance_history.balance_usd IS 'The USD value of this token balance at this timestamp'; +ALTER TABLE ONLY public.aggregate_track + ADD CONSTRAINT aggregate_track_table_pkey PRIMARY KEY (track_id); -- --- Name: COLUMN user_balance_history.created_at; Type: COMMENT; Schema: public; Owner: - +-- Name: aggregate_user aggregate_user_table_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -COMMENT ON COLUMN public.user_balance_history.created_at IS 'When this record was created'; +ALTER TABLE ONLY public.aggregate_user + ADD CONSTRAINT aggregate_user_table_pkey PRIMARY KEY (user_id); -- --- Name: user_balances; Type: TABLE; Schema: public; Owner: - +-- Name: aggregate_user_tips aggregate_user_tips_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE TABLE public.user_balances ( - user_id integer NOT NULL, - balance character varying NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - associated_wallets_balance character varying DEFAULT '0'::character varying NOT NULL, - waudio character varying DEFAULT '0'::character varying, - associated_sol_wallets_balance character varying DEFAULT '0'::character varying NOT NULL -); +ALTER TABLE ONLY public.aggregate_user_tips + ADD CONSTRAINT aggregate_user_tips_pkey PRIMARY KEY (sender_user_id, receiver_user_id); -- --- Name: user_balances_user_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- Name: album_price_history album_price_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE SEQUENCE public.user_balances_user_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; +ALTER TABLE ONLY public.album_price_history + ADD CONSTRAINT album_price_history_pkey PRIMARY KEY (playlist_id, block_timestamp); -- --- Name: user_balances_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- Name: api_access_keys api_access_keys_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER SEQUENCE public.user_balances_user_id_seq OWNED BY public.user_balances.user_id; +ALTER TABLE ONLY public.api_access_keys + ADD CONSTRAINT api_access_keys_pkey PRIMARY KEY (api_key, api_access_key); -- --- Name: user_bank_accounts; Type: TABLE; Schema: public; Owner: - +-- Name: api_keys api_keys_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE TABLE public.user_bank_accounts ( - signature character varying NOT NULL, - ethereum_address character varying NOT NULL, - created_at timestamp without time zone NOT NULL, - bank_account character varying NOT NULL -); +ALTER TABLE ONLY public.api_keys + ADD CONSTRAINT api_keys_pkey PRIMARY KEY (api_key); -- --- Name: user_bank_txs; Type: TABLE; Schema: public; Owner: - +-- Name: api_metrics_apps api_metrics_apps_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE TABLE public.user_bank_txs ( - signature character varying NOT NULL, - slot integer NOT NULL, - created_at timestamp without time zone NOT NULL -); +ALTER TABLE ONLY public.api_metrics_apps + ADD CONSTRAINT api_metrics_apps_pkey PRIMARY KEY (date, api_key, app_name); -- --- Name: user_challenges; Type: TABLE; Schema: public; Owner: - +-- Name: api_metrics_apps_unique api_metrics_apps_unique_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE TABLE public.user_challenges ( - challenge_id character varying NOT NULL, - user_id integer NOT NULL, - specifier character varying NOT NULL, - is_complete boolean NOT NULL, - current_step_count integer, - completed_blocknumber integer, - amount integer DEFAULT 0 NOT NULL, - created_at timestamp with time zone DEFAULT now() NOT NULL, - completed_at timestamp without time zone -); +ALTER TABLE ONLY public.api_metrics_apps_unique + ADD CONSTRAINT api_metrics_apps_unique_pkey PRIMARY KEY (date, app_name); -- --- Name: user_delist_statuses; Type: TABLE; Schema: public; Owner: - +-- Name: api_metrics_counts api_metrics_counts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE TABLE public.user_delist_statuses ( - created_at timestamp with time zone NOT NULL, - user_id integer NOT NULL, - delisted boolean NOT NULL, - reason public.delist_user_reason NOT NULL -); +ALTER TABLE ONLY public.api_metrics_counts + ADD CONSTRAINT api_metrics_counts_pkey PRIMARY KEY (date); -- --- Name: user_distinct_play_hours; Type: TABLE; Schema: public; Owner: - +-- Name: api_metrics_routes api_metrics_routes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE TABLE public.user_distinct_play_hours ( - user_id integer NOT NULL, - hours_with_play integer DEFAULT 0 NOT NULL, - updated_at timestamp with time zone DEFAULT now() NOT NULL -); +ALTER TABLE ONLY public.api_metrics_routes + ADD CONSTRAINT api_metrics_routes_pkey PRIMARY KEY (date, route_pattern, method); -- --- Name: TABLE user_distinct_play_hours; Type: COMMENT; Schema: public; Owner: - +-- Name: app_name_metrics app_name_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -COMMENT ON TABLE public.user_distinct_play_hours IS 'Tracks the number of distinct hours in which a user has listened to a track'; +ALTER TABLE ONLY public.app_name_metrics + ADD CONSTRAINT app_name_metrics_pkey PRIMARY KEY (id); -- --- Name: user_distinct_play_tracks; Type: TABLE; Schema: public; Owner: - +-- Name: artist_coin_pools artist_coin_pools_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE TABLE public.user_distinct_play_tracks ( - user_id integer NOT NULL, - track_count integer DEFAULT 0 NOT NULL, - updated_at timestamp with time zone DEFAULT now() NOT NULL -); +ALTER TABLE ONLY public.artist_coin_pools + ADD CONSTRAINT artist_coin_pools_pkey PRIMARY KEY (address); -- --- Name: TABLE user_distinct_play_tracks; Type: COMMENT; Schema: public; Owner: - +-- Name: artist_coin_price_history artist_coin_price_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -COMMENT ON TABLE public.user_distinct_play_tracks IS 'Tracks the number of distinct tracks a user has listened to'; +ALTER TABLE ONLY public.artist_coin_price_history + ADD CONSTRAINT artist_coin_price_history_pkey PRIMARY KEY (mint, "timestamp"); -- --- Name: user_events; Type: TABLE; Schema: public; Owner: - +-- Name: artist_coin_stats artist_coin_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE TABLE public.user_events ( - id integer NOT NULL, - blockhash character varying, - blocknumber integer, - is_current boolean NOT NULL, - user_id integer NOT NULL, - referrer integer, - is_mobile_user boolean DEFAULT false NOT NULL, - slot integer -); +ALTER TABLE ONLY public.artist_coin_stats + ADD CONSTRAINT artist_coin_stats_pkey PRIMARY KEY (mint); -- --- Name: user_events_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- Name: artist_coins artist_coins_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE SEQUENCE public.user_events_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; +ALTER TABLE ONLY public.artist_coins + ADD CONSTRAINT artist_coins_pkey PRIMARY KEY (mint); -- --- Name: user_events_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- Name: artist_coins artist_coins_ticker_unique; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER SEQUENCE public.user_events_id_seq OWNED BY public.user_events.id; +ALTER TABLE ONLY public.artist_coins + ADD CONSTRAINT artist_coins_ticker_unique UNIQUE (ticker); -- --- Name: user_listening_history; Type: TABLE; Schema: public; Owner: - +-- Name: associated_wallets associated_wallets_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE TABLE public.user_listening_history ( - user_id integer NOT NULL, - listening_history jsonb NOT NULL -); +ALTER TABLE ONLY public.associated_wallets + ADD CONSTRAINT associated_wallets_pkey PRIMARY KEY (id); -- --- Name: user_listening_history_user_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- Name: audio_transactions_history audio_transactions_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE SEQUENCE public.user_listening_history_user_id_seq - AS integer - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; +ALTER TABLE ONLY public.audio_transactions_history + ADD CONSTRAINT audio_transactions_history_pkey PRIMARY KEY (user_bank, signature); -- --- Name: user_listening_history_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- Name: audius_data_txs audius_data_txs_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER SEQUENCE public.user_listening_history_user_id_seq OWNED BY public.user_listening_history.user_id; +ALTER TABLE ONLY public.audius_data_txs + ADD CONSTRAINT audius_data_txs_pkey PRIMARY KEY (signature); -- --- Name: user_payout_wallet_history; Type: TABLE; Schema: public; Owner: - +-- Name: blocks blocks_number_key; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE TABLE public.user_payout_wallet_history ( - user_id integer NOT NULL, - spl_usdc_payout_wallet character varying, - blocknumber integer NOT NULL, - block_timestamp timestamp without time zone NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); +ALTER TABLE ONLY public.blocks + ADD CONSTRAINT blocks_number_key UNIQUE (number); -- --- Name: user_pubkeys; Type: TABLE; Schema: public; Owner: - +-- Name: blocks blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE TABLE public.user_pubkeys ( - user_id integer NOT NULL, - pubkey_base64 text NOT NULL -); +ALTER TABLE ONLY public.blocks + ADD CONSTRAINT blocks_pkey PRIMARY KEY (blockhash); -- --- Name: user_score_features; Type: TABLE; Schema: public; Owner: - +-- Name: challenge_disbursements challenge_disbursements_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE TABLE public.user_score_features ( - user_id integer NOT NULL, - challenge_count integer DEFAULT 0, - updated_at timestamp with time zone DEFAULT now() NOT NULL -); +ALTER TABLE ONLY public.challenge_disbursements + ADD CONSTRAINT challenge_disbursements_pkey PRIMARY KEY (challenge_id, specifier); -- --- Name: TABLE user_score_features; Type: COMMENT; Schema: public; Owner: - +-- Name: challenge_listen_streak challenge_listen_streak_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -COMMENT ON TABLE public.user_score_features IS 'Tracks some features used in user score calculation'; +ALTER TABLE ONLY public.challenge_listen_streak + ADD CONSTRAINT challenge_listen_streak_pkey PRIMARY KEY (user_id); -- --- Name: COLUMN user_score_features.challenge_count; Type: COMMENT; Schema: public; Owner: - +-- Name: challenge_profile_completion challenge_profile_completion_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -COMMENT ON COLUMN public.user_score_features.challenge_count IS 'Tracks the number of fast challenges auser has completed'; +ALTER TABLE ONLY public.challenge_profile_completion + ADD CONSTRAINT challenge_profile_completion_pkey PRIMARY KEY (user_id); -- --- Name: user_tips; Type: TABLE; Schema: public; Owner: - +-- Name: challenges challenges_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE TABLE public.user_tips ( - slot integer NOT NULL, - signature character varying NOT NULL, - sender_user_id integer NOT NULL, - receiver_user_id integer NOT NULL, - amount bigint NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); +ALTER TABLE ONLY public.challenges + ADD CONSTRAINT challenges_pkey PRIMARY KEY (id); + + +-- +-- Name: chat_ban chat_ban_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.chat_ban + ADD CONSTRAINT chat_ban_pkey PRIMARY KEY (user_id); -- --- Name: v_challenge_disbursements; Type: VIEW; Schema: public; Owner: - +-- Name: chat_blast chat_blast_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE VIEW public.v_challenge_disbursements AS - SELECT rd.challenge_id, - rd.specifier, - (rd.amount)::text AS amount, - rd.signature, - rd.slot, - rd.created_at, - users.user_id - FROM (public.sol_reward_disbursements rd - JOIN public.users ON (((lower((users.wallet)::text) = rd.recipient_eth_address) AND (users.is_current = true)))); +ALTER TABLE ONLY public.chat_blast + ADD CONSTRAINT chat_blast_pkey PRIMARY KEY (blast_id); -- --- Name: VIEW v_challenge_disbursements; Type: COMMENT; Schema: public; Owner: - +-- Name: chat_blocked_users chat_blocked_users_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -COMMENT ON VIEW public.v_challenge_disbursements IS 'Compatibility view that exposes sol_reward_disbursements in the column shape the API routes used to read from challenge_disbursements. Resolves user_id via the indexer-populated recipient_eth_address (see migration 0172). Join uses LOWER(users.wallet) because the Go indexer stores recipient_eth_address as lowercase.'; +ALTER TABLE ONLY public.chat_blocked_users + ADD CONSTRAINT chat_blocked_users_pkey PRIMARY KEY (blocker_user_id, blockee_user_id); -- --- Name: v_token_transactions_history; Type: VIEW; Schema: public; Owner: - +-- Name: chat_member chat_member_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE VIEW public.v_token_transactions_history AS - SELECT bc.signature, - bc.mint, - bc.account AS user_bank, - users.user_id, - bc.block_timestamp AS transaction_date, - bc.created_at, - bc.slot, - (abs(bc.change))::text AS change, - (bc.balance)::text AS balance, - CASE - WHEN (bc.change < 0) THEN 'send'::text - ELSE 'receive'::text - END AS method, - CASE - WHEN (rd.signature IS NOT NULL) THEN - CASE - WHEN (c.type = 'trending'::public.challengetype) THEN 'trending_reward'::text - ELSE 'user_reward'::text - END - WHEN (p.signature IS NOT NULL) THEN 'purchase_content'::text - WHEN (tmt.memo_type IS NOT NULL) THEN (tmt.memo_type)::text - WHEN ((cat.signature IS NOT NULL) AND (from_owner.user_id IS NOT NULL) AND (to_owner.user_id IS NOT NULL) AND (from_owner.user_id <> to_owner.user_id)) THEN 'tip'::text - WHEN (cat.signature IS NOT NULL) THEN 'transfer'::text - ELSE 'transfer'::text - END AS transaction_type, - CASE - WHEN (rd.signature IS NOT NULL) THEN rd.challenge_id - WHEN (((tmt.memo_type)::text = 'withdrawal'::text) AND (cat.to_account IS NOT NULL)) THEN cat.to_account - WHEN ((cat.signature IS NOT NULL) AND (bc.change > 0) AND (from_owner.user_id IS NOT NULL)) THEN ((from_owner.user_id)::text)::character varying - WHEN ((cat.signature IS NOT NULL) AND (bc.change < 0) AND (to_owner.user_id IS NOT NULL)) THEN ((to_owner.user_id)::text)::character varying - ELSE NULL::character varying - END AS tx_metadata - FROM (((((((((((public.sol_token_account_balance_changes bc - JOIN public.sol_claimable_accounts sca ON ((((sca.account)::text = (bc.account)::text) AND ((sca.mint)::text = (bc.mint)::text)))) - LEFT JOIN public.users ON ((((users.wallet)::text = (sca.ethereum_address)::text) AND (users.is_current = true)))) - LEFT JOIN public.sol_claimable_account_transfers cat ON ((((cat.signature)::text = (bc.signature)::text) AND (((cat.from_account)::text = (bc.account)::text) OR ((cat.to_account)::text = (bc.account)::text))))) - LEFT JOIN public.sol_claimable_accounts from_sca ON ((((from_sca.account)::text = (cat.from_account)::text) AND ((from_sca.mint)::text = (bc.mint)::text)))) - LEFT JOIN public.users from_owner ON ((((from_owner.wallet)::text = (from_sca.ethereum_address)::text) AND (from_owner.is_current = true)))) - LEFT JOIN public.sol_claimable_accounts to_sca ON ((((to_sca.account)::text = (cat.to_account)::text) AND ((to_sca.mint)::text = (bc.mint)::text)))) - LEFT JOIN public.users to_owner ON ((((to_owner.wallet)::text = (to_sca.ethereum_address)::text) AND (to_owner.is_current = true)))) - LEFT JOIN public.sol_reward_disbursements rd ON ((((rd.signature)::text = (bc.signature)::text) AND ((rd.user_bank)::text = (bc.account)::text)))) - LEFT JOIN public.challenges c ON (((c.id)::text = (rd.challenge_id)::text))) - LEFT JOIN public.sol_purchases p ON ((((p.signature)::text = (bc.signature)::text) AND ((p.from_account)::text = (bc.account)::text)))) - LEFT JOIN public.sol_transfer_memo_types tmt ON (((tmt.signature)::text = (bc.signature)::text))); +ALTER TABLE ONLY public.chat_member + ADD CONSTRAINT chat_member_pkey PRIMARY KEY (chat_id, user_id); -- --- Name: VIEW v_token_transactions_history; Type: COMMENT; Schema: public; Owner: - +-- Name: chat_message chat_message_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -COMMENT ON VIEW public.v_token_transactions_history IS 'Mint-agnostic transactions history derived from sol_token_account_balance_changes (the hub: only table with both mint and block_timestamp). Per-row transaction_type derived by LEFT JOIN to typed tables (sol_claimable_account_transfers, sol_reward_disbursements, sol_purchases, sol_transfer_memo_types). Callers filter by mint at query time. Vendor purchase types (PURCHASE_STRIPE/COINBASE/UNKNOWN) on AUDIO still degrade to bare transfer until the AUDIO mint subscription + vendor-memo capture land.'; +ALTER TABLE ONLY public.chat_message + ADD CONSTRAINT chat_message_pkey PRIMARY KEY (message_id); -- --- Name: v_usdc_purchases; Type: VIEW; Schema: public; Owner: - +-- Name: chat_message_reactions chat_message_reactions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE VIEW public.v_usdc_purchases AS - SELECT sp.signature, - sp.slot, - sp.buyer_user_id, - CASE sp.content_type - WHEN 'track'::text THEN t.owner_id - WHEN 'album'::text THEN p.playlist_owner_id - WHEN 'playlist'::text THEN p.playlist_owner_id - ELSE NULL::integer - END AS seller_user_id, - sp.amount, - (sp.content_type)::public.usdc_purchase_content_type AS content_type, - sp.content_id, - sp.created_at, - sp.created_at AS updated_at, - GREATEST((sp.amount - COALESCE( - CASE sp.content_type - WHEN 'track'::text THEN ( SELECT (tph.total_price_cents * 10000) - FROM public.track_price_history tph - WHERE ((tph.track_id = sp.content_id) AND (tph.block_timestamp <= sp.created_at)) - ORDER BY tph.block_timestamp DESC - LIMIT 1) - ELSE ( SELECT (aph.total_price_cents * 10000) - FROM public.album_price_history aph - WHERE ((aph.playlist_id = sp.content_id) AND (aph.block_timestamp <= sp.created_at)) - ORDER BY aph.block_timestamp DESC - LIMIT 1) - END, sp.amount)), (0)::bigint) AS extra_amount, - (sp.access_type)::public.usdc_purchase_access_type AS access, - sp.city, - sp.region, - sp.country, - ( SELECT COALESCE(jsonb_agg(jsonb_build_object('user_id', COALESCE(u_payout.user_id, u_sca.user_id), 'payout_wallet', pay.to_account, 'amount', pay.amount, 'percentage', (((pay.amount)::numeric * 100.0) / (NULLIF(sp.amount, 0))::numeric)) ORDER BY pay.route_index), '[]'::jsonb) AS "coalesce" - FROM (((public.sol_payments pay - LEFT JOIN LATERAL ( SELECT upwh.user_id - FROM public.user_payout_wallet_history upwh - WHERE (((upwh.spl_usdc_payout_wallet)::text = (pay.to_account)::text) AND (upwh.block_timestamp <= sp.created_at)) - ORDER BY upwh.block_timestamp DESC - LIMIT 1) u_payout ON (true)) - LEFT JOIN public.sol_claimable_accounts sca ON ((((sca.account)::text = (pay.to_account)::text) AND ((sca.mint)::text = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'::text)))) - LEFT JOIN public.users u_sca ON ((((u_sca.wallet)::text = (sca.ethereum_address)::text) AND (u_sca.is_current = true)))) - WHERE (((pay.signature)::text = (sp.signature)::text) AND (pay.instruction_index = sp.instruction_index))) AS splits - FROM ((public.sol_purchases sp - LEFT JOIN public.tracks t ON ((((sp.content_type)::text = 'track'::text) AND (t.track_id = sp.content_id) AND (t.is_current = true)))) - LEFT JOIN public.playlists p ON ((((sp.content_type)::text = ANY (ARRAY[('album'::character varying)::text, ('playlist'::character varying)::text])) AND (p.playlist_id = sp.content_id) AND (p.is_current = true)))) - WHERE (sp.is_valid IS TRUE); +ALTER TABLE ONLY public.chat_message_reactions + ADD CONSTRAINT chat_message_reactions_pkey PRIMARY KEY (user_id, message_id); -- --- Name: VIEW v_usdc_purchases; Type: COMMENT; Schema: public; Owner: - +-- Name: chat_permissions chat_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -COMMENT ON VIEW public.v_usdc_purchases IS 'Compatibility view exposing sol_purchases + sol_payments in the column shape API routes used to read from usdc_purchases. seller_user_id is the current content owner (not snapshotted at purchase time). extra_amount is amount paid minus base price from price history. vendor is intentionally dropped.'; +ALTER TABLE ONLY public.chat_permissions + ADD CONSTRAINT chat_permissions_pkey PRIMARY KEY (user_id, permits); -- --- Name: v_user_balances; Type: VIEW; Schema: public; Owner: - +-- Name: chat chat_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE VIEW public.v_user_balances AS - SELECT u.user_id, - (COALESCE(eub.balance, (0)::numeric))::character varying AS eth_balance, - (COALESCE(sub.balance, (0)::bigint))::character varying AS sol_balance, - GREATEST(COALESCE(eub.updated_at, '1970-01-01 00:00:00'::timestamp without time zone), COALESCE(sub.updated_at, '1970-01-01 00:00:00'::timestamp without time zone)) AS updated_at - FROM ((public.users u - LEFT JOIN public.sol_user_balances sub ON (((sub.user_id = u.user_id) AND (sub.mint = '9LzCMqDgTKYz9Drzqnpgee3SGa89up3a247ypMj2xrqM'::text)))) - LEFT JOIN public.eth_user_balances eub ON ((eub.user_id = u.user_id))) - WHERE (u.is_current = true); +ALTER TABLE ONLY public.chat + ADD CONSTRAINT chat_pkey PRIMARY KEY (chat_id); -- --- Name: VIEW v_user_balances; Type: COMMENT; Schema: public; Owner: - +-- Name: cid_data cid_data_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -COMMENT ON VIEW public.v_user_balances IS 'Per-user AUDIO/wAUDIO balance totals. One row per current user with eth_balance (wei) and sol_balance (wAUDIO base units, 8 decimals — multiply by 10^10 to compare to wei). eth_balance is eth_user_balances (pre-aggregated across users.wallet + chain=eth associated_wallets, maintained by handle_eth_wallet_balance_change / handle_associated_wallets). sol_balance is sol_user_balances for the wAUDIO mint, pre-aggregated across user_bank PDAs + linked Solana wallets by handle_sol_claimable_accounts / update_sol_user_balance triggers.'; +ALTER TABLE ONLY public.cid_data + ADD CONSTRAINT cid_data_pkey PRIMARY KEY (cid); -- --- Name: volume_leader_exclusions; Type: TABLE; Schema: public; Owner: - +-- Name: claimed_prizes claimed_prizes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE TABLE public.volume_leader_exclusions ( - address text NOT NULL, - description text -); +ALTER TABLE ONLY public.claimed_prizes + ADD CONSTRAINT claimed_prizes_pkey PRIMARY KEY (id); -- --- Name: aggregate_daily_app_name_metrics id; Type: DEFAULT; Schema: public; Owner: - +-- Name: claimed_prizes claimed_prizes_signature_key; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_daily_app_name_metrics ALTER COLUMN id SET DEFAULT nextval('public.aggregate_daily_app_name_metrics_id_seq'::regclass); +ALTER TABLE ONLY public.claimed_prizes + ADD CONSTRAINT claimed_prizes_signature_key UNIQUE (signature); -- --- Name: aggregate_daily_total_users_metrics id; Type: DEFAULT; Schema: public; Owner: - +-- Name: comment_mentions comment_mentions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_daily_total_users_metrics ALTER COLUMN id SET DEFAULT nextval('public.aggregate_daily_total_users_metrics_id_seq'::regclass); +ALTER TABLE ONLY public.comment_mentions + ADD CONSTRAINT comment_mentions_pkey PRIMARY KEY (comment_id, user_id); -- --- Name: aggregate_daily_unique_users_metrics id; Type: DEFAULT; Schema: public; Owner: - +-- Name: comment_notification_settings comment_notification_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_daily_unique_users_metrics ALTER COLUMN id SET DEFAULT nextval('public.aggregate_daily_unique_users_metrics_id_seq'::regclass); +ALTER TABLE ONLY public.comment_notification_settings + ADD CONSTRAINT comment_notification_settings_pkey PRIMARY KEY (user_id, entity_id, entity_type); -- --- Name: aggregate_monthly_app_name_metrics id; Type: DEFAULT; Schema: public; Owner: - +-- Name: comment_reactions comment_reactions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_monthly_app_name_metrics ALTER COLUMN id SET DEFAULT nextval('public.aggregate_monthly_app_name_metrics_id_seq'::regclass); +ALTER TABLE ONLY public.comment_reactions + ADD CONSTRAINT comment_reactions_pkey PRIMARY KEY (comment_id, user_id); -- --- Name: aggregate_monthly_total_users_metrics id; Type: DEFAULT; Schema: public; Owner: - +-- Name: comment_reports comment_reports_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_monthly_total_users_metrics ALTER COLUMN id SET DEFAULT nextval('public.aggregate_monthly_total_users_metrics_id_seq'::regclass); +ALTER TABLE ONLY public.comment_reports + ADD CONSTRAINT comment_reports_pkey PRIMARY KEY (comment_id, user_id); -- --- Name: aggregate_monthly_unique_users_metrics id; Type: DEFAULT; Schema: public; Owner: - +-- Name: comment_threads comment_threads_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_monthly_unique_users_metrics ALTER COLUMN id SET DEFAULT nextval('public.aggregate_monthly_unique_users_metrics_id_seq'::regclass); +ALTER TABLE ONLY public.comment_threads + ADD CONSTRAINT comment_threads_pkey PRIMARY KEY (parent_comment_id, comment_id); -- --- Name: associated_wallets id; Type: DEFAULT; Schema: public; Owner: - +-- Name: comments comments_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.associated_wallets ALTER COLUMN id SET DEFAULT nextval('public.associated_wallets_id_seq'::regclass); +ALTER TABLE ONLY public.comments + ADD CONSTRAINT comments_pkey PRIMARY KEY (comment_id); -- --- Name: challenge_listen_streak user_id; Type: DEFAULT; Schema: public; Owner: - +-- Name: countries countries_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.challenge_listen_streak ALTER COLUMN user_id SET DEFAULT nextval('public.challenge_listen_streak_user_id_seq'::regclass); +ALTER TABLE ONLY public.countries + ADD CONSTRAINT countries_pkey PRIMARY KEY (iso); -- --- Name: challenge_profile_completion user_id; Type: DEFAULT; Schema: public; Owner: - +-- Name: dashboard_wallet_users dashboard_wallet_users_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.challenge_profile_completion ALTER COLUMN user_id SET DEFAULT nextval('public.challenge_profile_completion_user_id_seq'::regclass); +ALTER TABLE ONLY public.dashboard_wallet_users + ADD CONSTRAINT dashboard_wallet_users_pkey PRIMARY KEY (wallet); -- --- Name: claimed_prizes id; Type: DEFAULT; Schema: public; Owner: - +-- Name: delist_status_cursor delist_status_cursor_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.claimed_prizes ALTER COLUMN id SET DEFAULT nextval('public.claimed_prizes_id_seq'::regclass); +ALTER TABLE ONLY public.delist_status_cursor + ADD CONSTRAINT delist_status_cursor_pkey PRIMARY KEY (host, entity); -- --- Name: email_access id; Type: DEFAULT; Schema: public; Owner: - +-- Name: developer_apps developer_apps_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.email_access ALTER COLUMN id SET DEFAULT nextval('public.email_access_id_seq'::regclass); +ALTER TABLE ONLY public.developer_apps + ADD CONSTRAINT developer_apps_pkey PRIMARY KEY (address, txhash); -- --- Name: encrypted_emails id; Type: DEFAULT; Schema: public; Owner: - +-- Name: email_access email_access_email_owner_user_id_receiving_user_id_grantor__key; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.encrypted_emails ALTER COLUMN id SET DEFAULT nextval('public.encrypted_emails_id_seq'::regclass); +ALTER TABLE ONLY public.email_access + ADD CONSTRAINT email_access_email_owner_user_id_receiving_user_id_grantor__key UNIQUE (email_owner_user_id, receiving_user_id, grantor_user_id); -- --- Name: eth_blocks last_scanned_block; Type: DEFAULT; Schema: public; Owner: - +-- Name: email_access email_access_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.eth_blocks ALTER COLUMN last_scanned_block SET DEFAULT nextval('public.eth_blocks_last_scanned_block_seq'::regclass); +ALTER TABLE ONLY public.email_access + ADD CONSTRAINT email_access_pkey PRIMARY KEY (id); -- --- Name: notification id; Type: DEFAULT; Schema: public; Owner: - +-- Name: encrypted_emails encrypted_emails_email_owner_user_id_key; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.notification ALTER COLUMN id SET DEFAULT nextval('public.notification_id_seq'::regclass); +ALTER TABLE ONLY public.encrypted_emails + ADD CONSTRAINT encrypted_emails_email_owner_user_id_key UNIQUE (email_owner_user_id); -- --- Name: oauth_redirect_uris id; Type: DEFAULT; Schema: public; Owner: - +-- Name: encrypted_emails encrypted_emails_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.oauth_redirect_uris ALTER COLUMN id SET DEFAULT nextval('public.oauth_redirect_uris_id_seq'::regclass); +ALTER TABLE ONLY public.encrypted_emails + ADD CONSTRAINT encrypted_emails_pkey PRIMARY KEY (id); -- --- Name: plays id; Type: DEFAULT; Schema: public; Owner: - +-- Name: eth_blocks eth_blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.plays ALTER COLUMN id SET DEFAULT nextval('public.plays_id_seq'::regclass); +ALTER TABLE ONLY public.eth_blocks + ADD CONSTRAINT eth_blocks_pkey PRIMARY KEY (last_scanned_block); -- --- Name: prizes id; Type: DEFAULT; Schema: public; Owner: - +-- Name: eth_indexer_checkpoints eth_indexer_checkpoints_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.prizes ALTER COLUMN id SET DEFAULT nextval('public.prizes_id_seq'::regclass); +ALTER TABLE ONLY public.eth_indexer_checkpoints + ADD CONSTRAINT eth_indexer_checkpoints_pkey PRIMARY KEY (name); -- --- Name: reactions id; Type: DEFAULT; Schema: public; Owner: - +-- Name: eth_user_balances eth_user_balances_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.reactions ALTER COLUMN id SET DEFAULT nextval('public.reactions_id_seq'::regclass); +ALTER TABLE ONLY public.eth_user_balances + ADD CONSTRAINT eth_user_balances_pkey PRIMARY KEY (user_id); -- --- Name: skipped_transactions id; Type: DEFAULT; Schema: public; Owner: - +-- Name: eth_wallet_balances eth_wallet_balances_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.skipped_transactions ALTER COLUMN id SET DEFAULT nextval('public.skipped_transactions_id_seq'::regclass); +ALTER TABLE ONLY public.eth_wallet_balances + ADD CONSTRAINT eth_wallet_balances_pkey PRIMARY KEY (wallet); -- --- Name: user_balance_changes user_id; Type: DEFAULT; Schema: public; Owner: - +-- Name: etl_addresses etl_addresses_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_balance_changes ALTER COLUMN user_id SET DEFAULT nextval('public.user_balance_changes_user_id_seq'::regclass); +ALTER TABLE ONLY public.etl_addresses + ADD CONSTRAINT etl_addresses_pkey PRIMARY KEY (id); -- --- Name: user_balances user_id; Type: DEFAULT; Schema: public; Owner: - +-- Name: etl_blocks etl_blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_balances ALTER COLUMN user_id SET DEFAULT nextval('public.user_balances_user_id_seq'::regclass); +ALTER TABLE ONLY public.etl_blocks + ADD CONSTRAINT etl_blocks_pkey PRIMARY KEY (id); -- --- Name: user_events id; Type: DEFAULT; Schema: public; Owner: - +-- Name: etl_db_migrations etl_db_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_events ALTER COLUMN id SET DEFAULT nextval('public.user_events_id_seq'::regclass); +ALTER TABLE ONLY public.etl_db_migrations + ADD CONSTRAINT etl_db_migrations_pkey PRIMARY KEY (version); -- --- Name: user_listening_history user_id; Type: DEFAULT; Schema: public; Owner: - +-- Name: etl_manage_entities etl_manage_entities_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_listening_history ALTER COLUMN user_id SET DEFAULT nextval('public.user_listening_history_user_id_seq'::regclass); +ALTER TABLE ONLY public.etl_manage_entities + ADD CONSTRAINT etl_manage_entities_pkey PRIMARY KEY (id); -- --- Name: SequelizeMeta SequelizeMeta_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_plays etl_plays_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public."SequelizeMeta" - ADD CONSTRAINT "SequelizeMeta_pkey" PRIMARY KEY (name); +ALTER TABLE ONLY public.etl_plays + ADD CONSTRAINT etl_plays_pkey PRIMARY KEY (id); -- --- Name: aggregate_daily_app_name_metrics aggregate_daily_app_name_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_sla_node_reports etl_sla_node_reports_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_daily_app_name_metrics - ADD CONSTRAINT aggregate_daily_app_name_metrics_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.etl_sla_node_reports + ADD CONSTRAINT etl_sla_node_reports_pkey PRIMARY KEY (id); -- --- Name: aggregate_daily_total_users_metrics aggregate_daily_total_users_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_sla_rollups etl_sla_rollups_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_daily_total_users_metrics - ADD CONSTRAINT aggregate_daily_total_users_metrics_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.etl_sla_rollups + ADD CONSTRAINT etl_sla_rollups_pkey PRIMARY KEY (id); -- --- Name: aggregate_daily_unique_users_metrics aggregate_daily_unique_users_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_storage_proof_verifications etl_storage_proof_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_daily_unique_users_metrics - ADD CONSTRAINT aggregate_daily_unique_users_metrics_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.etl_storage_proof_verifications + ADD CONSTRAINT etl_storage_proof_verifications_pkey PRIMARY KEY (id); -- --- Name: aggregate_monthly_app_name_metrics aggregate_monthly_app_name_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_storage_proofs etl_storage_proofs_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_monthly_app_name_metrics - ADD CONSTRAINT aggregate_monthly_app_name_metrics_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.etl_storage_proofs + ADD CONSTRAINT etl_storage_proofs_pkey PRIMARY KEY (id); -- --- Name: aggregate_monthly_plays aggregate_monthly_plays_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_transactions etl_transactions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_monthly_plays - ADD CONSTRAINT aggregate_monthly_plays_pkey PRIMARY KEY (play_item_id, "timestamp", country); +ALTER TABLE ONLY public.etl_transactions + ADD CONSTRAINT etl_transactions_pkey PRIMARY KEY (id); -- --- Name: aggregate_monthly_total_users_metrics aggregate_monthly_total_users_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_validator_deregistrations etl_validator_deregistrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_monthly_total_users_metrics - ADD CONSTRAINT aggregate_monthly_total_users_metrics_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.etl_validator_deregistrations + ADD CONSTRAINT etl_validator_deregistrations_pkey PRIMARY KEY (id); -- --- Name: aggregate_monthly_unique_users_metrics aggregate_monthly_unique_users_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_validator_misbehavior_deregistrations etl_validator_misbehavior_deregistrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_monthly_unique_users_metrics - ADD CONSTRAINT aggregate_monthly_unique_users_metrics_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.etl_validator_misbehavior_deregistrations + ADD CONSTRAINT etl_validator_misbehavior_deregistrations_pkey PRIMARY KEY (id); -- --- Name: aggregate_playlist aggregate_playlist_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_validator_registrations etl_validator_registrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_playlist - ADD CONSTRAINT aggregate_playlist_pkey PRIMARY KEY (playlist_id); +ALTER TABLE ONLY public.etl_validator_registrations + ADD CONSTRAINT etl_validator_registrations_pkey PRIMARY KEY (id); -- --- Name: aggregate_track aggregate_track_table_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_validators etl_validators_endpoint_key; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_track - ADD CONSTRAINT aggregate_track_table_pkey PRIMARY KEY (track_id); +ALTER TABLE ONLY public.etl_validators + ADD CONSTRAINT etl_validators_endpoint_key UNIQUE (endpoint); -- --- Name: aggregate_user aggregate_user_table_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_validators etl_validators_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_user - ADD CONSTRAINT aggregate_user_table_pkey PRIMARY KEY (user_id); +ALTER TABLE ONLY public.etl_validators + ADD CONSTRAINT etl_validators_pkey PRIMARY KEY (id); -- --- Name: aggregate_user_tips aggregate_user_tips_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: events events_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_user_tips - ADD CONSTRAINT aggregate_user_tips_pkey PRIMARY KEY (sender_user_id, receiver_user_id); +ALTER TABLE ONLY public.events + ADD CONSTRAINT events_pkey PRIMARY KEY (event_id); -- --- Name: album_price_history album_price_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: follows follows_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.album_price_history - ADD CONSTRAINT album_price_history_pkey PRIMARY KEY (playlist_id, block_timestamp); +ALTER TABLE ONLY public.follows + ADD CONSTRAINT follows_pkey PRIMARY KEY (follower_user_id, followee_user_id, txhash); -- --- Name: api_access_keys api_access_keys_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: grants grants_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.api_access_keys - ADD CONSTRAINT api_access_keys_pkey PRIMARY KEY (api_key, api_access_key); +ALTER TABLE ONLY public.grants + ADD CONSTRAINT grants_pkey PRIMARY KEY (grantee_address, user_id, txhash); -- --- Name: api_keys api_keys_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: hourly_play_counts hourly_play_counts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.api_keys - ADD CONSTRAINT api_keys_pkey PRIMARY KEY (api_key); +ALTER TABLE ONLY public.hourly_play_counts + ADD CONSTRAINT hourly_play_counts_pkey PRIMARY KEY (hourly_timestamp); -- --- Name: api_metrics_apps api_metrics_apps_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: indexing_checkpoints indexing_checkpoints_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.api_metrics_apps - ADD CONSTRAINT api_metrics_apps_pkey PRIMARY KEY (date, api_key, app_name); +ALTER TABLE ONLY public.indexing_checkpoints + ADD CONSTRAINT indexing_checkpoints_pkey PRIMARY KEY (tablename); -- --- Name: api_metrics_apps_unique api_metrics_apps_unique_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: milestones milestones_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.api_metrics_apps_unique - ADD CONSTRAINT api_metrics_apps_unique_pkey PRIMARY KEY (date, app_name); +ALTER TABLE ONLY public.milestones + ADD CONSTRAINT milestones_pkey PRIMARY KEY (id, name, threshold); -- --- Name: api_metrics_counts api_metrics_counts_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: muted_users muted_users_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.api_metrics_counts - ADD CONSTRAINT api_metrics_counts_pkey PRIMARY KEY (date); +ALTER TABLE ONLY public.muted_users + ADD CONSTRAINT muted_users_pkey PRIMARY KEY (muted_user_id, user_id); -- --- Name: api_metrics_routes api_metrics_routes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: new_chain_queue new_chain_queue_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.api_metrics_routes - ADD CONSTRAINT api_metrics_routes_pkey PRIMARY KEY (date, route_pattern, method); +ALTER TABLE ONLY public.new_chain_queue + ADD CONSTRAINT new_chain_queue_pkey PRIMARY KEY (id); -- --- Name: app_name_metrics app_name_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: notification_campaign_push_open notification_campaign_push_open_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.app_name_metrics - ADD CONSTRAINT app_name_metrics_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.notification_campaign_push_open + ADD CONSTRAINT notification_campaign_push_open_pkey PRIMARY KEY (campaign_id, user_id); -- --- Name: artist_coin_pools artist_coin_pools_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: notification notification_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.artist_coin_pools - ADD CONSTRAINT artist_coin_pools_pkey PRIMARY KEY (address); +ALTER TABLE ONLY public.notification + ADD CONSTRAINT notification_pkey PRIMARY KEY (id); -- --- Name: artist_coin_price_history artist_coin_price_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: notification_seen notification_seen_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.artist_coin_price_history - ADD CONSTRAINT artist_coin_price_history_pkey PRIMARY KEY (mint, "timestamp"); +ALTER TABLE ONLY public.notification_seen + ADD CONSTRAINT notification_seen_pkey PRIMARY KEY (user_id, seen_at); -- --- Name: artist_coin_stats artist_coin_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: oauth_authorization_codes oauth_authorization_codes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.artist_coin_stats - ADD CONSTRAINT artist_coin_stats_pkey PRIMARY KEY (mint); +ALTER TABLE ONLY public.oauth_authorization_codes + ADD CONSTRAINT oauth_authorization_codes_pkey PRIMARY KEY (code); -- --- Name: artist_coins artist_coins_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: oauth_redirect_uris oauth_redirect_uris_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.artist_coins - ADD CONSTRAINT artist_coins_pkey PRIMARY KEY (mint); +ALTER TABLE ONLY public.oauth_redirect_uris + ADD CONSTRAINT oauth_redirect_uris_pkey PRIMARY KEY (id); -- --- Name: artist_coins artist_coins_ticker_unique; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: oauth_tokens oauth_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.artist_coins - ADD CONSTRAINT artist_coins_ticker_unique UNIQUE (ticker); +ALTER TABLE ONLY public.oauth_tokens + ADD CONSTRAINT oauth_tokens_pkey PRIMARY KEY (token); -- --- Name: associated_wallets associated_wallets_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: core_indexed_blocks pk_chain_id_height; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.associated_wallets - ADD CONSTRAINT associated_wallets_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.core_indexed_blocks + ADD CONSTRAINT pk_chain_id_height PRIMARY KEY (chain_id, height); -- --- Name: audio_transactions_history audio_transactions_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: collectibles pk_user_id; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.audio_transactions_history - ADD CONSTRAINT audio_transactions_history_pkey PRIMARY KEY (user_bank, signature); +ALTER TABLE ONLY public.collectibles + ADD CONSTRAINT pk_user_id PRIMARY KEY (user_id); -- --- Name: audius_data_txs audius_data_txs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: aggregate_plays play_item_id_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.audius_data_txs - ADD CONSTRAINT audius_data_txs_pkey PRIMARY KEY (signature); +ALTER TABLE ONLY public.aggregate_plays + ADD CONSTRAINT play_item_id_pkey PRIMARY KEY (play_item_id); -- --- Name: blocks blocks_number_key; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: playlist_routes playlist_routes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.blocks - ADD CONSTRAINT blocks_number_key UNIQUE (number); +ALTER TABLE ONLY public.playlist_routes + ADD CONSTRAINT playlist_routes_pkey PRIMARY KEY (owner_id, slug); -- --- Name: blocks blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: playlist_seen playlist_seen_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.blocks - ADD CONSTRAINT blocks_pkey PRIMARY KEY (blockhash); +ALTER TABLE ONLY public.playlist_seen + ADD CONSTRAINT playlist_seen_pkey PRIMARY KEY (user_id, playlist_id, seen_at); -- --- Name: challenge_disbursements challenge_disbursements_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: playlist_tracks playlist_tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.challenge_disbursements - ADD CONSTRAINT challenge_disbursements_pkey PRIMARY KEY (challenge_id, specifier); +ALTER TABLE ONLY public.playlist_tracks + ADD CONSTRAINT playlist_tracks_pkey PRIMARY KEY (playlist_id, track_id); -- --- Name: challenge_listen_streak challenge_listen_streak_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: playlist_trending_scores playlist_trending_scores_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.challenge_listen_streak - ADD CONSTRAINT challenge_listen_streak_pkey PRIMARY KEY (user_id); +ALTER TABLE ONLY public.playlist_trending_scores + ADD CONSTRAINT playlist_trending_scores_pkey PRIMARY KEY (playlist_id, type, version, time_range); -- --- Name: challenge_profile_completion challenge_profile_completion_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: playlists playlists_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.challenge_profile_completion - ADD CONSTRAINT challenge_profile_completion_pkey PRIMARY KEY (user_id); +ALTER TABLE ONLY public.playlists + ADD CONSTRAINT playlists_pkey PRIMARY KEY (playlist_id, txhash); -- --- Name: challenges challenges_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: plays plays_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.challenges - ADD CONSTRAINT challenges_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.plays + ADD CONSTRAINT plays_pkey PRIMARY KEY (id); -- --- Name: chat_ban chat_ban_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: prizes prizes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.chat_ban - ADD CONSTRAINT chat_ban_pkey PRIMARY KEY (user_id); +ALTER TABLE ONLY public.prizes + ADD CONSTRAINT prizes_pkey PRIMARY KEY (id); -- --- Name: chat_blast chat_blast_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: prizes prizes_prize_id_key; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.chat_blast - ADD CONSTRAINT chat_blast_pkey PRIMARY KEY (blast_id); +ALTER TABLE ONLY public.prizes + ADD CONSTRAINT prizes_prize_id_key UNIQUE (prize_id); -- --- Name: chat_blocked_users chat_blocked_users_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: pubkeys pubkeys_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.chat_blocked_users - ADD CONSTRAINT chat_blocked_users_pkey PRIMARY KEY (blocker_user_id, blockee_user_id); +ALTER TABLE ONLY public.pubkeys + ADD CONSTRAINT pubkeys_pkey PRIMARY KEY (wallet); -- --- Name: chat_member chat_member_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: reactions reactions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.chat_member - ADD CONSTRAINT chat_member_pkey PRIMARY KEY (chat_id, user_id); +ALTER TABLE ONLY public.reactions + ADD CONSTRAINT reactions_pkey PRIMARY KEY (id); -- --- Name: chat_message chat_message_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: related_artists related_artists_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.chat_message - ADD CONSTRAINT chat_message_pkey PRIMARY KEY (message_id); +ALTER TABLE ONLY public.related_artists + ADD CONSTRAINT related_artists_pkey PRIMARY KEY (user_id, related_artist_user_id); -- --- Name: chat_message_reactions chat_message_reactions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: remixes remixes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.chat_message_reactions - ADD CONSTRAINT chat_message_reactions_pkey PRIMARY KEY (user_id, message_id); +ALTER TABLE ONLY public.remixes + ADD CONSTRAINT remixes_pkey PRIMARY KEY (parent_track_id, child_track_id); -- --- Name: chat_permissions chat_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: reported_comments reported_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.chat_permissions - ADD CONSTRAINT chat_permissions_pkey PRIMARY KEY (user_id, permits); +ALTER TABLE ONLY public.reported_comments + ADD CONSTRAINT reported_comments_pkey PRIMARY KEY (reported_comment_id, user_id); -- --- Name: chat chat_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: reposts reposts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.chat - ADD CONSTRAINT chat_pkey PRIMARY KEY (chat_id); +ALTER TABLE ONLY public.reposts + ADD CONSTRAINT reposts_pkey PRIMARY KEY (user_id, repost_item_id, repost_type, txhash); -- --- Name: cid_data cid_data_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: revert_blocks revert_blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.cid_data - ADD CONSTRAINT cid_data_pkey PRIMARY KEY (cid); +ALTER TABLE ONLY public.revert_blocks + ADD CONSTRAINT revert_blocks_pkey PRIMARY KEY (blocknumber); -- --- Name: claimed_prizes claimed_prizes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: reward_codes reward_codes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.claimed_prizes - ADD CONSTRAINT claimed_prizes_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.reward_codes + ADD CONSTRAINT reward_codes_pkey PRIMARY KEY (code); -- --- Name: claimed_prizes claimed_prizes_signature_key; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: reward_manager_txs reward_manager_txs_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.claimed_prizes - ADD CONSTRAINT claimed_prizes_signature_key UNIQUE (signature); +ALTER TABLE ONLY public.reward_manager_txs + ADD CONSTRAINT reward_manager_txs_pkey PRIMARY KEY (signature); -- --- Name: comment_mentions comment_mentions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: route_metrics route_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.comment_mentions - ADD CONSTRAINT comment_mentions_pkey PRIMARY KEY (comment_id, user_id); +ALTER TABLE ONLY public.route_metrics + ADD CONSTRAINT route_metrics_pkey PRIMARY KEY (id); -- --- Name: comment_notification_settings comment_notification_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: rpc_cursor rpc_cursor_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.comment_notification_settings - ADD CONSTRAINT comment_notification_settings_pkey PRIMARY KEY (user_id, entity_id, entity_type); +ALTER TABLE ONLY public.rpc_cursor + ADD CONSTRAINT rpc_cursor_pkey PRIMARY KEY (relayed_by); -- --- Name: comment_reactions comment_reactions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: rpc_error rpc_error_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.comment_reactions - ADD CONSTRAINT comment_reactions_pkey PRIMARY KEY (comment_id, user_id); +ALTER TABLE ONLY public.rpc_error + ADD CONSTRAINT rpc_error_pkey PRIMARY KEY (sig); -- --- Name: comment_reports comment_reports_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: rpc_log rpc_log_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.comment_reports - ADD CONSTRAINT comment_reports_pkey PRIMARY KEY (comment_id, user_id); +ALTER TABLE ONLY public.rpc_log + ADD CONSTRAINT rpc_log_pkey PRIMARY KEY (sig); -- --- Name: comment_threads comment_threads_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: rpclog rpclog_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.comment_threads - ADD CONSTRAINT comment_threads_pkey PRIMARY KEY (parent_comment_id, comment_id); +ALTER TABLE ONLY public.rpclog + ADD CONSTRAINT rpclog_pkey PRIMARY KEY (cuid); -- --- Name: comments comments_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: saves saves_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.comments - ADD CONSTRAINT comments_pkey PRIMARY KEY (comment_id); +ALTER TABLE ONLY public.saves + ADD CONSTRAINT saves_pkey PRIMARY KEY (user_id, save_item_id, save_type, txhash); -- --- Name: countries countries_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.countries - ADD CONSTRAINT countries_pkey PRIMARY KEY (iso); +ALTER TABLE ONLY public.schema_migrations + ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); -- --- Name: dashboard_wallet_users dashboard_wallet_users_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: schema_version schema_version_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.dashboard_wallet_users - ADD CONSTRAINT dashboard_wallet_users_pkey PRIMARY KEY (wallet); +ALTER TABLE ONLY public.schema_version + ADD CONSTRAINT schema_version_pkey PRIMARY KEY (file_name); -- --- Name: delist_status_cursor delist_status_cursor_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: shares shares_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.delist_status_cursor - ADD CONSTRAINT delist_status_cursor_pkey PRIMARY KEY (host, entity); +ALTER TABLE ONLY public.shares + ADD CONSTRAINT shares_pkey PRIMARY KEY (user_id, share_item_id, share_type, txhash); -- --- Name: developer_apps developer_apps_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: skipped_transactions skipped_transactions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.developer_apps - ADD CONSTRAINT developer_apps_pkey PRIMARY KEY (address, txhash); +ALTER TABLE ONLY public.skipped_transactions + ADD CONSTRAINT skipped_transactions_pkey PRIMARY KEY (id); -- --- Name: email_access email_access_email_owner_user_id_receiving_user_id_grantor__key; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_claimable_account_transfers sol_claimable_account_transfers_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.email_access - ADD CONSTRAINT email_access_email_owner_user_id_receiving_user_id_grantor__key UNIQUE (email_owner_user_id, receiving_user_id, grantor_user_id); +ALTER TABLE ONLY public.sol_claimable_account_transfers + ADD CONSTRAINT sol_claimable_account_transfers_pkey PRIMARY KEY (signature, instruction_index); -- --- Name: email_access email_access_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_claimable_accounts sol_claimable_accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.email_access - ADD CONSTRAINT email_access_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.sol_claimable_accounts + ADD CONSTRAINT sol_claimable_accounts_pkey PRIMARY KEY (signature, instruction_index); -- --- Name: encrypted_emails encrypted_emails_email_owner_user_id_key; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_keypairs sol_keypairs_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.encrypted_emails - ADD CONSTRAINT encrypted_emails_email_owner_user_id_key UNIQUE (email_owner_user_id); +ALTER TABLE ONLY public.sol_keypairs + ADD CONSTRAINT sol_keypairs_pkey PRIMARY KEY (public_key); -- --- Name: encrypted_emails encrypted_emails_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_locker_vesting_escrows sol_locker_vesting_escrows_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.encrypted_emails - ADD CONSTRAINT encrypted_emails_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.sol_locker_vesting_escrows + ADD CONSTRAINT sol_locker_vesting_escrows_pkey PRIMARY KEY (account); -- --- Name: eth_blocks eth_blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_meteora_damm_v2_initialize_custom_pool_instructions sol_meteora_damm_v2_initialize_custom_pool_instructions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.eth_blocks - ADD CONSTRAINT eth_blocks_pkey PRIMARY KEY (last_scanned_block); +ALTER TABLE ONLY public.sol_meteora_damm_v2_initialize_custom_pool_instructions + ADD CONSTRAINT sol_meteora_damm_v2_initialize_custom_pool_instructions_pkey PRIMARY KEY (signature, instruction_index); -- --- Name: eth_indexer_checkpoints eth_indexer_checkpoints_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_meteora_damm_v2_pool_base_fees sol_meteora_damm_v2_pool_base_fees_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.eth_indexer_checkpoints - ADD CONSTRAINT eth_indexer_checkpoints_pkey PRIMARY KEY (name); +ALTER TABLE ONLY public.sol_meteora_damm_v2_pool_base_fees + ADD CONSTRAINT sol_meteora_damm_v2_pool_base_fees_pkey PRIMARY KEY (pool); -- --- Name: eth_user_balances eth_user_balances_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_meteora_damm_v2_pool_dynamic_fees sol_meteora_damm_v2_pool_dynamic_fees_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.eth_user_balances - ADD CONSTRAINT eth_user_balances_pkey PRIMARY KEY (user_id); +ALTER TABLE ONLY public.sol_meteora_damm_v2_pool_dynamic_fees + ADD CONSTRAINT sol_meteora_damm_v2_pool_dynamic_fees_pkey PRIMARY KEY (pool); -- --- Name: eth_wallet_balances eth_wallet_balances_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_meteora_damm_v2_pool_fees sol_meteora_damm_v2_pool_fees_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.eth_wallet_balances - ADD CONSTRAINT eth_wallet_balances_pkey PRIMARY KEY (wallet); +ALTER TABLE ONLY public.sol_meteora_damm_v2_pool_fees + ADD CONSTRAINT sol_meteora_damm_v2_pool_fees_pkey PRIMARY KEY (pool); -- --- Name: events events_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_meteora_damm_v2_pool_metrics sol_meteora_damm_v2_pool_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.events - ADD CONSTRAINT events_pkey PRIMARY KEY (event_id); +ALTER TABLE ONLY public.sol_meteora_damm_v2_pool_metrics + ADD CONSTRAINT sol_meteora_damm_v2_pool_metrics_pkey PRIMARY KEY (pool); -- --- Name: follows follows_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_meteora_damm_v2_pools sol_meteora_damm_v2_pools_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.follows - ADD CONSTRAINT follows_pkey PRIMARY KEY (follower_user_id, followee_user_id, txhash); +ALTER TABLE ONLY public.sol_meteora_damm_v2_pools + ADD CONSTRAINT sol_meteora_damm_v2_pools_pkey PRIMARY KEY (account); -- --- Name: grants grants_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_meteora_damm_v2_position_metrics sol_meteora_damm_v2_position_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.grants - ADD CONSTRAINT grants_pkey PRIMARY KEY (grantee_address, user_id, txhash); +ALTER TABLE ONLY public.sol_meteora_damm_v2_position_metrics + ADD CONSTRAINT sol_meteora_damm_v2_position_metrics_pkey PRIMARY KEY ("position"); -- --- Name: hourly_play_counts hourly_play_counts_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_meteora_damm_v2_positions sol_meteora_damm_v2_positions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.hourly_play_counts - ADD CONSTRAINT hourly_play_counts_pkey PRIMARY KEY (hourly_timestamp); +ALTER TABLE ONLY public.sol_meteora_damm_v2_positions + ADD CONSTRAINT sol_meteora_damm_v2_positions_pkey PRIMARY KEY (account); -- --- Name: indexing_checkpoints indexing_checkpoints_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_meteora_dbc_config_fees sol_meteora_dbc_config_fees_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.indexing_checkpoints - ADD CONSTRAINT indexing_checkpoints_pkey PRIMARY KEY (tablename); +ALTER TABLE ONLY public.sol_meteora_dbc_config_fees + ADD CONSTRAINT sol_meteora_dbc_config_fees_pkey PRIMARY KEY (config); -- --- Name: milestones milestones_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_meteora_dbc_config_vestings sol_meteora_dbc_config_vestings_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.milestones - ADD CONSTRAINT milestones_pkey PRIMARY KEY (id, name, threshold); +ALTER TABLE ONLY public.sol_meteora_dbc_config_vestings + ADD CONSTRAINT sol_meteora_dbc_config_vestings_pkey PRIMARY KEY (config); -- --- Name: muted_users muted_users_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_meteora_dbc_configs sol_meteora_dbc_configs_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.muted_users - ADD CONSTRAINT muted_users_pkey PRIMARY KEY (muted_user_id, user_id); +ALTER TABLE ONLY public.sol_meteora_dbc_configs + ADD CONSTRAINT sol_meteora_dbc_configs_pkey PRIMARY KEY (account); -- --- Name: notification_campaign_push_open notification_campaign_push_open_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_meteora_dbc_migrations sol_meteora_dbc_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.notification_campaign_push_open - ADD CONSTRAINT notification_campaign_push_open_pkey PRIMARY KEY (campaign_id, user_id); +ALTER TABLE ONLY public.sol_meteora_dbc_migrations + ADD CONSTRAINT sol_meteora_dbc_migrations_pkey PRIMARY KEY (signature, instruction_index); -- --- Name: notification notification_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_meteora_dbc_pool_metrics sol_meteora_dbc_pool_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.notification - ADD CONSTRAINT notification_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.sol_meteora_dbc_pool_metrics + ADD CONSTRAINT sol_meteora_dbc_pool_metrics_pkey PRIMARY KEY (pool); -- --- Name: notification_seen notification_seen_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_meteora_dbc_pool_volatility_trackers sol_meteora_dbc_pool_volatility_trackers_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.notification_seen - ADD CONSTRAINT notification_seen_pkey PRIMARY KEY (user_id, seen_at); +ALTER TABLE ONLY public.sol_meteora_dbc_pool_volatility_trackers + ADD CONSTRAINT sol_meteora_dbc_pool_volatility_trackers_pkey PRIMARY KEY (pool); -- --- Name: oauth_authorization_codes oauth_authorization_codes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_meteora_dbc_pools sol_meteora_dbc_pools_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.oauth_authorization_codes - ADD CONSTRAINT oauth_authorization_codes_pkey PRIMARY KEY (code); +ALTER TABLE ONLY public.sol_meteora_dbc_pools + ADD CONSTRAINT sol_meteora_dbc_pools_pkey PRIMARY KEY (account); -- --- Name: oauth_redirect_uris oauth_redirect_uris_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_payments sol_payments_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.oauth_redirect_uris - ADD CONSTRAINT oauth_redirect_uris_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.sol_payments + ADD CONSTRAINT sol_payments_pkey PRIMARY KEY (signature, instruction_index, route_index); -- --- Name: oauth_tokens oauth_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_purchases sol_purchases_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.oauth_tokens - ADD CONSTRAINT oauth_tokens_pkey PRIMARY KEY (token); +ALTER TABLE ONLY public.sol_purchases + ADD CONSTRAINT sol_purchases_pkey PRIMARY KEY (signature, instruction_index); -- --- Name: core_indexed_blocks pk_chain_id_height; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_retry_queue sol_retry_queue_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.core_indexed_blocks - ADD CONSTRAINT pk_chain_id_height PRIMARY KEY (chain_id, height); +ALTER TABLE ONLY public.sol_retry_queue + ADD CONSTRAINT sol_retry_queue_pkey PRIMARY KEY (id); -- --- Name: collectibles pk_user_id; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_reward_disbursements sol_reward_disbursements_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.collectibles - ADD CONSTRAINT pk_user_id PRIMARY KEY (user_id); +ALTER TABLE ONLY public.sol_reward_disbursements + ADD CONSTRAINT sol_reward_disbursements_pkey PRIMARY KEY (signature, instruction_index); -- --- Name: aggregate_plays play_item_id_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_reward_manager_inits sol_reward_manager_inits_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.aggregate_plays - ADD CONSTRAINT play_item_id_pkey PRIMARY KEY (play_item_id); +ALTER TABLE ONLY public.sol_reward_manager_inits + ADD CONSTRAINT sol_reward_manager_inits_pkey PRIMARY KEY (signature, instruction_index); -- --- Name: playlist_routes playlist_routes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_slot_checkpoints sol_slot_checkpoints_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.playlist_routes - ADD CONSTRAINT playlist_routes_pkey PRIMARY KEY (owner_id, slug); +ALTER TABLE ONLY public.sol_slot_checkpoints + ADD CONSTRAINT sol_slot_checkpoints_pkey PRIMARY KEY (id); -- --- Name: playlist_seen playlist_seen_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_token_account_balance_changes sol_token_account_balance_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.playlist_seen - ADD CONSTRAINT playlist_seen_pkey PRIMARY KEY (playlist_id, seen_at, user_id); +ALTER TABLE ONLY public.sol_token_account_balance_changes + ADD CONSTRAINT sol_token_account_balance_changes_pkey PRIMARY KEY (signature, mint, account); -- --- Name: playlist_tracks playlist_tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_token_account_balances sol_token_account_balances_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.playlist_tracks - ADD CONSTRAINT playlist_tracks_pkey PRIMARY KEY (playlist_id, track_id); +ALTER TABLE ONLY public.sol_token_account_balances + ADD CONSTRAINT sol_token_account_balances_pkey PRIMARY KEY (account); -- --- Name: playlist_trending_scores playlist_trending_scores_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_token_transfers sol_token_transfers_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.playlist_trending_scores - ADD CONSTRAINT playlist_trending_scores_pkey PRIMARY KEY (playlist_id, type, version, time_range); +ALTER TABLE ONLY public.sol_token_transfers + ADD CONSTRAINT sol_token_transfers_pkey PRIMARY KEY (signature, instruction_index); -- --- Name: playlists playlists_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_transfer_memo_types sol_transfer_memo_types_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.playlists - ADD CONSTRAINT playlists_pkey PRIMARY KEY (playlist_id, txhash); +ALTER TABLE ONLY public.sol_transfer_memo_types + ADD CONSTRAINT sol_transfer_memo_types_pkey PRIMARY KEY (signature, instruction_index); -- --- Name: plays plays_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: sol_user_balances sol_user_balances_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.plays - ADD CONSTRAINT plays_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.sol_user_balances + ADD CONSTRAINT sol_user_balances_pkey PRIMARY KEY (user_id, mint); -- --- Name: prizes prizes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: spl_token_tx spl_token_tx_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.prizes - ADD CONSTRAINT prizes_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.spl_token_tx + ADD CONSTRAINT spl_token_tx_pkey PRIMARY KEY (last_scanned_slot); -- --- Name: prizes prizes_prize_id_key; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: stems stems_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.prizes - ADD CONSTRAINT prizes_prize_id_key UNIQUE (prize_id); +ALTER TABLE ONLY public.stems + ADD CONSTRAINT stems_pkey PRIMARY KEY (parent_track_id, child_track_id); -- --- Name: pubkeys pubkeys_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: subscriptions subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.pubkeys - ADD CONSTRAINT pubkeys_pkey PRIMARY KEY (wallet); +ALTER TABLE ONLY public.subscriptions + ADD CONSTRAINT subscriptions_pkey PRIMARY KEY (subscriber_id, user_id, txhash); -- --- Name: reactions reactions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: supporter_rank_ups supporter_rank_ups_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.reactions - ADD CONSTRAINT reactions_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.supporter_rank_ups + ADD CONSTRAINT supporter_rank_ups_pkey PRIMARY KEY (slot, sender_user_id, receiver_user_id); -- --- Name: related_artists related_artists_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: track_collaborators track_collaborators_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.related_artists - ADD CONSTRAINT related_artists_pkey PRIMARY KEY (user_id, related_artist_user_id); +ALTER TABLE ONLY public.track_collaborators + ADD CONSTRAINT track_collaborators_pkey PRIMARY KEY (track_id, collaborator_user_id); -- --- Name: remixes remixes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: track_delist_statuses track_delist_statuses_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.remixes - ADD CONSTRAINT remixes_pkey PRIMARY KEY (parent_track_id, child_track_id); +ALTER TABLE ONLY public.track_delist_statuses + ADD CONSTRAINT track_delist_statuses_pkey PRIMARY KEY (created_at, track_id, delisted); -- --- Name: reported_comments reported_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: track_downloads track_downloads_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.reported_comments - ADD CONSTRAINT reported_comments_pkey PRIMARY KEY (reported_comment_id, user_id); +ALTER TABLE ONLY public.track_downloads + ADD CONSTRAINT track_downloads_pkey PRIMARY KEY (parent_track_id, track_id, txhash); -- --- Name: reposts reposts_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: track_price_history track_price_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.reposts - ADD CONSTRAINT reposts_pkey PRIMARY KEY (user_id, repost_item_id, repost_type, txhash); +ALTER TABLE ONLY public.track_price_history + ADD CONSTRAINT track_price_history_pkey PRIMARY KEY (track_id, block_timestamp); -- --- Name: revert_blocks revert_blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: track_routes track_routes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.revert_blocks - ADD CONSTRAINT revert_blocks_pkey PRIMARY KEY (blocknumber); +ALTER TABLE ONLY public.track_routes + ADD CONSTRAINT track_routes_pkey PRIMARY KEY (owner_id, slug); -- --- Name: reward_codes reward_codes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: track_trending_scores track_trending_scores_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.reward_codes - ADD CONSTRAINT reward_codes_pkey PRIMARY KEY (code); +ALTER TABLE ONLY public.track_trending_scores + ADD CONSTRAINT track_trending_scores_pkey PRIMARY KEY (track_id, type, version, time_range); -- --- Name: reward_manager_txs reward_manager_txs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: tracks tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.reward_manager_txs - ADD CONSTRAINT reward_manager_txs_pkey PRIMARY KEY (signature); +ALTER TABLE ONLY public.tracks + ADD CONSTRAINT tracks_pkey PRIMARY KEY (track_id, txhash); -- --- Name: route_metrics route_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: trending_results trending_results_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.route_metrics - ADD CONSTRAINT route_metrics_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.trending_results + ADD CONSTRAINT trending_results_pkey PRIMARY KEY (rank, type, version, week); -- --- Name: rpc_cursor rpc_cursor_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: associated_wallets unique_user_wallet_chain; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.rpc_cursor - ADD CONSTRAINT rpc_cursor_pkey PRIMARY KEY (relayed_by); +ALTER TABLE ONLY public.associated_wallets + ADD CONSTRAINT unique_user_wallet_chain UNIQUE (user_id, wallet, chain); -- --- Name: rpc_error rpc_error_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: notification uq_notification; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.rpc_error - ADD CONSTRAINT rpc_error_pkey PRIMARY KEY (sig); +ALTER TABLE ONLY public.notification + ADD CONSTRAINT uq_notification UNIQUE (group_id, specifier); -- --- Name: rpc_log rpc_log_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: usdc_purchases usdc_purchases_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.rpc_log - ADD CONSTRAINT rpc_log_pkey PRIMARY KEY (sig); +ALTER TABLE ONLY public.usdc_purchases + ADD CONSTRAINT usdc_purchases_pkey PRIMARY KEY (slot, signature); -- --- Name: rpclog rpclog_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: usdc_transactions_history usdc_transactions_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.rpclog - ADD CONSTRAINT rpclog_pkey PRIMARY KEY (cuid); +ALTER TABLE ONLY public.usdc_transactions_history + ADD CONSTRAINT usdc_transactions_history_pkey PRIMARY KEY (user_bank, signature); -- --- Name: saves saves_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: usdc_user_bank_accounts usdc_user_bank_accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.saves - ADD CONSTRAINT saves_pkey PRIMARY KEY (user_id, save_item_id, save_type, txhash); +ALTER TABLE ONLY public.usdc_user_bank_accounts + ADD CONSTRAINT usdc_user_bank_accounts_pkey PRIMARY KEY (signature); -- --- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_balance_changes user_balance_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.schema_migrations - ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); +ALTER TABLE ONLY public.user_balance_changes + ADD CONSTRAINT user_balance_changes_pkey PRIMARY KEY (user_id); -- --- Name: schema_version schema_version_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_balance_history user_balance_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.schema_version - ADD CONSTRAINT schema_version_pkey PRIMARY KEY (file_name); +ALTER TABLE ONLY public.user_balance_history + ADD CONSTRAINT user_balance_history_pkey PRIMARY KEY (user_id, "timestamp", mint); -- --- Name: shares shares_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_balances user_balances_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.shares - ADD CONSTRAINT shares_pkey PRIMARY KEY (user_id, share_item_id, share_type, txhash); +ALTER TABLE ONLY public.user_balances + ADD CONSTRAINT user_balances_pkey PRIMARY KEY (user_id); -- --- Name: skipped_transactions skipped_transactions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_bank_accounts user_bank_accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.skipped_transactions - ADD CONSTRAINT skipped_transactions_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.user_bank_accounts + ADD CONSTRAINT user_bank_accounts_pkey PRIMARY KEY (signature); -- --- Name: sol_claimable_account_transfers sol_claimable_account_transfers_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_bank_txs user_bank_txs_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_claimable_account_transfers - ADD CONSTRAINT sol_claimable_account_transfers_pkey PRIMARY KEY (signature, instruction_index); +ALTER TABLE ONLY public.user_bank_txs + ADD CONSTRAINT user_bank_txs_pkey PRIMARY KEY (signature); -- --- Name: sol_claimable_accounts sol_claimable_accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_challenges user_challenges_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_claimable_accounts - ADD CONSTRAINT sol_claimable_accounts_pkey PRIMARY KEY (signature, instruction_index); +ALTER TABLE ONLY public.user_challenges + ADD CONSTRAINT user_challenges_pkey PRIMARY KEY (challenge_id, specifier); -- --- Name: sol_keypairs sol_keypairs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_delist_statuses user_delist_statuses_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_keypairs - ADD CONSTRAINT sol_keypairs_pkey PRIMARY KEY (public_key); +ALTER TABLE ONLY public.user_delist_statuses + ADD CONSTRAINT user_delist_statuses_pkey PRIMARY KEY (created_at, user_id, delisted); -- --- Name: sol_locker_vesting_escrows sol_locker_vesting_escrows_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_distinct_play_hours user_distinct_play_hours_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_locker_vesting_escrows - ADD CONSTRAINT sol_locker_vesting_escrows_pkey PRIMARY KEY (account); +ALTER TABLE ONLY public.user_distinct_play_hours + ADD CONSTRAINT user_distinct_play_hours_pkey PRIMARY KEY (user_id); -- --- Name: sol_meteora_damm_v2_initialize_custom_pool_instructions sol_meteora_damm_v2_initialize_custom_pool_instructions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_distinct_play_tracks user_distinct_play_tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_meteora_damm_v2_initialize_custom_pool_instructions - ADD CONSTRAINT sol_meteora_damm_v2_initialize_custom_pool_instructions_pkey PRIMARY KEY (signature, instruction_index); +ALTER TABLE ONLY public.user_distinct_play_tracks + ADD CONSTRAINT user_distinct_play_tracks_pkey PRIMARY KEY (user_id); -- --- Name: sol_meteora_damm_v2_pool_base_fees sol_meteora_damm_v2_pool_base_fees_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_events user_events_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_meteora_damm_v2_pool_base_fees - ADD CONSTRAINT sol_meteora_damm_v2_pool_base_fees_pkey PRIMARY KEY (pool); +ALTER TABLE ONLY public.user_events + ADD CONSTRAINT user_events_pkey PRIMARY KEY (id); -- --- Name: sol_meteora_damm_v2_pool_dynamic_fees sol_meteora_damm_v2_pool_dynamic_fees_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_listening_history user_listening_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_meteora_damm_v2_pool_dynamic_fees - ADD CONSTRAINT sol_meteora_damm_v2_pool_dynamic_fees_pkey PRIMARY KEY (pool); +ALTER TABLE ONLY public.user_listening_history + ADD CONSTRAINT user_listening_history_pkey PRIMARY KEY (user_id); -- --- Name: sol_meteora_damm_v2_pool_fees sol_meteora_damm_v2_pool_fees_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_payout_wallet_history user_payout_wallet_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_meteora_damm_v2_pool_fees - ADD CONSTRAINT sol_meteora_damm_v2_pool_fees_pkey PRIMARY KEY (pool); +ALTER TABLE ONLY public.user_payout_wallet_history + ADD CONSTRAINT user_payout_wallet_history_pkey PRIMARY KEY (user_id, block_timestamp); -- --- Name: sol_meteora_damm_v2_pool_metrics sol_meteora_damm_v2_pool_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_pubkeys user_pubkeys_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_meteora_damm_v2_pool_metrics - ADD CONSTRAINT sol_meteora_damm_v2_pool_metrics_pkey PRIMARY KEY (pool); +ALTER TABLE ONLY public.user_pubkeys + ADD CONSTRAINT user_pubkeys_pkey PRIMARY KEY (user_id); -- --- Name: sol_meteora_damm_v2_pools sol_meteora_damm_v2_pools_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_score_features user_score_features_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_meteora_damm_v2_pools - ADD CONSTRAINT sol_meteora_damm_v2_pools_pkey PRIMARY KEY (account); +ALTER TABLE ONLY public.user_score_features + ADD CONSTRAINT user_score_features_pkey PRIMARY KEY (user_id); -- --- Name: sol_meteora_damm_v2_position_metrics sol_meteora_damm_v2_position_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: user_tips user_tips_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_meteora_damm_v2_position_metrics - ADD CONSTRAINT sol_meteora_damm_v2_position_metrics_pkey PRIMARY KEY ("position"); +ALTER TABLE ONLY public.user_tips + ADD CONSTRAINT user_tips_pkey PRIMARY KEY (slot, signature); -- --- Name: sol_meteora_damm_v2_positions sol_meteora_damm_v2_positions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_meteora_damm_v2_positions - ADD CONSTRAINT sol_meteora_damm_v2_positions_pkey PRIMARY KEY (account); +ALTER TABLE ONLY public.users + ADD CONSTRAINT users_pkey PRIMARY KEY (user_id, txhash); -- --- Name: sol_meteora_dbc_config_fees sol_meteora_dbc_config_fees_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: volume_leader_exclusions volume_leader_exclusions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_meteora_dbc_config_fees - ADD CONSTRAINT sol_meteora_dbc_config_fees_pkey PRIMARY KEY (config); +ALTER TABLE ONLY public.volume_leader_exclusions + ADD CONSTRAINT volume_leader_exclusions_pkey PRIMARY KEY (address); -- --- Name: sol_meteora_dbc_config_vestings sol_meteora_dbc_config_vestings_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: agg_user_has_tracks_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_meteora_dbc_config_vestings - ADD CONSTRAINT sol_meteora_dbc_config_vestings_pkey PRIMARY KEY (config); +CREATE INDEX agg_user_has_tracks_idx ON public.aggregate_user USING btree (user_id) WHERE (total_track_count > 0); -- --- Name: sol_meteora_dbc_configs sol_meteora_dbc_configs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: artist_coin_price_history_mint_ts_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_meteora_dbc_configs - ADD CONSTRAINT sol_meteora_dbc_configs_pkey PRIMARY KEY (account); +CREATE INDEX artist_coin_price_history_mint_ts_idx ON public.artist_coin_price_history USING btree (mint, "timestamp" DESC); -- --- Name: sol_meteora_dbc_migrations sol_meteora_dbc_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: artist_coins_ticker_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_meteora_dbc_migrations - ADD CONSTRAINT sol_meteora_dbc_migrations_pkey PRIMARY KEY (signature, instruction_index); +CREATE INDEX artist_coins_ticker_idx ON public.artist_coins USING btree (ticker, user_id); -- --- Name: sol_meteora_dbc_pool_metrics sol_meteora_dbc_pool_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: INDEX artist_coins_ticker_idx; Type: COMMENT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_meteora_dbc_pool_metrics - ADD CONSTRAINT sol_meteora_dbc_pool_metrics_pkey PRIMARY KEY (pool); +COMMENT ON INDEX public.artist_coins_ticker_idx IS 'Used for getting mint address by ticker.'; -- --- Name: sol_meteora_dbc_pool_volatility_trackers sol_meteora_dbc_pool_volatility_trackers_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: artist_coins_user_id_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_meteora_dbc_pool_volatility_trackers - ADD CONSTRAINT sol_meteora_dbc_pool_volatility_trackers_pkey PRIMARY KEY (pool); +CREATE INDEX artist_coins_user_id_idx ON public.artist_coins USING btree (user_id); -- --- Name: sol_meteora_dbc_pools sol_meteora_dbc_pools_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: INDEX artist_coins_user_id_idx; Type: COMMENT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_meteora_dbc_pools - ADD CONSTRAINT sol_meteora_dbc_pools_pkey PRIMARY KEY (account); +COMMENT ON INDEX public.artist_coins_user_id_idx IS 'Used for getting coins minted by a particular artist.'; -- --- Name: sol_payments sol_payments_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: challenge_disbursements_user_id; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_payments - ADD CONSTRAINT sol_payments_pkey PRIMARY KEY (signature, instruction_index, route_index); +CREATE INDEX challenge_disbursements_user_id ON public.challenge_disbursements USING btree (user_id); -- --- Name: sol_purchases sol_purchases_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: chat_member_user_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_purchases - ADD CONSTRAINT sol_purchases_pkey PRIMARY KEY (signature, instruction_index); +CREATE INDEX chat_member_user_idx ON public.chat_member USING btree (user_id); -- --- Name: sol_retry_queue sol_retry_queue_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: chat_message_chat_created_non_blast_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_retry_queue - ADD CONSTRAINT sol_retry_queue_pkey PRIMARY KEY (id); +CREATE INDEX chat_message_chat_created_non_blast_idx ON public.chat_message USING btree (chat_id, created_at, user_id) WHERE (blast_id IS NULL); -- --- Name: sol_reward_disbursements sol_reward_disbursements_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: chat_message_reactions_updated_at_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_reward_disbursements - ADD CONSTRAINT sol_reward_disbursements_pkey PRIMARY KEY (signature, instruction_index); +CREATE INDEX chat_message_reactions_updated_at_idx ON public.chat_message_reactions USING btree (updated_at, message_id, user_id); -- --- Name: sol_reward_manager_inits sol_reward_manager_inits_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: INDEX chat_message_reactions_updated_at_idx; Type: COMMENT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_reward_manager_inits - ADD CONSTRAINT sol_reward_manager_inits_pkey PRIMARY KEY (signature, instruction_index); +COMMENT ON INDEX public.chat_message_reactions_updated_at_idx IS 'Supports DM reaction notification polling by updated_at cursor.'; -- --- Name: sol_slot_checkpoints sol_slot_checkpoints_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: claimed_prizes_mint_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_slot_checkpoints - ADD CONSTRAINT sol_slot_checkpoints_pkey PRIMARY KEY (id); +CREATE INDEX claimed_prizes_mint_idx ON public.claimed_prizes USING btree (mint); -- --- Name: sol_token_account_balance_changes sol_token_account_balance_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: INDEX claimed_prizes_mint_idx; Type: COMMENT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_token_account_balance_changes - ADD CONSTRAINT sol_token_account_balance_changes_pkey PRIMARY KEY (signature, mint, account); +COMMENT ON INDEX public.claimed_prizes_mint_idx IS 'Used for getting claimed prizes by coin mint.'; -- --- Name: sol_token_account_balances sol_token_account_balances_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: claimed_prizes_signature_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_token_account_balances - ADD CONSTRAINT sol_token_account_balances_pkey PRIMARY KEY (account); +CREATE INDEX claimed_prizes_signature_idx ON public.claimed_prizes USING btree (signature); -- --- Name: sol_token_transfers sol_token_transfers_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: INDEX claimed_prizes_signature_idx; Type: COMMENT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_token_transfers - ADD CONSTRAINT sol_token_transfers_pkey PRIMARY KEY (signature, instruction_index); +COMMENT ON INDEX public.claimed_prizes_signature_idx IS 'Used for checking if a signature has already been used.'; -- --- Name: sol_transfer_memo_types sol_transfer_memo_types_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: claimed_prizes_wallet_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_transfer_memo_types - ADD CONSTRAINT sol_transfer_memo_types_pkey PRIMARY KEY (signature, instruction_index); +CREATE INDEX claimed_prizes_wallet_idx ON public.claimed_prizes USING btree (wallet); -- --- Name: sol_user_balances sol_user_balances_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: INDEX claimed_prizes_wallet_idx; Type: COMMENT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.sol_user_balances - ADD CONSTRAINT sol_user_balances_pkey PRIMARY KEY (user_id, mint); +COMMENT ON INDEX public.claimed_prizes_wallet_idx IS 'Used for getting claimed prizes by wallet.'; -- --- Name: spl_token_tx spl_token_tx_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: comment_threads_comment_id_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.spl_token_tx - ADD CONSTRAINT spl_token_tx_pkey PRIMARY KEY (last_scanned_slot); +CREATE INDEX comment_threads_comment_id_idx ON public.comment_threads USING btree (comment_id); -- --- Name: stems stems_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: comments_blocknumber_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.stems - ADD CONSTRAINT stems_pkey PRIMARY KEY (parent_track_id, child_track_id); +CREATE INDEX comments_blocknumber_idx ON public.comments USING btree (blocknumber); -- --- Name: subscriptions subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: INDEX comments_blocknumber_idx; Type: COMMENT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.subscriptions - ADD CONSTRAINT subscriptions_pkey PRIMARY KEY (subscriber_id, user_id, txhash); +COMMENT ON INDEX public.comments_blocknumber_idx IS 'Range scans by blocknumber for the incremental FirstWeeklyComment challenge processor (c).'; -- --- Name: supporter_rank_ups supporter_rank_ups_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: comments_track_entity_created_at_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.supporter_rank_ups - ADD CONSTRAINT supporter_rank_ups_pkey PRIMARY KEY (slot, sender_user_id, receiver_user_id); +CREATE INDEX comments_track_entity_created_at_idx ON public.comments USING btree (entity_id, created_at DESC) INCLUDE (comment_id, user_id) WHERE ((entity_type = 'Track'::text) AND (is_delete = false)); -- --- Name: track_collaborators track_collaborators_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: comments_user_track_created_at_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.track_collaborators - ADD CONSTRAINT track_collaborators_pkey PRIMARY KEY (track_id, collaborator_user_id); +CREATE INDEX comments_user_track_created_at_idx ON public.comments USING btree (user_id, created_at DESC) INCLUDE (comment_id) WHERE ((entity_type = 'Track'::text) AND (is_delete = false)); -- --- Name: track_delist_statuses track_delist_statuses_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: eth_wallet_balances_updated_at_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.track_delist_statuses - ADD CONSTRAINT track_delist_statuses_pkey PRIMARY KEY (created_at, track_id, delisted); +CREATE INDEX eth_wallet_balances_updated_at_idx ON public.eth_wallet_balances USING btree (updated_at); -- --- Name: track_downloads track_downloads_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: INDEX eth_wallet_balances_updated_at_idx; Type: COMMENT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.track_downloads - ADD CONSTRAINT track_downloads_pkey PRIMARY KEY (parent_track_id, track_id, txhash); +COMMENT ON INDEX public.eth_wallet_balances_updated_at_idx IS 'Supports staleness queries / catch-up sweeps.'; -- --- Name: track_price_history track_price_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_blocks_block_height_desc_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.track_price_history - ADD CONSTRAINT track_price_history_pkey PRIMARY KEY (track_id, block_timestamp); +CREATE INDEX etl_blocks_block_height_desc_idx ON public.etl_blocks USING btree (block_height DESC); -- --- Name: track_routes track_routes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_blocks_block_height_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.track_routes - ADD CONSTRAINT track_routes_pkey PRIMARY KEY (owner_id, slug); +CREATE INDEX etl_blocks_block_height_idx ON public.etl_blocks USING btree (block_height); -- --- Name: track_trending_scores track_trending_scores_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_blocks_block_time_height_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.track_trending_scores - ADD CONSTRAINT track_trending_scores_pkey PRIMARY KEY (track_id, type, version, time_range); +CREATE INDEX etl_blocks_block_time_height_idx ON public.etl_blocks USING btree (block_time DESC, block_height DESC); -- --- Name: tracks tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_blocks_block_time_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.tracks - ADD CONSTRAINT tracks_pkey PRIMARY KEY (track_id, txhash); +CREATE INDEX etl_blocks_block_time_idx ON public.etl_blocks USING btree (block_time); -- --- Name: trending_results trending_results_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_blocks_block_time_range_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.trending_results - ADD CONSTRAINT trending_results_pkey PRIMARY KEY (rank, type, version, week); +CREATE INDEX etl_blocks_block_time_range_idx ON public.etl_blocks USING btree (block_time, block_height); -- --- Name: developer_apps unique_developer_apps_address; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_blocks_id_desc_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.developer_apps - ADD CONSTRAINT unique_developer_apps_address UNIQUE (address); +CREATE INDEX etl_blocks_id_desc_idx ON public.etl_blocks USING btree (id DESC); -- --- Name: associated_wallets unique_user_wallet_chain; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_manage_entities_cursor_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.associated_wallets - ADD CONSTRAINT unique_user_wallet_chain UNIQUE (user_id, wallet, chain); +CREATE INDEX etl_manage_entities_cursor_idx ON public.etl_manage_entities USING btree (block_height, id); -- --- Name: notification uq_notification; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_manage_entities_tx_hash_action_entity_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.notification - ADD CONSTRAINT uq_notification UNIQUE (group_id, specifier); +CREATE INDEX etl_manage_entities_tx_hash_action_entity_idx ON public.etl_manage_entities USING btree (tx_hash, action, entity_type); -- --- Name: usdc_purchases usdc_purchases_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_manage_entities_tx_hash_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.usdc_purchases - ADD CONSTRAINT usdc_purchases_pkey PRIMARY KEY (slot, signature); +CREATE INDEX etl_manage_entities_tx_hash_idx ON public.etl_manage_entities USING btree (tx_hash); -- --- Name: usdc_transactions_history usdc_transactions_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_plays_cursor_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.usdc_transactions_history - ADD CONSTRAINT usdc_transactions_history_pkey PRIMARY KEY (user_bank, signature); +CREATE INDEX etl_plays_cursor_idx ON public.etl_plays USING btree (block_height, id); -- --- Name: usdc_user_bank_accounts usdc_user_bank_accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_plays_tx_hash_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.usdc_user_bank_accounts - ADD CONSTRAINT usdc_user_bank_accounts_pkey PRIMARY KEY (signature); +CREATE INDEX etl_plays_tx_hash_idx ON public.etl_plays USING btree (tx_hash); -- --- Name: user_balance_changes user_balance_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_sla_node_reports_address_lower_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_balance_changes - ADD CONSTRAINT user_balance_changes_pkey PRIMARY KEY (user_id); +CREATE INDEX etl_sla_node_reports_address_lower_idx ON public.etl_sla_node_reports USING btree (lower(address)); -- --- Name: user_balance_history user_balance_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_sla_node_reports_address_sla_rollup_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_balance_history - ADD CONSTRAINT user_balance_history_pkey PRIMARY KEY (user_id, "timestamp", mint); +CREATE INDEX etl_sla_node_reports_address_sla_rollup_idx ON public.etl_sla_node_reports USING btree (address, sla_rollup_id); -- --- Name: user_balances user_balances_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_sla_node_reports_cursor_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_balances - ADD CONSTRAINT user_balances_pkey PRIMARY KEY (user_id); +CREATE INDEX etl_sla_node_reports_cursor_idx ON public.etl_sla_node_reports USING btree (block_height, id); -- --- Name: user_bank_accounts user_bank_accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_sla_node_reports_sla_rollup_id_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_bank_accounts - ADD CONSTRAINT user_bank_accounts_pkey PRIMARY KEY (signature); +CREATE INDEX etl_sla_node_reports_sla_rollup_id_idx ON public.etl_sla_node_reports USING btree (sla_rollup_id); -- --- Name: user_bank_txs user_bank_txs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_sla_rollups_block_height_desc_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_bank_txs - ADD CONSTRAINT user_bank_txs_pkey PRIMARY KEY (signature); +CREATE INDEX etl_sla_rollups_block_height_desc_idx ON public.etl_sla_rollups USING btree (block_height DESC, id DESC); -- --- Name: user_challenges user_challenges_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_sla_rollups_cursor_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_challenges - ADD CONSTRAINT user_challenges_pkey PRIMARY KEY (challenge_id, specifier); +CREATE INDEX etl_sla_rollups_cursor_idx ON public.etl_sla_rollups USING btree (block_height, id); -- --- Name: user_delist_statuses user_delist_statuses_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_sla_rollups_latest_covering_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_delist_statuses - ADD CONSTRAINT user_delist_statuses_pkey PRIMARY KEY (created_at, user_id, delisted); +CREATE INDEX etl_sla_rollups_latest_covering_idx ON public.etl_sla_rollups USING btree (block_height DESC, id DESC, block_start, block_end, validator_count, block_quota, bps, tps); -- --- Name: user_distinct_play_hours user_distinct_play_hours_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_sla_rollups_tx_hash_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_distinct_play_hours - ADD CONSTRAINT user_distinct_play_hours_pkey PRIMARY KEY (user_id); +CREATE INDEX etl_sla_rollups_tx_hash_idx ON public.etl_sla_rollups USING btree (tx_hash); -- --- Name: user_distinct_play_tracks user_distinct_play_tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_storage_proof_verifications_cursor_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_distinct_play_tracks - ADD CONSTRAINT user_distinct_play_tracks_pkey PRIMARY KEY (user_id); +CREATE INDEX etl_storage_proof_verifications_cursor_idx ON public.etl_storage_proof_verifications USING btree (block_height, id); -- --- Name: user_events user_events_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_storage_proof_verifications_tx_hash_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_events - ADD CONSTRAINT user_events_pkey PRIMARY KEY (id); +CREATE INDEX etl_storage_proof_verifications_tx_hash_idx ON public.etl_storage_proof_verifications USING btree (tx_hash); -- --- Name: user_listening_history user_listening_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_storage_proofs_cursor_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_listening_history - ADD CONSTRAINT user_listening_history_pkey PRIMARY KEY (user_id); +CREATE INDEX etl_storage_proofs_cursor_idx ON public.etl_storage_proofs USING btree (block_height, id); -- --- Name: user_payout_wallet_history user_payout_wallet_history_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_storage_proofs_height_address_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_payout_wallet_history - ADD CONSTRAINT user_payout_wallet_history_pkey PRIMARY KEY (user_id, block_timestamp); +CREATE INDEX etl_storage_proofs_height_address_idx ON public.etl_storage_proofs USING btree (height, address); -- --- Name: user_pubkeys user_pubkeys_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_storage_proofs_height_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_pubkeys - ADD CONSTRAINT user_pubkeys_pkey PRIMARY KEY (user_id); +CREATE INDEX etl_storage_proofs_height_idx ON public.etl_storage_proofs USING btree (height); -- --- Name: user_score_features user_score_features_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_storage_proofs_height_range_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_score_features - ADD CONSTRAINT user_score_features_pkey PRIMARY KEY (user_id); +CREATE INDEX etl_storage_proofs_height_range_idx ON public.etl_storage_proofs USING btree (height, address) WHERE (height >= 0); -- --- Name: user_tips user_tips_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_storage_proofs_status_fail_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.user_tips - ADD CONSTRAINT user_tips_pkey PRIMARY KEY (slot, signature); +CREATE INDEX etl_storage_proofs_status_fail_idx ON public.etl_storage_proofs USING btree (height, address) WHERE (status = 'fail'::public.etl_proof_status); -- --- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_storage_proofs_status_unresolved_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.users - ADD CONSTRAINT users_pkey PRIMARY KEY (user_id, txhash); +CREATE INDEX etl_storage_proofs_status_unresolved_idx ON public.etl_storage_proofs USING btree (height, address) WHERE (status = 'unresolved'::public.etl_proof_status); -- --- Name: volume_leader_exclusions volume_leader_exclusions_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: etl_storage_proofs_tx_hash_idx; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.volume_leader_exclusions - ADD CONSTRAINT volume_leader_exclusions_pkey PRIMARY KEY (address); +CREATE INDEX etl_storage_proofs_tx_hash_idx ON public.etl_storage_proofs USING btree (tx_hash); -- --- Name: agg_user_has_tracks_idx; Type: INDEX; Schema: public; Owner: - +-- Name: etl_transactions_address_filter_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX agg_user_has_tracks_idx ON public.aggregate_user USING btree (user_id) WHERE (total_track_count > 0); +CREATE INDEX etl_transactions_address_filter_idx ON public.etl_transactions USING btree (lower(address), tx_type, created_at, block_height DESC, tx_index DESC); -- --- Name: artist_coin_price_history_mint_ts_idx; Type: INDEX; Schema: public; Owner: - +-- Name: etl_transactions_address_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX artist_coin_price_history_mint_ts_idx ON public.artist_coin_price_history USING btree (mint, "timestamp" DESC); +CREATE INDEX etl_transactions_address_idx ON public.etl_transactions USING btree (address); -- --- Name: artist_coins_ticker_idx; Type: INDEX; Schema: public; Owner: - +-- Name: etl_transactions_address_lower_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX artist_coins_ticker_idx ON public.artist_coins USING btree (ticker, user_id); +CREATE INDEX etl_transactions_address_lower_idx ON public.etl_transactions USING btree (lower(address)); -- --- Name: INDEX artist_coins_ticker_idx; Type: COMMENT; Schema: public; Owner: - +-- Name: etl_transactions_block_height_desc_idx; Type: INDEX; Schema: public; Owner: - -- -COMMENT ON INDEX public.artist_coins_ticker_idx IS 'Used for getting mint address by ticker.'; +CREATE INDEX etl_transactions_block_height_desc_idx ON public.etl_transactions USING btree (block_height DESC, tx_index DESC); -- --- Name: artist_coins_user_id_idx; Type: INDEX; Schema: public; Owner: - +-- Name: etl_transactions_created_at_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX artist_coins_user_id_idx ON public.artist_coins USING btree (user_id); +CREATE INDEX etl_transactions_created_at_idx ON public.etl_transactions USING btree (created_at); -- --- Name: INDEX artist_coins_user_id_idx; Type: COMMENT; Schema: public; Owner: - +-- Name: etl_transactions_created_at_type_idx; Type: INDEX; Schema: public; Owner: - -- -COMMENT ON INDEX public.artist_coins_user_id_idx IS 'Used for getting coins minted by a particular artist.'; +CREATE INDEX etl_transactions_created_at_type_idx ON public.etl_transactions USING btree (created_at, tx_type); -- --- Name: challenge_disbursements_user_id; Type: INDEX; Schema: public; Owner: - +-- Name: etl_transactions_cursor_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX challenge_disbursements_user_id ON public.challenge_disbursements USING btree (user_id); +CREATE INDEX etl_transactions_cursor_idx ON public.etl_transactions USING btree (block_height, id); -- --- Name: chat_member_user_idx; Type: INDEX; Schema: public; Owner: - +-- Name: etl_transactions_id_desc_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX chat_member_user_idx ON public.chat_member USING btree (user_id); +CREATE INDEX etl_transactions_id_desc_idx ON public.etl_transactions USING btree (id DESC); -- --- Name: chat_message_chat_created_non_blast_idx; Type: INDEX; Schema: public; Owner: - +-- Name: etl_transactions_tx_hash_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX chat_message_chat_created_non_blast_idx ON public.chat_message USING btree (chat_id, created_at, user_id) WHERE (blast_id IS NULL); +CREATE UNIQUE INDEX etl_transactions_tx_hash_idx ON public.etl_transactions USING btree (tx_hash); -- --- Name: chat_message_reactions_updated_at_idx; Type: INDEX; Schema: public; Owner: - +-- Name: etl_transactions_tx_type_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX chat_message_reactions_updated_at_idx ON public.chat_message_reactions USING btree (updated_at, message_id, user_id); +CREATE INDEX etl_transactions_tx_type_idx ON public.etl_transactions USING btree (tx_type); -- --- Name: INDEX chat_message_reactions_updated_at_idx; Type: COMMENT; Schema: public; Owner: - +-- Name: etl_validator_deregistrations_comet_address_idx; Type: INDEX; Schema: public; Owner: - -- -COMMENT ON INDEX public.chat_message_reactions_updated_at_idx IS 'Supports DM reaction notification polling by updated_at cursor.'; +CREATE INDEX etl_validator_deregistrations_comet_address_idx ON public.etl_validator_deregistrations USING btree (comet_address); -- --- Name: claimed_prizes_mint_idx; Type: INDEX; Schema: public; Owner: - +-- Name: etl_validator_deregistrations_cursor_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX claimed_prizes_mint_idx ON public.claimed_prizes USING btree (mint); +CREATE INDEX etl_validator_deregistrations_cursor_idx ON public.etl_validator_deregistrations USING btree (block_height, id); -- --- Name: INDEX claimed_prizes_mint_idx; Type: COMMENT; Schema: public; Owner: - +-- Name: etl_validator_deregistrations_tx_hash_idx; Type: INDEX; Schema: public; Owner: - -- -COMMENT ON INDEX public.claimed_prizes_mint_idx IS 'Used for getting claimed prizes by coin mint.'; +CREATE INDEX etl_validator_deregistrations_tx_hash_idx ON public.etl_validator_deregistrations USING btree (tx_hash); -- --- Name: claimed_prizes_signature_idx; Type: INDEX; Schema: public; Owner: - +-- Name: etl_validator_misbehavior_deregistrations_cursor_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX claimed_prizes_signature_idx ON public.claimed_prizes USING btree (signature); +CREATE INDEX etl_validator_misbehavior_deregistrations_cursor_idx ON public.etl_validator_misbehavior_deregistrations USING btree (block_height, id); -- --- Name: INDEX claimed_prizes_signature_idx; Type: COMMENT; Schema: public; Owner: - +-- Name: etl_validator_registrations_comet_address_idx; Type: INDEX; Schema: public; Owner: - -- -COMMENT ON INDEX public.claimed_prizes_signature_idx IS 'Used for checking if a signature has already been used.'; +CREATE INDEX etl_validator_registrations_comet_address_idx ON public.etl_validator_registrations USING btree (comet_address); -- --- Name: claimed_prizes_wallet_idx; Type: INDEX; Schema: public; Owner: - +-- Name: etl_validator_registrations_cursor_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX claimed_prizes_wallet_idx ON public.claimed_prizes USING btree (wallet); +CREATE INDEX etl_validator_registrations_cursor_idx ON public.etl_validator_registrations USING btree (block_height, id); -- --- Name: INDEX claimed_prizes_wallet_idx; Type: COMMENT; Schema: public; Owner: - +-- Name: etl_validator_registrations_tx_hash_idx; Type: INDEX; Schema: public; Owner: - -- -COMMENT ON INDEX public.claimed_prizes_wallet_idx IS 'Used for getting claimed prizes by wallet.'; +CREATE INDEX etl_validator_registrations_tx_hash_idx ON public.etl_validator_registrations USING btree (tx_hash); -- --- Name: comment_threads_comment_id_idx; Type: INDEX; Schema: public; Owner: - +-- Name: etl_validators_active_reports_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX comment_threads_comment_id_idx ON public.comment_threads USING btree (comment_id); +CREATE INDEX etl_validators_active_reports_idx ON public.etl_validators USING btree (status, comet_address) WHERE (status = 'active'::text); -- --- Name: comments_blocknumber_idx; Type: INDEX; Schema: public; Owner: - +-- Name: etl_validators_address_lower_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX comments_blocknumber_idx ON public.comments USING btree (blocknumber); +CREATE INDEX etl_validators_address_lower_idx ON public.etl_validators USING btree (lower(address)); -- --- Name: INDEX comments_blocknumber_idx; Type: COMMENT; Schema: public; Owner: - +-- Name: etl_validators_comet_address_idx; Type: INDEX; Schema: public; Owner: - -- -COMMENT ON INDEX public.comments_blocknumber_idx IS 'Range scans by blocknumber for the incremental FirstWeeklyComment challenge processor (c).'; +CREATE INDEX etl_validators_comet_address_idx ON public.etl_validators USING btree (comet_address); -- --- Name: comments_user_track_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- Name: etl_validators_comet_address_lower_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX comments_user_track_created_at_idx ON public.comments USING btree (user_id, created_at DESC) INCLUDE (comment_id) WHERE ((entity_type = 'Track'::text) AND (is_delete = false)); +CREATE INDEX etl_validators_comet_address_lower_idx ON public.etl_validators USING btree (lower(comet_address)); -- --- Name: eth_wallet_balances_updated_at_idx; Type: INDEX; Schema: public; Owner: - +-- Name: etl_validators_status_covering_idx; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX eth_wallet_balances_updated_at_idx ON public.eth_wallet_balances USING btree (updated_at); +CREATE INDEX etl_validators_status_covering_idx ON public.etl_validators USING btree (status, comet_address, endpoint, node_type, spid, voting_power) WHERE (status = 'active'::text); -- --- Name: INDEX eth_wallet_balances_updated_at_idx; Type: COMMENT; Schema: public; Owner: - +-- Name: etl_validators_status_idx; Type: INDEX; Schema: public; Owner: - -- -COMMENT ON INDEX public.eth_wallet_balances_updated_at_idx IS 'Supports staleness queries / catch-up sweeps.'; +CREATE INDEX etl_validators_status_idx ON public.etl_validators USING btree (status); -- @@ -12621,6 +13836,13 @@ CREATE INDEX fix_tracks_top_genre_users_idx ON public.tracks USING btree (track_ CREATE INDEX follows_blocknumber_idx ON public.follows USING btree (blocknumber); +-- +-- Name: follows_current_uniq_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX follows_current_uniq_idx ON public.follows USING btree (follower_user_id, followee_user_id) WHERE (is_current = true); + + -- -- Name: follows_inbound_idx; Type: INDEX; Schema: public; Owner: - -- @@ -12719,6 +13941,13 @@ CREATE INDEX idx_api_metrics_routes_route_pattern ON public.api_metrics_routes U CREATE INDEX idx_chain_blockhash ON public.core_indexed_blocks USING btree (blockhash); +-- +-- Name: idx_chain_id_height; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_chain_id_height ON public.core_indexed_blocks USING btree (chain_id, height); + + -- -- Name: idx_challenge_disbursements_created_at; Type: INDEX; Schema: public; Owner: - -- @@ -12754,6 +13983,13 @@ CREATE INDEX idx_chat_message_reactions_message_id ON public.chat_message_reacti CREATE INDEX idx_chat_message_user_id ON public.chat_message USING btree (user_id, created_at); +-- +-- Name: idx_dashboard_wallet_users_user_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_dashboard_wallet_users_user_id ON public.dashboard_wallet_users USING btree (user_id); + + -- -- Name: idx_ddex_release_ids; Type: INDEX; Schema: public; Owner: - -- @@ -12845,6 +14081,13 @@ CREATE INDEX idx_genre_related_artists ON public.aggregate_user USING btree (dom CREATE INDEX idx_grants_grantee_address ON public.grants USING btree (grantee_address, is_revoked, created_at DESC) WHERE (is_current = true); +-- +-- Name: idx_grants_user_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_grants_user_id ON public.grants USING btree (user_id); + + -- -- Name: idx_lower_wallet; Type: INDEX; Schema: public; Owner: - -- @@ -12992,6 +14235,20 @@ COMMENT ON INDEX public.idx_sol_reward_manager_inits_mint IS 'Index to quickly f CREATE INDEX idx_track_collaborators_collaborator ON public.track_collaborators USING btree (collaborator_user_id, status, track_id); +-- +-- Name: idx_track_downloads_track_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_track_downloads_track_id ON public.track_downloads USING btree (track_id); + + +-- +-- Name: idx_track_downloads_user_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX idx_track_downloads_user_id ON public.track_downloads USING btree (user_id); + + -- -- Name: idx_track_status; Type: INDEX; Schema: public; Owner: - -- @@ -13188,6 +14445,13 @@ CREATE INDEX ix_notification_cooldown_user_ids ON public.notification USING gin COMMENT ON INDEX public.ix_notification_cooldown_user_ids IS 'Partial GIN for the on_user_challenge trigger''s cooldown-window check; replaces a multi-second IO-bound scan against the full 8GB notification table with a tiny in-subset lookup.'; +-- +-- Name: ix_oauth_redirect_uris_client_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX ix_oauth_redirect_uris_client_id ON public.oauth_redirect_uris USING btree (client_id); + + -- -- Name: ix_playlist_trending_scores_playlist_id; Type: INDEX; Schema: public; Owner: - -- @@ -13335,6 +14599,27 @@ CREATE INDEX ix_user_tips_slot ON public.user_tips USING btree (slot); CREATE INDEX milestones_name_idx ON public.milestones USING btree (name, id); +-- +-- Name: mv_dashboard_transaction_stats_24h_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX mv_dashboard_transaction_stats_24h_idx ON public.mv_dashboard_transaction_stats USING btree (transactions_24h); + + +-- +-- Name: mv_dashboard_transaction_types_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX mv_dashboard_transaction_types_idx ON public.mv_dashboard_transaction_types USING btree (tx_type, transaction_count); + + +-- +-- Name: new_chain_queue_confirmed_block_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX new_chain_queue_confirmed_block_idx ON public.new_chain_queue USING btree (confirmed_block); + + -- -- Name: notification_multi_recipient_user_ids_idx; Type: INDEX; Schema: public; Owner: - -- @@ -13384,6 +14669,13 @@ CREATE INDEX playlist_created_at_idx ON public.playlists USING btree (created_at CREATE INDEX playlist_owner_idx ON public.playlists USING btree (playlist_owner_id, created_at); +-- +-- Name: playlist_routes_owner_title_slug_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX playlist_routes_owner_title_slug_idx ON public.playlist_routes USING btree (owner_id, title_slug, collision_id); + + -- -- Name: playlist_routes_playlist_id_idx; Type: INDEX; Schema: public; Owner: - -- @@ -13440,6 +14732,13 @@ CREATE INDEX related_artists_related_artist_id_idx ON public.related_artists USI CREATE INDEX remixes_child_idx ON public.remixes USING btree (child_track_id, parent_track_id); +-- +-- Name: reposts_current_uniq_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX reposts_current_uniq_idx ON public.reposts USING btree (user_id, repost_item_id, repost_type) WHERE (is_current = true); + + -- -- Name: reposts_item_idx; Type: INDEX; Schema: public; Owner: - -- @@ -13510,6 +14809,13 @@ CREATE INDEX rpclog_method_idx ON public.rpclog USING btree (method); CREATE INDEX rpclog_wallet_idx ON public.rpclog USING btree (wallet); +-- +-- Name: saves_current_uniq_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX saves_current_uniq_idx ON public.saves USING btree (user_id, save_item_id, save_type) WHERE (is_current = true); + + -- -- Name: saves_item_idx; Type: INDEX; Schema: public; Owner: - -- @@ -13916,6 +15222,13 @@ CREATE INDEX sol_user_balances_mint_user_id_idx ON public.sol_user_balances USIN COMMENT ON INDEX public.sol_user_balances_mint_user_id_idx IS 'Index for quick access to user balances by mint and user ID.'; +-- +-- Name: subscriptions_current_uniq_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX subscriptions_current_uniq_idx ON public.subscriptions USING btree (subscriber_id, user_id) WHERE (is_current = true); + + -- -- Name: subscriptions_entity_type_entity_id_idx; Type: INDEX; Schema: public; Owner: - -- @@ -13986,6 +15299,13 @@ CREATE INDEX track_owner_idx ON public.tracks USING btree (owner_id, created_at) CREATE INDEX track_routes_owner_title_slug_collision_idx ON public.track_routes USING btree (owner_id, title_slug, collision_id DESC); +-- +-- Name: track_routes_owner_title_slug_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX track_routes_owner_title_slug_idx ON public.track_routes USING btree (owner_id, title_slug, collision_id); + + -- -- Name: track_routes_track_id_idx; Type: INDEX; Schema: public; Owner: - -- @@ -14105,6 +15425,13 @@ CREATE INDEX user_events_user_id_idx ON public.user_events USING btree (user_id) CREATE INDEX user_payout_wallet_history_wallet_idx ON public.user_payout_wallet_history USING btree (spl_usdc_payout_wallet, block_timestamp); +-- +-- Name: users_current_uniq_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX users_current_uniq_idx ON public.users USING btree (user_id) WHERE (is_current = true); + + -- -- Name: users_new_blocknumber_idx; Type: INDEX; Schema: public; Owner: - -- @@ -14560,6 +15887,20 @@ CREATE TRIGGER trg_users AFTER INSERT OR UPDATE ON public.users FOR EACH ROW EXE CREATE TRIGGER trigger_grant_change AFTER INSERT OR UPDATE ON public.grants FOR EACH ROW EXECUTE FUNCTION public.process_grant_change(); +-- +-- Name: etl_blocks trigger_notify_new_block; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER trigger_notify_new_block AFTER INSERT ON public.etl_blocks FOR EACH ROW EXECUTE FUNCTION public.notify_new_block(); + + +-- +-- Name: etl_plays trigger_notify_new_plays; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER trigger_notify_new_plays AFTER INSERT ON public.etl_plays FOR EACH ROW EXECUTE FUNCTION public.notify_new_plays(); + + -- -- Name: track_collaborators trigger_track_collaborator_change; Type: TRIGGER; Schema: public; Owner: - -- @@ -14671,6 +16012,14 @@ ALTER TABLE ONLY public.developer_apps ADD CONSTRAINT developer_apps_blocknumber_fkey FOREIGN KEY (blocknumber) REFERENCES public.blocks(number) ON DELETE CASCADE; +-- +-- Name: etl_sla_node_reports etl_sla_node_reports_sla_rollup_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.etl_sla_node_reports + ADD CONSTRAINT etl_sla_node_reports_sla_rollup_id_fkey FOREIGN KEY (sla_rollup_id) REFERENCES public.etl_sla_rollups(id); + + -- -- Name: events events_blocknumber_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -14851,3 +16200,4 @@ ALTER TABLE ONLY public.users -- PostgreSQL database dump complete -- + diff --git a/sql/03_migration_tracker.sql b/sql/03_migration_tracker.sql index 216d8300..7dfc0bff 100644 --- a/sql/03_migration_tracker.sql +++ b/sql/03_migration_tracker.sql @@ -106,7 +106,6 @@ functions/compute_user_score.sql 814b5fa3d1383d3e216943b4ff8c4877 2026-05-27 00: functions/country_to_iso_alpha2.sql 218832f0607aeca4fce99815a07f7a85 2026-05-27 00:22:35.592939+00 functions/find_track.sql f09431015118f31aa7b4ac49d14e7639 2026-05-27 00:22:35.667572+00 functions/handle_artist_coins.sql 21ed1610d80cceca2262efb1338060ed 2026-05-27 00:22:35.905536+00 -functions/handle_challenge_disbursements.sql 1bbf82cc035971d828ed96f3ea1a23d6 2026-05-29 22:00:00+00 functions/handle_chat_blast.sql ccd276957c1b68bfc82fb5a11bac09ee 2026-05-27 00:22:36.155215+00 functions/handle_chat_message.sql 31bebee3d0437133f1f53c2eadb7b391 2026-05-27 00:22:36.229275+00 functions/handle_chat_message_reaction.sql b898313aa8f31c61df7f1e6dd791ef31 2026-05-27 00:22:36.304728+00 @@ -125,7 +124,6 @@ functions/handle_supporter_rank_ups.sql dea497f1859ade282b4f7d33687e6fe7 2026-05 functions/handle_usdc_purchase.sql c35bccc2789ae0641d413d28a131ef8d 2026-05-27 00:22:37.800109+00 functions/handle_user.sql 169778112e5362ee20af56d9b8f274c5 2026-05-27 00:22:37.955619+00 functions/handle_user_balance_changes.sql 1ae7f99f4f37194cdf27dc3189ebc858 2026-05-27 00:22:38.02983+00 -functions/handle_user_challenges.sql 8a1287bc971c83e7440b88da7c86e93d 2026-05-29 22:00:00.1+00 functions/handle_user_tip.sql e4bde4e7e04b0ed8254690959513bd69 2026-05-27 00:22:38.167097+00 functions/is_country_eur.sql c5641d570edb9cd47cd4e38d883e941a 2026-05-27 00:22:38.234372+00 functions/notify_pending_purchase_revalidation.sql beb9eebc6bd34ab069c7b90a51bb8bb3 2026-05-27 00:22:38.378429+00 @@ -133,7 +131,6 @@ functions/price_from_sqrt_price.sql 1b217f211adba88e3f12d1d6c81fc97d 2026-05-27 functions/refresh_all_user_scores.sql 04935173f102e5e28b5c384e312102c1 2026-05-27 00:22:38.539364+00 functions/update_sol_user_balance.sql 4a297a671c74a683814ff217bd097589 2026-05-27 00:22:38.619283+00 functions/user_mint_balance_at.sql 6d227781d4d97500e0ec2bb76e8fa295 2026-05-27 00:22:38.701765+00 -views/artist_coin_prices.sql 10a65b64b7d13aaabe18ad1055e9fd7b 2026-05-27 00:22:38.820919+00 views/v_challenge_disbursements.sql 74a0a05af6a02f82af3695d5c3ade45c 2026-05-27 00:22:38.899214+00 views/v_usdc_purchases.sql 322a527e132aed647c39b70d63aa6b51 2026-05-27 00:22:39.061667+00 migrations/0204_backfill_eth_wallet_balances_tracked.sql d8b752794c42edb94f0d43633e14208c 2026-05-28 00:56:10.178339+00 @@ -166,6 +163,8 @@ functions/handle_track.sql c2d4c5674b0cb1db907ad625fd957c91 2026-07-28 05:42:29. functions/notify_on_row.sql a326d476636de01dd939047526b0cb92 2026-07-28 05:42:29.345724+00 preflight/0001_initial_block.sql 6cc3c0833c195a1104bed5bf849c0266 2026-07-28 05:42:29.588508+00 functions/handle_comment_reaction.sql 8153e3cdb922265857b6beaf20d29733 2026-05-30 01:37:22.856663+00 +functions/handle_user_challenges.sql 202037a6ec14955885a479648e2cc57a 2026-08-05 00:50:26.86158+00 +views/artist_coin_prices.sql fbfb4b530235c4b95f851bf5be2a063d 2026-08-05 00:50:27.089199+00 functions/handle_comment_thread.sql 6eb74eb92cf3a01421498df96c6832f3 2026-05-30 01:37:22.955997+00 functions/handle_eth_wallet_balance_change.sql 3e31160b4bc55e951d9dfa4d994c180b 2026-05-30 01:37:23.054573+00 functions/handle_fan_club_text_post.sql 531bf682bcfd67c6866faf8ccdf7603b 2026-05-30 01:37:23.160142+00 @@ -208,6 +207,14 @@ migrations/0229_artist_coin_stats_onchain.sql 3e469a25759d4598603e4dc230466be3 2 migrations/0230_artist_coin_price_history.sql 3f8e262d95c76c2b58d4eea8f2135840 2026-07-28 05:45:38.06593+00 migrations/0231_artist_coin_volume_accumulator.sql 08ad700f8e10b84ee2c1b1e3eecbe033 2026-07-28 05:45:38.134036+00 views/artist_coin_stats_comparison.sql e323f13c890cf86ce06d164523c1ec5b 2026-07-28 05:45:38.857194+00 +migrations/0232_new_chain_queue.sql 50ba5b4bee289fddc17316c505dab465 2026-08-05 00:50:25.543262+00 +migrations/0233_comments_track_entity_created_at_idx.sql a35b92644e65c68f924c0ed638c3ea90 2026-08-05 00:50:25.665626+00 +migrations/0233_notification_id_bigint.sql 5ae9ed5cae27021c6865b3508aa62a7d 2026-08-05 00:50:25.786408+00 +migrations/0234_drop_artist_coin_volume_accumulator.sql e161882135bb98d95349fc01b5dd08d8 2026-08-05 00:50:25.877491+00 +migrations/0235_drop_coin_stats_shadow.sql ecbd5cd4d2edd02bbb86d760c9768388 2026-08-05 00:50:25.971214+00 +migrations/0236_saves_reposts_album_to_playlist.sql 5bd5036831dbfa656352dfd937c3fe5c 2026-08-05 00:50:26.077564+00 +migrations/0237_users_one_current_row_backfill.sql b48ab562bc1ab92d12a17795a59cdf84 2026-08-05 00:50:26.167093+00 +functions/handle_challenge_disbursements.sql 32db00f1ecfcfbda0094c0a5e1e6e300 2026-08-05 00:50:26.417396+00 \.