Skip to content

Commit 9323d04

Browse files
committed
Option to migrate SQL Server hard tables to PostgreSQL
1 parent 3148b39 commit 9323d04

3 files changed

Lines changed: 28 additions & 10 deletions

File tree

resources/schemas/dbscripts/postgresql/targetedms-0.000-24.000.sql

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ CREATE TABLE targetedms.QCMetricConfiguration
14551455
CONSTRAINT UQ_QCMetricConfig_Name_Container UNIQUE (Name, Container)
14561456
);
14571457

1458-
1458+
@SkipOnEmptySchemasBegin
14591459
WITH rootIdentity as (select EntityId as theIdentity FROM core.Containers WHERE Parent is null)
14601460
INSERT INTO targetedms.QCMetricConfiguration (Container, Name,Series1Label,Series1SchemaName,Series1QueryName,Series2Label,Series2SchemaName,Series2QueryName) VALUES
14611461
((select theIdentity from rootIdentity), 'Retention Time','Retention Time','targetedms','QCMetric_retentionTime',NULL , NULL , NULL ),
@@ -1466,6 +1466,7 @@ INSERT INTO targetedms.QCMetricConfiguration (Container, Name,Series1Label,Serie
14661466
((select theIdentity from rootIdentity), 'Transition/Precursor Area Ratio','Transition/Precursor Area Ratio','targetedms','QCMetric_transitionPrecursorRatio',NULL , NULL , NULL ),
14671467
((select theIdentity from rootIdentity), 'Transition/Precursor Areas','Transition Area','targetedms','QCMetric_transitionArea','Precursor Area','targetedms','QCMetric_precursorArea'),
14681468
((select theIdentity from rootIdentity), 'Mass Accuracy','Mass Accuracy','targetedms','QCMetric_massAccuracy',NULL , NULL , NULL );
1469+
@SkipOnEmptySchemasEnd
14691470

14701471
-- Add column to ReplicateAnnotation to store the source of the annotation (e.g. Skyline or AutoQC)
14711472
ALTER TABLE targetedms.ReplicateAnnotation ADD COLUMN Source VARCHAR(20) NOT NULL DEFAULT 'Skyline';
@@ -1800,9 +1801,11 @@ ALTER TABLE targetedms.MeasuredDriftTime ADD IonMobilityUnits VARCHAR(30);
18001801

18011802
ALTER TABLE targetedms.Runs ADD COLUMN AuditLogEntriesCount INT4 DEFAULT 0 NOT NULL;
18021803

1804+
@SkipOnEmptySchemasBegin
18031805
WITH rootIdentity as (select EntityId as theIdentity FROM core.Containers WHERE Parent is null)
18041806
INSERT INTO targetedms.QCMetricConfiguration (Container, Name,Series1Label,Series1SchemaName,Series1QueryName,Series2Label,Series2SchemaName,Series2QueryName,PrecursorScoped) VALUES
18051807
((select theIdentity from rootIdentity), 'TIC Area','TIC Area','targetedms','QCRunMetric_ticArea',NULL , NULL , NULL , FALSE );
1808+
@SkipOnEmptySchemasEnd
18061809

18071810
ALTER TABLE targetedms.SampleFile ADD COLUMN TicArea DOUBLE PRECISION;
18081811

@@ -1860,6 +1863,7 @@ CREATE TABLE targetedms.ListItemValue
18601863
ALTER TABLE targetedms.QCMetricConfiguration ADD COLUMN EnabledQueryName VARCHAR(200);
18611864
ALTER TABLE targetedms.QCMetricConfiguration ADD COLUMN EnabledSchemaName VARCHAR(200);
18621865

1866+
@SkipOnEmptySchemasBegin
18631867
WITH rootIdentity as (select EntityId as theIdentity FROM core.Containers WHERE Parent is null)
18641868
INSERT INTO targetedms.QCMetricConfiguration (Container, Name,Series1Label,Series1SchemaName,Series1QueryName,Series2Label,Series2SchemaName,Series2QueryName,PrecursorScoped, EnabledQueryName, EnabledSchemaName) VALUES
18651869
((select theIdentity from rootIdentity), 'Isotopologue LOD', 'LOD','targetedms', 'QCMetric_IsotopologuePrecursorLOD', NULL, NULL, NULL, TRUE, 'QCMetricEnabled_IsotopologuePrecursorLOD', 'targetedms');
@@ -1877,6 +1881,7 @@ INSERT INTO targetedms.QCMetricConfiguration (Container, Name,Series1Label,Serie
18771881
((select theIdentity from rootIdentity), 'Isotopologue Regression RSquared', 'Coefficient', 'targetedms', 'QCMetric_IsotopologuePrecursorRSquared', NULL, NULL, NULL, TRUE, 'QCMetricEnabled_IsotopologuePrecursorRSquared', 'targetedms');
18781882

18791883
UPDATE targetedms.QCMetricConfiguration SET EnabledQueryName = 'QCMetricEnabled_lhRatio', EnabledSchemaName ='targetedms' WHERE Series1QueryName = 'QCMetric_lhRatio';
1884+
@SkipOnEmptySchemasEnd
18801885

18811886
ALTER TABLE targetedms.runs ALTER COLUMN SoftwareVersion TYPE VARCHAR(200);
18821887

@@ -2229,6 +2234,7 @@ CREATE TABLE targetedms.keywords (
22292234
CONSTRAINT keywords_keywordid_key UNIQUE (keywordid)
22302235
);
22312236

2237+
@SkipOnEmptySchemasBegin
22322238
INSERT INTO targetedms.keywordcategories VALUES (1, 'KW-9999', 'Biological process');
22332239
INSERT INTO targetedms.keywordcategories VALUES (2, 'KW-9998', 'Cellular component');
22342240
INSERT INTO targetedms.keywordcategories VALUES (3, 'KW-9997', 'Coding sequence diversity');
@@ -3423,6 +3429,7 @@ INSERT INTO targetedms.keywords VALUES ( DEFAULT, 'KW-1268', 'Autism spectrum di
34233429
INSERT INTO targetedms.keywords VALUES ( DEFAULT, 'KW-1269', 'Autism', 'KW-9995');
34243430
INSERT INTO targetedms.keywords VALUES ( DEFAULT, 'KW-1270', 'Asperger syndrome', 'KW-9995');
34253431
INSERT INTO targetedms.keywords VALUES ( DEFAULT, 'KW-1271', 'Inflammasome', 'KW-9998');
3432+
@SkipOnEmptySchemasEnd
34263433

34273434
ALTER TABLE targetedms.Runs ALTER COLUMN Id TYPE bigint;
34283435

@@ -3924,6 +3931,7 @@ ALTER TABLE targetedms.SampleFile ADD IRTSlope REAL;
39243931
ALTER TABLE targetedms.SampleFile ADD IRTIntercept REAL;
39253932
ALTER TABLE targetedms.SampleFile ADD IRTCorrelation REAL;
39263933

3934+
@SkipOnEmptySchemasBegin
39273935
WITH rootIdentity as (select EntityId as theIdentity FROM core.Containers WHERE Parent is null)
39283936
INSERT INTO targetedms.QCMetricConfiguration (Container, Name, Series1Label, Series1SchemaName, Series1QueryName, PrecursorScoped, EnabledQueryName, EnabledSchemaName) VALUES
39293937
((select theIdentity from rootIdentity), 'iRT Slope', 'iRT Slope', 'targetedms', 'QCRunMetric_iRTSlope', false, 'QCRunMetricEnabled_iRTSlope', 'targetedms');
@@ -3943,7 +3951,6 @@ WITH rootIdentity as (select EntityId as theIdentity FROM core.Containers WHERE
39433951
INSERT INTO targetedms.QCMetricConfiguration (Container, Name, Series1Label, Series1SchemaName, Series1QueryName, PrecursorScoped) VALUES
39443952
((select theIdentity from rootIdentity), 'Precursor Area', 'Precursor Area', 'targetedms', 'QCMetric_precursorArea', true);
39453953

3946-
39473954
WITH rootIdentity as (select EntityId as theIdentity FROM core.Containers WHERE Parent is null)
39483955
INSERT INTO targetedms.QCMetricConfiguration (Container, Name, Series1Label, Series1SchemaName, Series1QueryName, PrecursorScoped, EnabledQueryName, EnabledSchemaName) VALUES
39493956
((select theIdentity from rootIdentity), 'Transition Area', 'Transition Area', 'targetedms', 'QCMetric_transitionArea', true, 'QCMetricEnabled_transitionArea', 'targetedms');
@@ -3970,6 +3977,7 @@ SET
39703977
EnabledQueryName = 'QCMetricEnabled_transitionArea',
39713978
EnabledSchemaName = 'targetedms'
39723979
WHERE Name = 'Transition & Precursor Areas';
3980+
@SkipOnEmptySchemasEnd
39733981

39743982
ALTER TABLE targetedms.PrecursorChromInfo
39753983
ADD COLUMN TotalAreaMs1 REAL,
@@ -4025,13 +4033,15 @@ SELECT core.fn_dropifexists('AuditLogEntry', 'targetedms', 'CONSTRAINT', 'fk_aud
40254033
ALTER TABLE targetedms.AuditLogEntry
40264034
DROP COLUMN VersionId;
40274035

4036+
@SkipOnEmptySchemasBegin
40284037
WITH rootIdentity as (select EntityId as theIdentity FROM core.Containers WHERE Parent is null)
40294038
INSERT INTO targetedms.QCMetricConfiguration (Container, Name, Series1Label, Series1SchemaName, Series1QueryName, PrecursorScoped, EnabledQueryName, EnabledSchemaName) VALUES
40304039
((select theIdentity from rootIdentity), 'Library dotp', 'Library dotp', 'targetedms', 'QCMetric_libraryDotp', true, 'QCMetricEnabled_libraryDotp', 'targetedms');
40314040

40324041
WITH rootIdentity as (select EntityId as theIdentity FROM core.Containers WHERE Parent is null)
40334042
INSERT INTO targetedms.QCMetricConfiguration (Container, Name, Series1Label, Series1SchemaName, Series1QueryName, PrecursorScoped, EnabledQueryName, EnabledSchemaName) VALUES
40344043
((select theIdentity from rootIdentity), 'Isotope dotp', 'Isotope dotp', 'targetedms', 'QCMetric_isotopeDotp', true, 'QCMetricEnabled_isotopeDotp', 'targetedms');
4044+
@SkipOnEmptySchemasEnd
40354045

40364046
-- Reparent table if it exists in PanoramaPremium schema
40374047
ALTER TABLE IF EXISTS PanoramaPremium.QCEmailNotifications SET SCHEMA targetedms;

resources/schemas/dbscripts/postgresql/targetedms-24.000-24.001.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ UPDATE targetedms.QCMetricConfiguration SET
66
YAxisLabel1 = 'Mass Error PPM'
77
WHERE Name = 'Mass Accuracy';
88

9+
@SkipOnEmptySchemasBegin
910
WITH rootIdentity AS (SELECT EntityId AS theIdentity FROM core.Containers WHERE Parent IS NULL)
1011
INSERT INTO targetedms.QCMetricConfiguration (Container, Name, Series1Label, Series1SchemaName, Series1QueryName, EnabledSchemaName, EnabledQueryName, YAxisLabel1) VALUES
1112
((SELECT theIdentity FROM rootIdentity), 'Transition Mass Error','Transition Mass Error','targetedms','QCMetric_massErrorTransition', 'targetedms', 'QCMetricEnabled_massErrorTransition', 'Mass Error PPM')
13+
@SkipOnEmptySchemasEnd
1214
;

src/org/labkey/targetedms/TargetedMSUpgradeCode.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,27 @@ public class TargetedMSUpgradeCode implements UpgradeCode
5454
@SuppressWarnings({"UnusedDeclaration"})
5555
public void populateDefaultAnnotationTypes(final ModuleContext moduleContext)
5656
{
57-
insertAnnotationType("Instrumentation Change", "FF0000", moduleContext.getUpgradeUser());
58-
insertAnnotationType("Reagent Change", "00FF00", moduleContext.getUpgradeUser());
59-
insertAnnotationType("Technician Change", "0000FF", moduleContext.getUpgradeUser());
57+
if (ModuleLoader.getInstance().shouldInsertData())
58+
{
59+
insertAnnotationType("Instrumentation Change", "FF0000", moduleContext.getUpgradeUser());
60+
insertAnnotationType("Reagent Change", "00FF00", moduleContext.getUpgradeUser());
61+
insertAnnotationType("Technician Change", "0000FF", moduleContext.getUpgradeUser());
6062

61-
// Enable the module in the /Shared container so that it can be resolved
62-
Set<Module> activeModules = new HashSet<>(ContainerManager.getSharedContainer().getActiveModules());
63-
activeModules.add(ModuleLoader.getInstance().getModule(TargetedMSModule.class));
64-
ContainerManager.getSharedContainer().setActiveModules(activeModules);
63+
// Enable the module in the /Shared container so that it can be resolved
64+
Set<Module> activeModules = new HashSet<>(ContainerManager.getSharedContainer().getActiveModules());
65+
activeModules.add(ModuleLoader.getInstance().getModule(TargetedMSModule.class));
66+
ContainerManager.getSharedContainer().setActiveModules(activeModules);
67+
}
6568
}
6669

6770
// initialization code called at 0.000-24.000 to add a new type. Can eventually be consolidated into the bootstrap insert above
6871
@SuppressWarnings({"UnusedDeclaration"})
6972
public void addInstrumentDowntimeAnnotationType(final ModuleContext moduleContext)
7073
{
71-
insertAnnotationType(QCAnnotationTypeTable.INSTRUMENT_DOWNTIME, "CCCC00", moduleContext.getUpgradeUser());
74+
if (ModuleLoader.getInstance().shouldInsertData())
75+
{
76+
insertAnnotationType(QCAnnotationTypeTable.INSTRUMENT_DOWNTIME, "CCCC00", moduleContext.getUpgradeUser());
77+
}
7278
}
7379

7480
private void insertAnnotationType(String name, String color, User user)

0 commit comments

Comments
 (0)