From 35369e157dbed9ab827e3b13858074cb9ee11d26 Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Sun, 2 Aug 2020 16:29:26 -0700 Subject: [PATCH] Consolidate SQL Server bootstrap scripts to 0.00-18.20.sql --- ....00-17.30.sql => snprc_ehr-0.00-18.20.sql} | 51 +++++++++++++++- .../sqlserver/snprc_ehr-18.10-18.20.sql | 59 ------------------- ....00-17.20.sql => snprc_r24-0.00-18.20.sql} | 28 ++++++++- .../sqlserver/snprc_r24-18.10-18.20.sql | 38 ------------ 4 files changed, 74 insertions(+), 102 deletions(-) rename snprc_ehr/resources/schemas/dbscripts/sqlserver/{snprc_ehr-0.00-17.30.sql => snprc_ehr-0.00-18.20.sql} (93%) delete mode 100644 snprc_ehr/resources/schemas/dbscripts/sqlserver/snprc_ehr-18.10-18.20.sql rename snprc_r24/resources/schemas/dbscripts/sqlserver/{snprc_r24-0.00-17.20.sql => snprc_r24-0.00-18.20.sql} (84%) delete mode 100644 snprc_r24/resources/schemas/dbscripts/sqlserver/snprc_r24-18.10-18.20.sql diff --git a/snprc_ehr/resources/schemas/dbscripts/sqlserver/snprc_ehr-0.00-17.30.sql b/snprc_ehr/resources/schemas/dbscripts/sqlserver/snprc_ehr-0.00-18.20.sql similarity index 93% rename from snprc_ehr/resources/schemas/dbscripts/sqlserver/snprc_ehr-0.00-17.30.sql rename to snprc_ehr/resources/schemas/dbscripts/sqlserver/snprc_ehr-0.00-18.20.sql index e2f0d8d20..83b68e833 100644 --- a/snprc_ehr/resources/schemas/dbscripts/sqlserver/snprc_ehr-0.00-17.30.sql +++ b/snprc_ehr/resources/schemas/dbscripts/sqlserver/snprc_ehr-0.00-18.20.sql @@ -14,8 +14,6 @@ * limitations under the License. */ --- Create schema, tables, indexes, and constraints used for SNPRC_EHR module here --- All SQL VIEW definitions should be created in snprc_ehr-create.sql and dropped in snprc_ehr-drop.sql CREATE SCHEMA snprc_ehr; GO @@ -787,4 +785,51 @@ CREATE TABLE [snprc_ehr].[FeeSchedule]( CONSTRAINT FK_snprc_fee_Schedule_container FOREIGN KEY (Container) REFERENCES core.Containers (EntityId) ); CREATE UNIQUE INDEX idx_snprc_fee_schedule_objectid ON snprc_ehr.feeSchedule (objectid) -CREATE UNIQUE INDEX idx_snprc_fee_schedule_activityId_budgetYear ON snprc_ehr.FeeSchedule (ActivityId, BudgetYear); \ No newline at end of file +CREATE UNIQUE INDEX idx_snprc_fee_schedule_activityId_budgetYear ON snprc_ehr.FeeSchedule (ActivityId, BudgetYear); + +/* snprc_ehr-18.10-18.20.sql */ + +EXEC core.fn_dropifexists 'FeeSchedule','snprc_ehr', 'TABLE'; +EXEC core.fn_dropifexists 'FeeScheduleSpeciesLookup','snprc_ehr', 'TABLE'; +GO + +CREATE TABLE [snprc_ehr].[FeeSchedule]( + [RowId] [bigint] IDENTITY(1,1) NOT NULL, + [StartingYear] INTEGER NOT NULL, + [VersionLabel] NVARCHAR(128) NOT NULL, + [ActivityId] INTEGER NOT NULL, + [Species] NVARCHAR(128) NOT NULL, + [Description] NVARCHAR (256) NOT NULL, + [BudgetYear] NVARCHAR (256) NOT NULL, + [Cost] NUMERIC (9,2) NOT NULL, + [FileName] NVARCHAR (256) NOT NULL, + [ObjectId] UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(), + [Created] [DATETIME] NULL, + [CreatedBy] [dbo].[USERID] NULL, + [Modified] [DATETIME] NULL, + [ModifiedBy] [dbo].[USERID] NULL, + Container entityId NOT NULL + + + CONSTRAINT PK_snprc_fee_schedule PRIMARY KEY ([RowId]) + CONSTRAINT FK_snprc_fee_Schedule_container FOREIGN KEY (Container) REFERENCES core.Containers (EntityId) ); + +CREATE UNIQUE INDEX idx_snprc_fee_schedule_objectid ON snprc_ehr.feeSchedule (objectid) +CREATE UNIQUE INDEX idx_snprc_fee_schedule_activityId_budgetYear ON snprc_ehr.FeeSchedule (StartingYear, VersionLabel, ActivityId, BudgetYear); +GO + +CREATE TABLE [snprc_ehr].[FeeScheduleSpeciesLookup] ( + [FsSpecies] [VARCHAR](128) NOT NULL, + [SpeciesCode] [VARCHAR](2) NOT NULL, + [ObjectId] UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(), + [Created] [DATETIME] NULL, + [CreatedBy] [dbo].[USERID] NULL, + [Modified] [DATETIME] NULL, + [ModifiedBy] [dbo].[USERID] NULL, + [Container] [dbo].[ENTITYID] NOT NULL + + CONSTRAINT [PK_FeeScheduleSpeciesLookup] PRIMARY KEY CLUSTERED ([FsSpecies], [SpeciesCode]) + CONSTRAINT [FK_FeeScheduleSpeciesLookup_container] FOREIGN KEY (Container) REFERENCES core.Containers (EntityId) ); +GO + +ALTER TABLE snprc_ehr.package ADD pkgType NVARCHAR(1) not null default 'U'; \ No newline at end of file diff --git a/snprc_ehr/resources/schemas/dbscripts/sqlserver/snprc_ehr-18.10-18.20.sql b/snprc_ehr/resources/schemas/dbscripts/sqlserver/snprc_ehr-18.10-18.20.sql deleted file mode 100644 index 7fcbc230d..000000000 --- a/snprc_ehr/resources/schemas/dbscripts/sqlserver/snprc_ehr-18.10-18.20.sql +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2018 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. - */ -EXEC core.fn_dropifexists 'FeeSchedule','snprc_ehr', 'TABLE'; -EXEC core.fn_dropifexists 'FeeScheduleSpeciesLookup','snprc_ehr', 'TABLE'; -GO - -CREATE TABLE [snprc_ehr].[FeeSchedule]( - [RowId] [bigint] IDENTITY(1,1) NOT NULL, - [StartingYear] INTEGER NOT NULL, - [VersionLabel] NVARCHAR(128) NOT NULL, - [ActivityId] INTEGER NOT NULL, - [Species] NVARCHAR(128) NOT NULL, - [Description] NVARCHAR (256) NOT NULL, - [BudgetYear] NVARCHAR (256) NOT NULL, - [Cost] NUMERIC (9,2) NOT NULL, - [FileName] NVARCHAR (256) NOT NULL, - [ObjectId] UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(), - [Created] [DATETIME] NULL, - [CreatedBy] [dbo].[USERID] NULL, - [Modified] [DATETIME] NULL, - [ModifiedBy] [dbo].[USERID] NULL, - Container entityId NOT NULL - - - CONSTRAINT PK_snprc_fee_schedule PRIMARY KEY ([RowId]) - CONSTRAINT FK_snprc_fee_Schedule_container FOREIGN KEY (Container) REFERENCES core.Containers (EntityId) ); - -CREATE UNIQUE INDEX idx_snprc_fee_schedule_objectid ON snprc_ehr.feeSchedule (objectid) -CREATE UNIQUE INDEX idx_snprc_fee_schedule_activityId_budgetYear ON snprc_ehr.FeeSchedule (StartingYear, VersionLabel, ActivityId, BudgetYear); -GO - -CREATE TABLE [snprc_ehr].[FeeScheduleSpeciesLookup] ( - [FsSpecies] [VARCHAR](128) NOT NULL, - [SpeciesCode] [VARCHAR](2) NOT NULL, - [ObjectId] UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(), - [Created] [DATETIME] NULL, - [CreatedBy] [dbo].[USERID] NULL, - [Modified] [DATETIME] NULL, - [ModifiedBy] [dbo].[USERID] NULL, - [Container] [dbo].[ENTITYID] NOT NULL - - CONSTRAINT [PK_FeeScheduleSpeciesLookup] PRIMARY KEY CLUSTERED ([FsSpecies], [SpeciesCode]) - CONSTRAINT [FK_FeeScheduleSpeciesLookup_container] FOREIGN KEY (Container) REFERENCES core.Containers (EntityId) ); -GO - -ALTER TABLE snprc_ehr.package ADD pkgType NVARCHAR(1) not null default 'U'; \ No newline at end of file diff --git a/snprc_r24/resources/schemas/dbscripts/sqlserver/snprc_r24-0.00-17.20.sql b/snprc_r24/resources/schemas/dbscripts/sqlserver/snprc_r24-0.00-18.20.sql similarity index 84% rename from snprc_r24/resources/schemas/dbscripts/sqlserver/snprc_r24-0.00-17.20.sql rename to snprc_r24/resources/schemas/dbscripts/sqlserver/snprc_r24-0.00-18.20.sql index ff9030c33..8193a8f60 100644 --- a/snprc_r24/resources/schemas/dbscripts/sqlserver/snprc_r24-0.00-17.20.sql +++ b/snprc_r24/resources/schemas/dbscripts/sqlserver/snprc_r24-0.00-18.20.sql @@ -14,8 +14,6 @@ * limitations under the License. */ --- Create schema, tables, indexes, and constraints used for snprc_r24 module here --- All SQL VIEW definitions should be created in snprc_r24-create.sql and dropped in snprc_r24-drop.sql CREATE SCHEMA snprc_r24; GO @@ -124,4 +122,30 @@ CREATE UNIQUE NONCLUSTERED INDEX [idx_snprc_r24_lookups_setname] ON [snprc_r24]. GO ALTER TABLE [snprc_r24].[Lookups] ADD DEFAULT (NEWID()) FOR [ObjectId] +GO + +/* snprc_r24-18.10-18.20.sql */ + +ALTER TABLE snprc_r24.SampleInventory ADD SampleWeight NUMERIC(7,2) NULL; +ALTER TABLE snprc_r24.SampleInventory ADD SampleAmount NUMERIC(7,2) NULL; + +CREATE TABLE [snprc_r24].[RowsToDelete]( +[ObjectId] [dbo].[EntityId] NOT NULL, +[Modified] [DATETIME] NOT NULL +CONSTRAINT [pk_snprc_r24_RowsToDelete] PRIMARY KEY ( [ObjectId] ASC) ); + +GO + +CREATE TABLE [snprc_r24].[WeightStaging] ( +[AnimalId] [NVARCHAR](32) NOT NULL, +[Date] [DATETIME] NOT NULL, +[Weight] [NUMERIC](7,4) NOT NULL, +[ObjectId] [dbo].EntityId NOT NULL, +[Created] [DATETIME] NULL, +[CreatedBy] [dbo].[USERID] NULL, +[Modified] [DATETIME] NULL, +[ModifiedBy] [dbo].[USERID] NULL + +CONSTRAINT [pk_snprc_r24_weight_staging] PRIMARY KEY ( [ObjectId] ASC) ); + GO \ No newline at end of file diff --git a/snprc_r24/resources/schemas/dbscripts/sqlserver/snprc_r24-18.10-18.20.sql b/snprc_r24/resources/schemas/dbscripts/sqlserver/snprc_r24-18.10-18.20.sql deleted file mode 100644 index 47f853299..000000000 --- a/snprc_r24/resources/schemas/dbscripts/sqlserver/snprc_r24-18.10-18.20.sql +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - */ -ALTER TABLE snprc_r24.SampleInventory ADD SampleWeight NUMERIC(7,2) NULL; -ALTER TABLE snprc_r24.SampleInventory ADD SampleAmount NUMERIC(7,2) NULL; - -CREATE TABLE [snprc_r24].[RowsToDelete]( -[ObjectId] [dbo].[EntityId] NOT NULL, -[Modified] [DATETIME] NOT NULL -CONSTRAINT [pk_snprc_r24_RowsToDelete] PRIMARY KEY ( [ObjectId] ASC) ); - -GO - -CREATE TABLE [snprc_r24].[WeightStaging] ( -[AnimalId] [NVARCHAR](32) NOT NULL, -[Date] [DATETIME] NOT NULL, -[Weight] [NUMERIC](7,4) NOT NULL, -[ObjectId] [dbo].EntityId NOT NULL, -[Created] [DATETIME] NULL, -[CreatedBy] [dbo].[USERID] NULL, -[Modified] [DATETIME] NULL, -[ModifiedBy] [dbo].[USERID] NULL - -CONSTRAINT [pk_snprc_r24_weight_staging] PRIMARY KEY ( [ObjectId] ASC) ); - -GO \ No newline at end of file