drop table if exists  "LabTemplateHeader" cascade;

create table "LabTemplateHeader"(
			"LabTemplateHeaderId" serial primary key,
			"TemplateName" text,
			"TemplateId" text,
			"Active" boolean default true,
			"CreatedBy" int references "Account"("AccountId"),
			"CreatedDate" timestamp without time zone,
			"ModifiedBy" int references "Account"("AccountId"),
			"ModifiedDate" timestamp without time zone
);

drop table if exists  "LabTemplateDetail" cascade;

create table "LabTemplateDetail"(
			"LabTemplateDetailId" serial primary key,
			"LabTemplateHeaderId" int references "LabTemplateHeader"("LabTemplateHeaderId"),
			"LabComponentHeaderId" int references "LabComponentHeader"("LabComponentHeaderId"),
			"Priority" int
);

drop table if exists  "LabParameterMethod" cascade;

create table "LabParameterMethod"(
			"LabParameterMethodId" serial primary key,
			"MethodName" text
);

alter table "LabParameterHeader" add column "LabParameterMethodId" int references "LabParameterMethod"("LabParameterMethodId");