CREATE TABLE "plan_features" (
    "id"         TEXT         NOT NULL,
    "plan"       "Plan"       NOT NULL,
    "label"      TEXT         NOT NULL,
    "sortOrder"  INTEGER      NOT NULL DEFAULT 0,
    "createdAt"  TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt"  TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

    CONSTRAINT "plan_features_pkey" PRIMARY KEY ("id")
);

CREATE INDEX "plan_features_plan_sortOrder_idx" ON "plan_features"("plan", "sortOrder");

INSERT INTO "plan_features" ("id", "plan", "label", "sortOrder") VALUES
  ('plf_starter_1', 'STARTER', 'Up to 10 vehicles', 10),
  ('plf_starter_2', 'STARTER', '1 user account', 20),
  ('plf_starter_3', 'STARTER', 'Basic analytics', 30),
  ('plf_starter_4', 'STARTER', 'Carplace listing', 40),
  ('plf_growth_1',  'GROWTH',  'Up to 50 vehicles', 10),
  ('plf_growth_2',  'GROWTH',  '5 user accounts', 20),
  ('plf_growth_3',  'GROWTH',  'Full analytics', 30),
  ('plf_growth_4',  'GROWTH',  'Priority Carplace placement', 40),
  ('plf_growth_5',  'GROWTH',  'Custom branding', 50),
  ('plf_pro_1',     'PRO',     'Unlimited vehicles', 10),
  ('plf_pro_2',     'PRO',     'Unlimited user accounts', 20),
  ('plf_pro_3',     'PRO',     'Advanced reports', 30),
  ('plf_pro_4',     'PRO',     'API access', 40),
  ('plf_pro_5',     'PRO',     'Dedicated support', 50);
