20 lines
1.1 KiB
SQL
20 lines
1.1 KiB
SQL
ALTER TABLE gateway_settings
|
|
ADD COLUMN routing_weights jsonb NOT NULL DEFAULT '{"country":1000,"region":100,"city":20,"carrier":10,"asn":10}'::jsonb,
|
|
ADD COLUMN recovery_ramp_seconds integer NOT NULL DEFAULT 300 CHECK (recovery_ramp_seconds BETWEEN 0 AND 3600),
|
|
ADD CONSTRAINT gateway_settings_routing_weights_object CHECK (jsonb_typeof(routing_weights) = 'object');
|
|
|
|
ALTER TABLE gateway_route_events
|
|
ADD COLUMN username text NOT NULL DEFAULT '',
|
|
ADD COLUMN device_hash text NOT NULL DEFAULT '',
|
|
ADD COLUMN resource_id text NOT NULL DEFAULT '',
|
|
ADD COLUMN path_class text NOT NULL DEFAULT 'other'
|
|
CHECK (path_class IN ('login','browse','image','playback','transcode','websocket','other')),
|
|
ADD COLUMN selection_source text NOT NULL DEFAULT '';
|
|
|
|
CREATE INDEX gateway_route_events_outcome_created_idx
|
|
ON gateway_route_events(outcome,created_at DESC);
|
|
CREATE INDEX gateway_route_events_location_created_idx
|
|
ON gateway_route_events(country,region,carrier,created_at DESC);
|
|
CREATE INDEX gateway_route_events_username_created_idx
|
|
ON gateway_route_events(username,created_at DESC) WHERE username <> '';
|