CREATE TABLE IF NOT EXISTS public.icons (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  number integer,
  title text NOT NULL,
  image_path text NOT NULL,
  thumb_path text NOT NULL,
  carrier text,
  dimensions text,
  reinf text,
  ground text,
  ground_for_gold text,
  gild text,
  painted_with text,
  protection text,
  price_lines jsonb NOT NULL DEFAULT '[]'::jsonb,
  created_at timestamptz NOT NULL DEFAULT now(),
  updated_at timestamptz NOT NULL DEFAULT now()
);

CREATE UNIQUE INDEX IF NOT EXISTS icons_number_uniq ON public.icons (number);

CREATE TABLE IF NOT EXISTS public.removed_icons (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  original_id uuid,
  number integer,
  title text NOT NULL,
  image_path text NOT NULL,
  thumb_path text NOT NULL,
  carrier text,
  dimensions text,
  reinf text,
  ground text,
  ground_for_gold text,
  gild text,
  painted_with text,
  protection text,
  price_lines jsonb NOT NULL DEFAULT '[]'::jsonb,
  created_at timestamptz,
  updated_at timestamptz,
  removed_at timestamptz NOT NULL DEFAULT now()
);

CREATE INDEX IF NOT EXISTS removed_icons_removed_at_idx ON public.removed_icons (removed_at DESC);
