Permalink
Browse files

Added sql openPDC specific sql scripts.

  • Loading branch information...
wbernest committed Jan 12, 2018
1 parent 783dde5 commit 9eca15283d370b5a006d7979b7e5312cba2dcccb
@@ -98,6 +98,16 @@ MOVE /Y "%sourceschema%\Oracle\*.*" "%targetschema%\Oracle\"
MOVE /Y "%sourceschema%\PostgreSQL\*.*" "%targetschema%\PostgreSQL\"
MOVE /Y "%sourceschema%\SQL Server\*.*" "%targetschema%\SQL Server\"
MOVE /Y "%sourceschema%\SQLite\*.*" "%targetschema%\SQLite\"
ECHO. >> "%targetschema%\MySQL\openPDC.sql"
ECHO. >> "%targetschema%\Oracle\openPDC.sql"
ECHO. >> "%targetschema%\PostgreSQL\openPDC.sql"
ECHO. >> "%targetschema%\SQL Server\openPDC.sql"
ECHO. >> "%targetschema%\SQLite\openPDC.sql"
TYPE "%targetschema%\MySQL\_openPDC.sql" >> "%targetschema%\MySQL\openPDC.sql"
TYPE "%targetschema%\Oracle\_openPDC.sql" >> "%targetschema%\Oracle\openPDC.sql"
TYPE "%targetschema%\PostgreSQL\_openPDC.sql" >> "%targetschema%\PostgreSQL\openPDC.sql"
TYPE "%targetschema%\SQL Server\_openPDC.sql" >> "%targetschema%\SQL Server\openPDC.sql"
TYPE "%targetschema%\SQLite\_openPDC.sql" >> "%targetschema%\SQLite\openPDC.sql"
"%replace%" /r /v "%targetschema%\*.sql" GSFSchema openPDC
"%replace%" /r /v "%targetschema%\*.sql" "--*" ""
"%replace%" /r /v "%targetschema%\*SampleDataSet.sql" TestingAdapters HistorianAdapters
@@ -0,0 +1,39 @@
-- *******************************************************************************************
-- IMPORTANT NOTE: When making updates to this schema, please increment the version number!
-- *******************************************************************************************
CREATE VIEW LocalSchemaVersion AS
SELECT 1 AS VersionNumber;
CREATE TABLE DataAvailability(
ID int AUTO_INCREMENT NOT NULL,
GoodAvailableData float NOT NULL,
BadAvailableData float NOT NULL,
TotalAvailableData float NOT NULL,
PRIMARY KEY(ID)
);
CREATE TABLE AlarmDevice(
ID int AUTO_INCREMENT NOT NULL,
DeviceID int NULL,
StateID int NULL,
TimeStamp datetime NULL,
DisplayData varchar(10) NULL,
PRIMARY KEY(ID),
FOREIGN KEY (DeviceID) REFERENCES Device(ID),
FOREIGN KEY (StateID) REFERENCES AlarmState(ID)
);
CREATE TABLE AlarmState(
ID int AUTO_INCREMENT NOT NULL,
State varchar(50) NULL,
Color varchar(50) NULL,
PRIMARY KEY(ID)
);
INSERT INTO AlarmState (State, Color) VALUES ('Good', 'green');
INSERT INTO AlarmState (State, Color) VALUES ('Alarm', 'red');
INSERT INTO AlarmState (State, Color) VALUES ('Not Available', 'orange')
INSERT INTO AlarmState (State, Color) VALUES ('Bad Data', 'blue');
INSERT INTO AlarmState (State, Color) VALUES ('Bad Time', 'purple');
INSERT INTO AlarmState (State, Color) VALUES ('Out of Service', 'grey');
@@ -0,0 +1,60 @@
-- *******************************************************************************************
-- IMPORTANT NOTE: When making updates to this schema, please increment the version number!
-- *******************************************************************************************
CREATE VIEW LocalSchemaVersion AS
SELECT 1 AS VersionNumber
FROM dual;
CREATE TABLE DataAvailability(
ID NUMBER NOT NULL,
GoodAvailableData NUMBER NOT NULL,
BadAvailableData NUMBER NOT NULL,
TotalAvailableData NUMBER NOT NULL,
);
ALTER TABLE DataAvailability ADD CONSTRAINT PK_DataAvailability PRIMARY KEY (ID);
CREATE SEQUENCE SEQ_DataAvailability START WITH 1 INCREMENT BY 1;
CREATE TRIGGER AI_DataAvailability BEFORE INSERT ON DataAvailability
FOR EACH ROW BEGIN SELECT SEQ_DataAvailability.nextval INTO :NEW.ID FROM dual;
END;
CREATE TABLE AlarmDevice(
ID NUMBER IDENTITY(1,1) NOT NULL PRIMARY KEY,
DeviceID NUMBER NULL,
StateID NUMBER NULL,
TimeStamp datetime NULL,
DisplayData varchar(10) NULL
);
ALTER TABLE AlarmDevice ADD CONSTRAINT PK_AlarmDevice PRIMARY KEY (ID);
ALTER TABLE AlarmDevice ADD CONSTRAINT FK_AlarmDevice_Device FOREIGN KEY(DeviceID) REFERENCES Device(ID) ON DELETE CASCADE;
ALTER TABLE AlarmDevice ADD CONSTRAINT FK_AlarmDevice_State FOREIGN KEY(StateID) REFERENCES AlarmState(ID) ON DELETE CASCADE;
CREATE SEQUENCE SEQ_AlarmDevice START WITH 1 INCREMENT BY 1;
CREATE TRIGGER AI_AlarmDevice BEFORE INSERT ON AlarmDevice
FOR EACH ROW BEGIN SELECT SEQ_AlarmDevice.nextval INTO :NEW.ID FROM dual;
END;
CREATE TABLE AlarmState(
ID NUMBER NOT NULL,
State varchar(50) NULL,
Color varchar(50) NULL,
);
ALTER TABLE AlarmState ADD CONSTRAINT PK_AlarmState PRIMARY KEY (ID);
CREATE SEQUENCE SEQ_AlarmState START WITH 1 INCREMENT BY 1;
CREATE TRIGGER AI_AlarmState BEFORE INSERT ON AlarmState
FOR EACH ROW BEGIN SELECT SEQ_AlarmState.nextval INTO :NEW.ID FROM dual;
END;
INSERT INTO AlarmState (State, Color) VALUES ('Good', 'green');
INSERT INTO AlarmState (State, Color) VALUES ('Alarm', 'red');
INSERT INTO AlarmState (State, Color) VALUES ('Not Available', 'orange');
INSERT INTO AlarmState (State, Color) VALUES ('Bad Data', 'blue');
INSERT INTO AlarmState (State, Color) VALUES ('Bad Time', 'purple');
INSERT INTO AlarmState (State, Color) VALUES ('Out of Service', 'grey');
@@ -0,0 +1,37 @@
-- *******************************************************************************************
-- IMPORTANT NOTE: When making updates to this schema, please increment the version number!
-- *******************************************************************************************
CREATE VIEW LocalSchemaVersion AS
SELECT 1 AS VersionNumber;
CREATE TABLE DataAvailability(
ID SERIAL NOT NULL PRIMARY KEY,
GoodAvailableData DOUBLE PRECISION NOT NULL,
BadAvailableData DOUBLE PRECISION NOT NULL,
TotalAvailableData DOUBLE PRECISION NOT NULL,
);
CREATE TABLE AlarmDevice(
ID SERIAL NOT NULL PRIMARY KEY,
DeviceID INTEGER NULL FOREIGN KEY REFERENCES Device(ID),
StateID INTEGER NULL FOREIGN KEY REFERENCES AlarmState(ID),
TimeStamp TIMESTAMP NULL,
DisplayData varchar(10) NULL,
CONSTRAINT FK_AlarmDevice_Device FOREIGN KEY(DeviceID) REFERENCES Device (ID) ON DELETE CASCADE,
CONSTRAINT FK_AlarmDevice_AlarmState FOREIGN KEY(StateID) REFERENCES AlarmState (ID) ON DELETE CASCADE
);
CREATE TABLE AlarmState(
ID SERIAL NOT NULL PRIMARY KEY,
State varchar(50) NULL,
Color varchar(50) NULL,
);
INSERT INTO AlarmState (State, Color) VALUES ('Good', 'green');
INSERT INTO AlarmState (State, Color) VALUES ('Alarm', 'red');
INSERT INTO AlarmState (State, Color) VALUES ('Not Available', 'orange')
INSERT INTO AlarmState (State, Color) VALUES ('Bad Data', 'blue');
INSERT INTO AlarmState (State, Color) VALUES ('Bad Time', 'purple');
INSERT INTO AlarmState (State, Color) VALUES ('Out of Service', 'grey');
@@ -0,0 +1,46 @@
-- *******************************************************************************************
-- IMPORTANT NOTE: When making updates to this schema, please increment the version number!
-- *******************************************************************************************
CREATE VIEW [dbo].[LocalSchemaVersion] AS
SELECT 1 AS VersionNumber
GO
CREATE TABLE DataAvailability(
ID int IDENTITY(1,1) NOT NULL PRIMARY KEY,
GoodAvailableData float NOT NULL,
BadAvailableData float NOT NULL,
TotalAvailableData float NOT NULL,
)
GO
CREATE TABLE AlarmDevice(
ID int IDENTITY(1,1) NOT NULL PRIMARY KEY,
DeviceID int NULL FOREIGN KEY REFERENCES Device(ID),
StateID int NULL FOREIGN KEY REFERENCES AlarmState(ID),
TimeStamp datetime NULL,
DisplayData varchar(10) NULL
)
GO
CREATE TABLE AlarmState(
ID int IDENTITY(1,1) NOT NULL PRIMARY KEY,
State varchar(50) NULL,
Color varchar(50) NULL,
)
GO
INSERT AlarmState (State, Color) VALUES ('Good', 'green')
GO
INSERT AlarmState (State, Color) VALUES ('Alarm', 'red')
GO
INSERT AlarmState (State, Color) VALUES ('Not Available', 'orange')
GO
INSERT AlarmState (State, Color) VALUES ('Bad Data', 'blue')
GO
INSERT AlarmState (State, Color) VALUES ('Bad Time', 'purple')
GO
INSERT AlarmState (State, Color) VALUES ('Out of Service', 'grey')
GO
@@ -0,0 +1,36 @@
-- *******************************************************************************************
-- IMPORTANT NOTE: When making updates to this schema, please increment the version number!
-- *******************************************************************************************
CREATE VIEW LocalSchemaVersion AS
SELECT 1 AS VersionNumber;
CREATE TABLE DataAvailability(
ID int PRIMARY KEY AUTOINCREMENT NOT NULL,
GoodAvailableData DOUBLE NOT NULL,
BadAvailableData DOUBLE NOT NULL,
TotalAvailableData DOUBLE NOT NULL
);
CREATE TABLE AlarmDevice(
ID int PRIMARY KEY AUTOINCREMENT NOT NULL,
DeviceID int NULL,
StateID int NULL,
TimeStamp datetime NULL,
DisplayData varchar(10) NULL,
CONSTRAINT FK_AlarmDevice_Device FOREIGN KEY(DeviceID) REFERENCES Device (ID) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT FK_AlarmDevice_AlarmState FOREIGN KEY(StateID) REFERENCES AlarmState (ID) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE AlarmState(
ID int PRIMARY KEY AUTOINCREMENT NOT NULL,
State varchar(50) NULL,
Color varchar(50) NULL,
);
INSERT INTO AlarmState (State, Color) VALUES ('Good', 'green');
INSERT INTO AlarmState (State, Color) VALUES ('Alarm', 'red');
INSERT INTO AlarmState (State, Color) VALUES ('Not Available', 'orange')
INSERT INTO AlarmState (State, Color) VALUES ('Bad Data', 'blue');
INSERT INTO AlarmState (State, Color) VALUES ('Bad Time', 'purple');
INSERT INTO AlarmState (State, Color) VALUES ('Out of Service', 'grey');
View
@@ -26,6 +26,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{E7006E3E-A
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SQL Server", "SQL Server", "{9A59B9E0-A36F-4C52-8568-CB004B20885B}"
ProjectSection(SolutionItems) = preProject
Data\SQL Server\_openPDC.sql = Data\SQL Server\_openPDC.sql
Data\SQL Server\AuditLog.sql = Data\SQL Server\AuditLog.sql
Data\SQL Server\InitialDataSet.sql = Data\SQL Server\InitialDataSet.sql
Data\SQL Server\openPDC.sql = Data\SQL Server\openPDC.sql
@@ -34,6 +35,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SQL Server", "SQL Server",
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MySql", "MySql", "{B1AC9848-2909-4A7B-9541-8EA4E89E72F1}"
ProjectSection(SolutionItems) = preProject
Data\MySQL\_openPDC.sql = Data\MySQL\_openPDC.sql
Data\MySQL\AuditLog.sql = Data\MySQL\AuditLog.sql
Data\MySQL\InitialDataSet.sql = Data\MySQL\InitialDataSet.sql
Data\MySQL\openPDC.sql = Data\MySQL\openPDC.sql
@@ -116,6 +118,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Help Me Choose Diagrams", "
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SQLite", "SQLite", "{53255BB7-2046-4606-BF76-7B5C13F49819}"
ProjectSection(SolutionItems) = preProject
Data\SQLite\_openPDC.sql = Data\SQLite\_openPDC.sql
Data\SQLite\InitialDataSet.sql = Data\SQLite\InitialDataSet.sql
Data\SQLite\openPDC-InitialDataSet.db = Data\SQLite\openPDC-InitialDataSet.db
Data\SQLite\openPDC-SampleDataSet.db = Data\SQLite\openPDC-SampleDataSet.db
@@ -126,6 +129,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SQLite", "SQLite", "{53255B
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Oracle", "Oracle", "{051BD028-6567-442A-B7C5-A5DD9F70B357}"
ProjectSection(SolutionItems) = preProject
Data\Oracle\_openPDC.sql = Data\Oracle\_openPDC.sql
Data\Oracle\AuditLog.sql = Data\Oracle\AuditLog.sql
Data\Oracle\InitialDataSet.sql = Data\Oracle\InitialDataSet.sql
Data\Oracle\openPDC.sql = Data\Oracle\openPDC.sql
@@ -279,6 +283,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WiX", "WiX", "{6CFC0EB9-861
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PostgreSQL", "PostgreSQL", "{73515839-30AD-40E6-809F-A891F2C95599}"
ProjectSection(SolutionItems) = preProject
Data\PostgreSQL\_openPDC.sql = Data\PostgreSQL\_openPDC.sql
Data\PostgreSQL\InitialDataSet.sql = Data\PostgreSQL\InitialDataSet.sql
Data\PostgreSQL\openPDC.sql = Data\PostgreSQL\openPDC.sql
Data\PostgreSQL\SampleDataSet.sql = Data\PostgreSQL\SampleDataSet.sql

0 comments on commit 9eca152

Please sign in to comment.