-- Single-node seed: 1 provider + 1 status='up' node, so GET /v1/nodes returns
-- this box and the client can connect to it. Placeholders (__VAR__) are filled
-- by deploy.sh from the generated REALITY keypair + the VPS public IP.
--
-- Idempotent: fixed uuid, delete-then-insert so re-running deploy.sh refreshes
-- the row without duplicating it. The REALITY keys MUST stay stable across
-- re-deploys (deploy.sh persists them in /etc/pangolin/reality.env) or already
-- issued client configs would break.

DELETE FROM nodes     WHERE uuid = '__NODE_UUID__';
DELETE FROM providers WHERE name = 'single-node';

INSERT INTO providers (name, api_kind, regions, pool, enabled)
VALUES ('single-node', 'manual', '["__REGION__"]', 'consumable', 1);

INSERT INTO nodes
  (uuid, region, name_zh, name_en, role, tier, endpoint, hy2_port,
   reality_pbk, reality_prk, reality_short_id, reality_sni, provider_id, status, weight)
VALUES (
  '__NODE_UUID__',
  '__REGION__', '__NAME_ZH__', '__NAME_EN__',
  'exit', 'free',
  '__ENDPOINT__', __HY2_PORT__,
  '__REALITY_PBK__', '__REALITY_PRK__', '__REALITY_SHORT_ID__',
  '__REALITY_SNI__',
  (SELECT id FROM providers WHERE name = 'single-node' LIMIT 1),
  'up', 100
);
