ui changes and cs prices
All checks were successful
Test and deploy staging / staging (push) Successful in 11m52s
All checks were successful
Test and deploy staging / staging (push) Successful in 11m52s
This commit is contained in:
45
scripts/cs-prices-migration.sql
Normal file
45
scripts/cs-prices-migration.sql
Normal file
@@ -0,0 +1,45 @@
|
||||
CREATE TABLE IF NOT EXISTS cs_market_items (
|
||||
id serial PRIMARY KEY,
|
||||
market_hash_name text NOT NULL,
|
||||
name text NOT NULL,
|
||||
icon_url text,
|
||||
item_type text,
|
||||
first_seen_at timestamptz NOT NULL DEFAULT now(),
|
||||
last_seen_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS cs_market_items_hash_idx ON cs_market_items (market_hash_name);
|
||||
CREATE INDEX IF NOT EXISTS cs_market_items_name_idx ON cs_market_items (name);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS cs_item_dimensions (
|
||||
item_id integer NOT NULL REFERENCES cs_market_items(id) ON DELETE CASCADE,
|
||||
key text NOT NULL,
|
||||
value text NOT NULL
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS cs_item_dimensions_unique_idx ON cs_item_dimensions (item_id, key);
|
||||
CREATE INDEX IF NOT EXISTS cs_item_dimensions_filter_idx ON cs_item_dimensions (key, value, item_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS cs_price_streams (
|
||||
source text NOT NULL,
|
||||
currency text NOT NULL,
|
||||
kind text NOT NULL
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS cs_price_streams_unique_idx
|
||||
ON cs_price_streams (source, currency, kind);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS cs_price_observations (
|
||||
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
item_id integer NOT NULL REFERENCES cs_market_items(id) ON DELETE CASCADE,
|
||||
source text NOT NULL,
|
||||
currency text NOT NULL,
|
||||
observed_at timestamptz NOT NULL,
|
||||
price_cents integer NOT NULL CHECK (price_cents >= 0),
|
||||
volume integer CHECK (volume IS NULL OR volume >= 0),
|
||||
kind text NOT NULL,
|
||||
imported_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS cs_price_observations_unique_idx
|
||||
ON cs_price_observations (item_id, source, currency, observed_at, kind);
|
||||
CREATE INDEX IF NOT EXISTS cs_price_observations_lookup_idx
|
||||
ON cs_price_observations (item_id, source, currency, observed_at);
|
||||
CREATE INDEX IF NOT EXISTS cs_price_observations_time_idx
|
||||
ON cs_price_observations (observed_at);
|
||||
Reference in New Issue
Block a user