BEGIN; CREATE TABLE IF NOT EXISTS xs_read_pressure_config(id boolean PRIMARY KEY DEFAULT true CHECK(id),concurrency integer NOT NULL DEFAULT 2 CHECK(concurrency BETWEEN 1 AND 8)); INSERT INTO xs_read_pressure_config(id) VALUES(true) ON CONFLICT DO NOTHING; CREATE TABLE IF NOT EXISTS xs_read_permit(slot integer PRIMARY KEY,owner text,lease_until timestamptz); INSERT INTO xs_read_permit(slot) SELECT generate_series(1,8) ON CONFLICT DO NOTHING; CREATE TABLE IF NOT EXISTS xs_read_cache( key text PRIMARY KEY,company text NOT NULL,scope text NOT NULL,revision text NOT NULL, value jsonb,expires_at timestamptz NOT NULL DEFAULT 'epoch',owner text,lease_until timestamptz ); CREATE INDEX IF NOT EXISTS xs_read_cache_expiry ON xs_read_cache(expires_at); COMMIT;