

CREATE TABLE IF NOT EXISTS public."Ambulance"
(
    "AmbulanceId" serial,
    "AmbulanceNo" character varying(50) COLLATE pg_catalog."default" NOT NULL,
    "AssignedNo" character varying(50) COLLATE pg_catalog."default" NOT NULL,
    "Active" boolean NOT NULL DEFAULT true,
    "CreatedDate" timestamp(6) without time zone NOT NULL,
    "CreatedBy" integer NOT NULL,
    "ModifiedBy" integer,
    "ModifiedDate" timestamp(6) without time zone,
    "LocationId" integer,
    CONSTRAINT "Ambulance_pkey" PRIMARY KEY ("AmbulanceId"),
    CONSTRAINT "UQ_Ambulance_AmbulanceNo" UNIQUE ("AmbulanceNo"),
    CONSTRAINT "UQ_Ambulance_AssignedNo" UNIQUE ("AssignedNo"),
    CONSTRAINT "Ambulance_LocationId_fkey" FOREIGN KEY ("LocationId")
        REFERENCES public."Location" ("LocationId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public."Ambulance"
    OWNER to postgres;
------------------------------------------------------------------------------------------------------

-- Table: public.DriverDetail

-- DROP TABLE IF EXISTS public."DriverDetail";

CREATE TABLE IF NOT EXISTS public."DriverDetail"
(
    "DriverDetailId" serial,
    "DriverDetailName" character varying(255) COLLATE pg_catalog."default",
    "MobileNo" character varying(10) COLLATE pg_catalog."default",
    "AadharNo" character varying(12) COLLATE pg_catalog."default",
    "Address" character varying(255) COLLATE pg_catalog."default",
    "Active" boolean,
    "CreatedBy" integer,
    "CreatedDate" timestamp without time zone,
    "ModifiedBy" integer,
    "ModifiedDate" timestamp without time zone,
    "FromTime" character varying(10) COLLATE pg_catalog."default",
    "ToTime" character varying(10) COLLATE pg_catalog."default",
    CONSTRAINT "DriverDetail_pkey" PRIMARY KEY ("DriverDetailId"),
    CONSTRAINT "DriverDetail_CreatedBy_fkey" FOREIGN KEY ("CreatedBy")
        REFERENCES public."Account" ("AccountId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "DriverDetail_ModifiedBy_fkey" FOREIGN KEY ("ModifiedBy")
        REFERENCES public."Account" ("AccountId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public."DriverDetail"
    OWNER to postgres;
--------------------------------------------------------------------------------------------------------

-- Table: public.AmbulanceReciept

-- DROP TABLE IF EXISTS public."AmbulanceReciept";

CREATE TABLE IF NOT EXISTS public."AmbulanceReciept"
(
    "AmbulanceRecieptId" integer NOT NULL DEFAULT nextval('"AmbulanceReciept_AmbulanceRecieptId_seq"'::regclass),
    "RecieptNo" text COLLATE pg_catalog."default",
    "FromLocation" character varying(50) COLLATE pg_catalog."default",
    "Address" character varying(255) COLLATE pg_catalog."default",
    "ToLocation" character varying(50) COLLATE pg_catalog."default",
    "PatientName" character varying(50) COLLATE pg_catalog."default",
    "PatientMobile" character varying(10) COLLATE pg_catalog."default",
    "CreatedBy" integer,
    "CreatedDate" timestamp without time zone,
    "DriverDetailId" integer,
    "AmbulanceId" integer,
    "Amount" numeric(8,2),
    "ModifiedBy" integer,
    "ModifiedDate" timestamp without time zone,
    CONSTRAINT "AmbulanceReciept_pkey" PRIMARY KEY ("AmbulanceRecieptId"),
    CONSTRAINT "AmbulanceReciept_CreatedBy_fkey" FOREIGN KEY ("CreatedBy")
        REFERENCES public."Account" ("AccountId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "AmbulanceReciept_ModifiedBy_fkey" FOREIGN KEY ("ModifiedBy")
        REFERENCES public."Account" ("AccountId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public."AmbulanceReciept"
    OWNER to postgres;  
    
 alter table "AmbulanceReciept" add column "LocationId" integer references "Location"("LocationId");

---------------------------------------------------------------------------------------------------------------
    
    
    