text: /*
   * Copyright (c) 2018-2019 LabKey Corporation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  CREATE TABLE wnprc_r24.SampleInventory(
                                            RowId SERIAL NOT NULL,
                                            AnimalId VARCHAR(32) NOT NULL,
                                            Date TIMESTAMP NOT NULL,
                                            SampleId VARCHAR(32) NOT NULL,
                                            Aim VARCHAR(128) NULL,
                                            SampleType VARCHAR(128) NOT NULL,
                                            ObjectId VARCHAR(128) NULL,
                                            Created TIMESTAMP NULL,
                                            CreatedBy USERID NULL,
                                            Modified TIMESTAMP NULL,
                                            ModifiedBy USERID NULL,
                                            DiCreated TIMESTAMP NULL,
                                            DiModified TIMESTAMP NULL,
                                            DiCreatedBy USERID NULL,
                                            DiModifiedBy USERID NULL,
                                            Container	entityId NOT NULL,
  
                                            CONSTRAINT pk_wnprc_r24_sampleinventory PRIMARY KEY (SampleId),
                                            CONSTRAINT fk_wnprc_r24_sampleinventory_container FOREIGN KEY (Container) REFERENCES core.Containers (EntityId)
  );
  
  
  ALTER TABLE wnprc_r24.SampleInventory ALTER ObjectId SET  DEFAULT (ehr.uuid());
  
  
  CREATE TABLE wnprc_r24.lookupSets(
                                       RowId SERIAL NOT NULL,
                                       SetName VARCHAR(32) NOT NULL,
                                       Label VARCHAR(32) NOT NULL,
                                       ObjectId VARCHAR(128) NULL,
                                       Created TIMESTAMP NULL,
                                       CreatedBy USERID NULL,
                                       Modified TIMESTAMP NULL,
                                       ModifiedBy USERID NULL,
                                       DiCreated TIMESTAMP NULL,
                                       DiModified TIMESTAMP NULL,
                                       DiCreatedBy USERID NULL,
                                       DiModifiedBy USERID NULL,
                                       Container	entityId NOT NULL,
  
                                       CONSTRAINT pk_wnprc_r24_lookupsets PRIMARY KEY ( RowId ),
                                       CONSTRAINT fk_wnprc_r24_lookupsets_container FOREIGN KEY (Container) REFERENCES core.Containers (EntityId)
                                   );
  
  
  CREATE UNIQUE INDEX idx_wnprc_r24_lookupSets_setname ON wnprc_r24.lookupSets ( SetName );
  
  
  ALTER TABLE wnprc_r24.LookupSets ALTER ObjectId SET DEFAULT (ehr.uuid());
  
  
  CREATE TABLE wnprc_r24.lookups(
                                    RowId SERIAL NOT NULL,
                                    SetName VARCHAR(32) NOT NULL,
                                    Value VARCHAR(128) NOT NULL,
                                    SortOrder INTEGER NULL,
                                    DateDisabled TIMESTAMP NULL,
                                    ObjectId VARCHAR(128) NULL,
                                    Created TIMESTAMP NULL,
                                    CreatedBy USERID NULL,
                                    Modified TIMESTAMP NULL,
                                    ModifiedBy USERID NULL,
                                    DiCreated TIMESTAMP NULL,
                                    DiModified TIMESTAMP NULL,
                                    DiCreatedBy USERID NULL,
                                    DiModifiedBy USERID NULL,
                                    Container	entityId NOT NULL,
  
                                    CONSTRAINT pk_wnprc_r24_lookups PRIMARY KEY ( RowId ),
                                    CONSTRAINT fk_wnprc_r24_lookups_SetName FOREIGN KEY (SetName) REFERENCES wnprc_r24.LookupSets (SetName),
                                    CONSTRAINT fk_wnprc_r24_lookups_container FOREIGN KEY (Container) REFERENCES core.Containers (EntityId)
  );
  
  
  CREATE UNIQUE INDEX idx_wnprc_r24_lookups_setname ON wnprc_r24.lookups ( SetName , VALUE );
  
  
  ALTER TABLE wnprc_r24.Lookups ALTER ObjectId SET DEFAULT (ehr.uuid());
  