-- Adminer 5.3.0 PostgreSQL 17.5 dump

DROP TABLE IF EXISTS "Code";
DROP SEQUENCE IF EXISTS "Code_CODE_ID_seq";
CREATE SEQUENCE "Code_CODE_ID_seq" INCREMENT 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1;

CREATE TABLE "public"."Code" (
    "CODE_ID" integer DEFAULT nextval('"Code_CODE_ID_seq"') NOT NULL,
    "CODE" character varying(60) NOT NULL,
    "Time" timestamp NOT NULL,
    CONSTRAINT "Code_pkey" PRIMARY KEY ("CODE_ID")
)
WITH (oids = false);


DROP TABLE IF EXISTS "Company";
DROP SEQUENCE IF EXISTS "Company_C_ID_seq";
CREATE SEQUENCE "Company_C_ID_seq" INCREMENT 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1;

CREATE TABLE "public"."Company" (
    "C_ID" integer DEFAULT nextval('"Company_C_ID_seq"') NOT NULL,
    "Name" character varying(30) NOT NULL,
    "ContactName" character varying(30) NOT NULL,
    "ContactEmail" character varying(30) NOT NULL,
    "FirstAPI" text NOT NULL,
    "TokenAPI" text NOT NULL,
    CONSTRAINT "Company_pkey" PRIMARY KEY ("C_ID")
)
WITH (oids = false);


DROP TABLE IF EXISTS "User";
DROP SEQUENCE IF EXISTS "User_id_seq";
CREATE SEQUENCE "User_id_seq" INCREMENT 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1;

CREATE TABLE "public"."User" (
    "id" integer DEFAULT nextval('"User_id_seq"') NOT NULL,
    "UName" character varying(30) NOT NULL,
    "PSWD" character varying(30) NOT NULL,
    "RegDate" timestamp NOT NULL,
    "Email" character varying(40) NOT NULL,
    "Name" character varying(30) NOT NULL,
    "AUTH" boolean DEFAULT false NOT NULL,
    "REG_CODE" integer NOT NULL,
    "C_Id" integer NOT NULL,
    "C_Token" character varying(60) NOT NULL,
    CONSTRAINT "User_pkey" PRIMARY KEY ("id")
)
WITH (oids = false);


ALTER TABLE ONLY "public"."User" ADD CONSTRAINT "User_C_Id_fkey" FOREIGN KEY ("C_Id") REFERENCES "Company"("C_ID") ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE;
ALTER TABLE ONLY "public"."User" ADD CONSTRAINT "User_REG_CODE_fkey" FOREIGN KEY ("REG_CODE") REFERENCES "Code"("CODE_ID") ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE;

-- 2025-05-20 22:16:50 UTC
