-- Table: public.PaymentModule

-- DROP TABLE IF EXISTS public."PaymentModule";
CREATE SEQUENCE IF NOT EXISTS public."PaymentModule_PaymentModuleId_seq";
CREATE TABLE IF NOT EXISTS public."PaymentModule"
(
    "PaymentModuleId" integer NOT NULL DEFAULT nextval('"PaymentModule_PaymentModuleId_seq"'::regclass),
    "Name" character varying(150) COLLATE pg_catalog."default" NOT NULL,
	"Active" boolean NOT NULL DEFAULT true,
    CONSTRAINT "PaymentModule_pkey" PRIMARY KEY ("PaymentModuleId"),
	CONSTRAINT "UQ_PaymentModule_Name" UNIQUE ("Name")
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public."PaymentModule"
    OWNER to postgres;
-- Index: IX_PaymentModule_Name

-- DROP INDEX IF EXISTS public."IX_PaymentModule_Name";

CREATE UNIQUE INDEX IF NOT EXISTS "IX_PaymentModule_Name"
    ON public."PaymentModule" USING btree
    (upper("Name"::text) COLLATE pg_catalog."default" ASC NULLS LAST)
    TABLESPACE pg_default;	
---------------------------------------------------	
INSERT INTO public."PaymentModule"(
	"PaymentModuleId", "Name")
	VALUES (1,'Patient'),(2,'Appointment'),(3,'Pharmacy'),(4,'Labs');
---------------------------------------------------
-- Table: public.PaymentInitiationLog
-- DROP TABLE IF EXISTS public."PaymentInitiationLog";

CREATE SEQUENCE IF NOT EXISTS public."PaymentInitiationLog_PaymentInitiationLogId_seq";
CREATE TABLE IF NOT EXISTS public."PaymentInitiationLog"
(
    "PaymentInitiationLogId" integer NOT NULL DEFAULT nextval('"PaymentInitiationLog_PaymentInitiationLogId_seq"'::regclass),
    "TableData" text NOT NULL,
    "CreatedBy" integer NOT NULL,
    "CreatedDate" timestamp(6) with time zone NOT NULL,
    "PaymentModuleId" integer NOT NULL,
    "Mode" character varying(10) NOT NULL,
    CONSTRAINT "PaymentInitiationLog_pkey" PRIMARY KEY ("PaymentInitiationLogId"),
    CONSTRAINT "FK_PaymentInitiationLog_PaymentModuleId" FOREIGN KEY ("PaymentModuleId")
        REFERENCES public."PaymentModule" ("PaymentModuleId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE CASCADE,
    CONSTRAINT "FK_PaymentInitiationLog_CreatedBy" FOREIGN KEY ("CreatedBy")
        REFERENCES public."Account" ("AccountId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE CASCADE
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public."PaymentInitiationLog"
    OWNER to postgres;
--------------------------------------------------
INSERT INTO public."LogType"(
	"LogTypeId", "LogTypeName", "Active")
	VALUES (67, 'PaymentInitiationLog', true);
--------------------------------------------------