CREATE TYPE "public"."system_role" AS ENUM('standard', 'super_admin');--> statement-breakpoint
ALTER TABLE "users" ADD COLUMN "phone" text;--> statement-breakpoint
ALTER TABLE "users" ADD COLUMN "system_role" "system_role" DEFAULT 'standard' NOT NULL;--> statement-breakpoint
ALTER TABLE "users" ADD COLUMN "is_active" boolean DEFAULT true NOT NULL;--> statement-breakpoint
UPDATE "users"
SET "system_role" = 'super_admin'
WHERE "id" = (
  SELECT "id"
  FROM "users"
  ORDER BY "created_at" ASC
  LIMIT 1
)
AND NOT EXISTS (
  SELECT 1
  FROM "users"
  WHERE "system_role" = 'super_admin'
);
