mirror of
https://github.com/krugersu/YY.EventLogExportAssistant.git
synced 2026-06-20 01:16:51 +02:00
Актуализировал скрипты ручного создания баз данных
This commit is contained in:
@@ -1,141 +1,197 @@
|
||||
create table applications
|
||||
create table if not exists applications
|
||||
(
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(250) null,
|
||||
primary key (Id, InformationSystemId)
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(500) null,
|
||||
primary key (Id, InformationSystemId),
|
||||
constraint IX_Applications_InformationSystemId_Id
|
||||
unique (InformationSystemId, Id)
|
||||
);
|
||||
|
||||
create table computers
|
||||
create index IX_Applications_InformationSystemId_Name
|
||||
on applications (InformationSystemId, Name);
|
||||
|
||||
create table if not exists computers
|
||||
(
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(250) null,
|
||||
primary key (Id, InformationSystemId)
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(500) null,
|
||||
primary key (Id, InformationSystemId),
|
||||
constraint IX_Computers_InformationSystemId_Id
|
||||
unique (InformationSystemId, Id)
|
||||
);
|
||||
|
||||
create table events
|
||||
create index IX_Computers_InformationSystemId_Name
|
||||
on computers (InformationSystemId, Name);
|
||||
|
||||
create table if not exists events
|
||||
(
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(250) null,
|
||||
primary key (Id, InformationSystemId)
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(500) null,
|
||||
Presentation varchar(500) null,
|
||||
primary key (Id, InformationSystemId),
|
||||
constraint IX_Events_InformationSystemId_Id
|
||||
unique (InformationSystemId, Id)
|
||||
);
|
||||
|
||||
create table informationsystems
|
||||
create index IX_Events_InformationSystemId_Name
|
||||
on events (InformationSystemId, Name);
|
||||
|
||||
create table if not exists informationsystems
|
||||
(
|
||||
Id bigint auto_increment
|
||||
primary key,
|
||||
Name varchar(250) null,
|
||||
Description varchar(500) null
|
||||
Id bigint auto_increment,
|
||||
Name varchar(250) null,
|
||||
Description varchar(500) null,
|
||||
constraint IX_InformationSystems_Id
|
||||
unique (Id)
|
||||
);
|
||||
|
||||
create table logfiles
|
||||
alter table informationsystems
|
||||
add primary key (Id);
|
||||
|
||||
create table if not exists logfiles
|
||||
(
|
||||
InformationSystemId bigint not null,
|
||||
FileName varchar(255) not null,
|
||||
CreateDate datetime(6) not null,
|
||||
Id bigint auto_increment,
|
||||
ModificationDate datetime(6) not null,
|
||||
LastEventNumber bigint not null,
|
||||
LastCurrentFileReferences longtext null,
|
||||
LastCurrentFileData longtext null,
|
||||
LastStreamPosition bigint null,
|
||||
primary key (Id, InformationSystemId, FileName, CreateDate)
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
FileName varchar(255) null,
|
||||
CreateDate datetime(6) not null,
|
||||
ModificationDate datetime(6) not null,
|
||||
LastEventNumber bigint not null,
|
||||
LastCurrentFileReferences longtext null,
|
||||
LastCurrentFileData longtext null,
|
||||
LastStreamPosition bigint null,
|
||||
primary key (Id, InformationSystemId),
|
||||
constraint IX_LogFiles_InformationSystemId_FileName_CreateDate_Id
|
||||
unique (InformationSystemId, FileName, CreateDate, Id)
|
||||
);
|
||||
|
||||
create table metadata
|
||||
create table if not exists metadata
|
||||
(
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Uuid char(36) not null,
|
||||
Name varchar(250) null,
|
||||
primary key (Id, InformationSystemId)
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(500) null,
|
||||
Uuid char(36) not null,
|
||||
primary key (Id, InformationSystemId),
|
||||
constraint IX_Metadata_InformationSystemId_Id
|
||||
unique (InformationSystemId, Id)
|
||||
);
|
||||
|
||||
create table primaryports
|
||||
create index IX_Metadata_InformationSystemId_Name_Uuid
|
||||
on metadata (InformationSystemId, Name, Uuid);
|
||||
|
||||
create table if not exists primaryports
|
||||
(
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(250) null,
|
||||
primary key (Id, InformationSystemId)
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(500) null,
|
||||
primary key (Id, InformationSystemId),
|
||||
constraint IX_PrimaryPorts_InformationSystemId_Id
|
||||
unique (InformationSystemId, Id)
|
||||
);
|
||||
|
||||
create table rowsdata
|
||||
create index IX_PrimaryPorts_InformationSystemId_Name
|
||||
on primaryports (InformationSystemId, Name);
|
||||
|
||||
create table if not exists rowsdata
|
||||
(
|
||||
InformationSystemId bigint not null,
|
||||
Period datetime (6) not null,
|
||||
Id bigint not null,
|
||||
SeverityId bigint null,
|
||||
ConnectId bigint null,
|
||||
Session bigint null,
|
||||
TransactionStatusId bigint null,
|
||||
TransactionDate datetime(6) null,
|
||||
TransactionId bigint null,
|
||||
UserId bigint null,
|
||||
ComputerId bigint null,
|
||||
ApplicationId bigint null,
|
||||
EventId bigint null,
|
||||
Comment longtext null,
|
||||
MetadataId bigint null,
|
||||
Data longtext null,
|
||||
DataUUID varchar(255) null,
|
||||
DataPresentation longtext null,
|
||||
WorkServerId bigint null,
|
||||
PrimaryPortId bigint null,
|
||||
SecondaryPortId bigint null,
|
||||
primary key (InformationSystemId, Period, Id)
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint not null,
|
||||
Period datetime(6) not null,
|
||||
SeverityId bigint null,
|
||||
ConnectId bigint null,
|
||||
Session bigint null,
|
||||
TransactionStatusId bigint null,
|
||||
TransactionDate datetime(6) null,
|
||||
TransactionId bigint null,
|
||||
UserId bigint null,
|
||||
ComputerId bigint null,
|
||||
ApplicationId bigint null,
|
||||
EventId bigint null,
|
||||
Comment longtext null,
|
||||
MetadataId bigint null,
|
||||
Data longtext null,
|
||||
DataUUID varchar(255) null,
|
||||
DataPresentation longtext null,
|
||||
WorkServerId bigint null,
|
||||
PrimaryPortId bigint null,
|
||||
SecondaryPortId bigint null,
|
||||
constraint IX_RowsData_InformationSystemId_Period_Id
|
||||
unique (InformationSystemId, Period, Id)
|
||||
);
|
||||
|
||||
create index IX_RowsData_InformationSystemId_DataUUID
|
||||
on rowsdata (InformationSystemId, DataUUID);
|
||||
on rowsdata (InformationSystemId, DataUUID);
|
||||
|
||||
create index IX_RowsData_InformationSystemId_UserId_Period
|
||||
on rowsdata (InformationSystemId, UserId, Period);
|
||||
on rowsdata (InformationSystemId, UserId, Period);
|
||||
|
||||
create table secondaryports
|
||||
alter table rowsdata
|
||||
add primary key (InformationSystemId, Period, Id);
|
||||
|
||||
create table if not exists secondaryports
|
||||
(
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(250) null,
|
||||
primary key (Id, InformationSystemId)
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(500) null,
|
||||
primary key (Id, InformationSystemId),
|
||||
constraint IX_SecondaryPorts_InformationSystemId_Id
|
||||
unique (InformationSystemId, Id)
|
||||
);
|
||||
|
||||
create table severities
|
||||
create index IX_SecondaryPorts_InformationSystemId_Name
|
||||
on secondaryports (InformationSystemId, Name);
|
||||
|
||||
create table if not exists severities
|
||||
(
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(250) null,
|
||||
primary key (Id, InformationSystemId)
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(500) null,
|
||||
primary key (Id, InformationSystemId),
|
||||
constraint IX_Severities_InformationSystemId_Id
|
||||
unique (InformationSystemId, Id)
|
||||
);
|
||||
|
||||
create table transactionstatuses
|
||||
create index IX_Severities_InformationSystemId_Name
|
||||
on severities (InformationSystemId, Name);
|
||||
|
||||
create table if not exists transactionstatuses
|
||||
(
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(250) null,
|
||||
primary key (Id, InformationSystemId)
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(500) null,
|
||||
primary key (Id, InformationSystemId)
|
||||
);
|
||||
|
||||
create table users
|
||||
create table if not exists users
|
||||
(
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Uuid char(36) not null,
|
||||
Name varchar(250) null,
|
||||
primary key (Id, InformationSystemId)
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(500) null,
|
||||
Uuid char(36) not null,
|
||||
primary key (Id, InformationSystemId),
|
||||
constraint IX_Users_InformationSystemId_Id
|
||||
unique (InformationSystemId, Id)
|
||||
);
|
||||
|
||||
create table workservers
|
||||
create index IX_Users_InformationSystemId_Name_Uuid
|
||||
on users (InformationSystemId, Name, Uuid);
|
||||
|
||||
create table if not exists workservers
|
||||
(
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(250) null,
|
||||
primary key (Id, InformationSystemId)
|
||||
InformationSystemId bigint not null,
|
||||
Id bigint auto_increment,
|
||||
Name varchar(500) null,
|
||||
primary key (Id, InformationSystemId),
|
||||
constraint IX_WorkServers_InformationSystemId_Id
|
||||
unique (InformationSystemId, Id)
|
||||
);
|
||||
|
||||
create view vw_eventlog as
|
||||
select `rd`.`InformationSystemId` AS `InformationSystemId`,
|
||||
create index IX_WorkServers_InformationSystemId_Name
|
||||
on workservers (InformationSystemId, Name);
|
||||
|
||||
create or replace definer = YPermitin@`%` view vw_eventlog as
|
||||
select `rd`.`InformationSystemId` AS `InformationSystemId`,
|
||||
`infs`.`Name` AS `InformationSystemName`,
|
||||
`rd`.`Period` AS `Period`,
|
||||
`rd`.`Id` AS `RowId`,
|
||||
@@ -168,23 +224,23 @@ select `rd`.`InformationSystemId` AS `InformationSystemId`,
|
||||
`pprt`.`Name` AS `PrimaryPortName`,
|
||||
`rd`.`SecondaryPortId` AS `SecondaryPortId`,
|
||||
`sprt`.`Name` AS `SecondaryPortName`
|
||||
from ((((((((((`eventlogexporttest`.`rowsdata` `rd` left join `eventlogexporttest`.`informationsystems` `infs` on ((`rd`.`InformationSystemId` = `infs`.`Id`))) left join `eventlogexporttest`.`severities` `sv` on ((
|
||||
from ((((((((((`rowsdata` `rd` left join `informationsystems` `infs` on ((`rd`.`InformationSystemId` = `infs`.`Id`))) left join `severities` `sv` on ((
|
||||
(`rd`.`InformationSystemId` = `sv`.`InformationSystemId`) and
|
||||
(`rd`.`SeverityId` = `sv`.`Id`)))) left join `eventlogexporttest`.`users` `usr` on ((
|
||||
(`rd`.`SeverityId` = `sv`.`Id`)))) left join `users` `usr` on ((
|
||||
(`rd`.`InformationSystemId` = `usr`.`InformationSystemId`) and
|
||||
(`rd`.`UserId` = `usr`.`Id`)))) left join `eventlogexporttest`.`computers` `cmp` on ((
|
||||
(`rd`.`UserId` = `usr`.`Id`)))) left join `computers` `cmp` on ((
|
||||
(`rd`.`InformationSystemId` = `cmp`.`InformationSystemId`) and
|
||||
(`rd`.`ComputerId` = `cmp`.`Id`)))) left join `eventlogexporttest`.`applications` `apps` on ((
|
||||
(`rd`.`ComputerId` = `cmp`.`Id`)))) left join `applications` `apps` on ((
|
||||
(`rd`.`InformationSystemId` = `apps`.`InformationSystemId`) and
|
||||
(`rd`.`ApplicationId` = `apps`.`Id`)))) left join `eventlogexporttest`.`events` `evnt` on ((
|
||||
(`rd`.`ApplicationId` = `apps`.`Id`)))) left join `events` `evnt` on ((
|
||||
(`rd`.`InformationSystemId` = `evnt`.`InformationSystemId`) and
|
||||
(`rd`.`EventId` = `evnt`.`Id`)))) left join `eventlogexporttest`.`metadata` `meta` on ((
|
||||
(`rd`.`EventId` = `evnt`.`Id`)))) left join `metadata` `meta` on ((
|
||||
(`rd`.`InformationSystemId` = `meta`.`InformationSystemId`) and
|
||||
(`rd`.`MetadataId` = `meta`.`Id`)))) left join `eventlogexporttest`.`workservers` `wsrv` on ((
|
||||
(`rd`.`MetadataId` = `meta`.`Id`)))) left join `workservers` `wsrv` on ((
|
||||
(`rd`.`InformationSystemId` = `wsrv`.`InformationSystemId`) and
|
||||
(`rd`.`WorkServerId` = `wsrv`.`Id`)))) left join `eventlogexporttest`.`primaryports` `pprt` on ((
|
||||
(`rd`.`WorkServerId` = `wsrv`.`Id`)))) left join `primaryports` `pprt` on ((
|
||||
(`rd`.`InformationSystemId` = `pprt`.`InformationSystemId`) and (`rd`.`PrimaryPortId` = `pprt`.`Id`))))
|
||||
left join `eventlogexporttest`.`secondaryports` `sprt`
|
||||
left join `secondaryports` `sprt`
|
||||
on (((`rd`.`InformationSystemId` = `sprt`.`InformationSystemId`) and
|
||||
(`rd`.`SecondaryPortId` = `sprt`.`Id`))));
|
||||
|
||||
|
||||
+239
-127
@@ -1,156 +1,268 @@
|
||||
CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" (
|
||||
"MigrationId" character varying(150) NOT NULL,
|
||||
"ProductVersion" character varying(32) NOT NULL,
|
||||
CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId")
|
||||
create table if not exists "Applications"
|
||||
(
|
||||
"InformationSystemId" bigint not null,
|
||||
"Id" bigint generated by default as identity,
|
||||
"Name" varchar(500),
|
||||
constraint "PK_Applications"
|
||||
primary key ("InformationSystemId", "Id")
|
||||
);
|
||||
|
||||
CREATE TABLE "Applications" (
|
||||
"InformationSystemId" bigint NOT NULL,
|
||||
"Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"Name" character varying(250) NULL,
|
||||
CONSTRAINT "PK_Applications" PRIMARY KEY ("InformationSystemId", "Id")
|
||||
create unique index if not exists "IX_Applications_InformationSystemId_Id"
|
||||
on "Applications" ("InformationSystemId", "Id");
|
||||
|
||||
create index if not exists "IX_Applications_InformationSystemId_Name"
|
||||
on "Applications" ("InformationSystemId", "Name");
|
||||
|
||||
create table if not exists "Computers"
|
||||
(
|
||||
"InformationSystemId" bigint not null,
|
||||
"Id" bigint generated by default as identity,
|
||||
"Name" varchar(500),
|
||||
constraint "PK_Computers"
|
||||
primary key ("InformationSystemId", "Id")
|
||||
);
|
||||
|
||||
CREATE TABLE "Computers" (
|
||||
"InformationSystemId" bigint NOT NULL,
|
||||
"Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"Name" character varying(250) NULL,
|
||||
CONSTRAINT "PK_Computers" PRIMARY KEY ("InformationSystemId", "Id")
|
||||
create unique index if not exists "IX_Computers_InformationSystemId_Id"
|
||||
on "Computers" ("InformationSystemId", "Id");
|
||||
|
||||
create index if not exists "IX_Computers_InformationSystemId_Name"
|
||||
on "Computers" ("InformationSystemId", "Name");
|
||||
|
||||
create table if not exists "Events"
|
||||
(
|
||||
"InformationSystemId" bigint not null,
|
||||
"Id" bigint generated by default as identity,
|
||||
"Name" varchar(500),
|
||||
"Presentation" varchar(500),
|
||||
constraint "PK_Events"
|
||||
primary key ("InformationSystemId", "Id")
|
||||
);
|
||||
|
||||
CREATE TABLE "Events" (
|
||||
"InformationSystemId" bigint NOT NULL,
|
||||
"Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"Name" character varying(250) NULL,
|
||||
CONSTRAINT "PK_Events" PRIMARY KEY ("InformationSystemId", "Id")
|
||||
create unique index if not exists "IX_Events_InformationSystemId_Id"
|
||||
on "Events" ("InformationSystemId", "Id");
|
||||
|
||||
create index if not exists "IX_Events_InformationSystemId_Name"
|
||||
on "Events" ("InformationSystemId", "Name");
|
||||
|
||||
create table if not exists "InformationSystems"
|
||||
(
|
||||
"Id" bigint generated by default as identity
|
||||
constraint "PK_InformationSystems"
|
||||
primary key,
|
||||
"Name" varchar(250),
|
||||
"Description" varchar(500)
|
||||
);
|
||||
|
||||
CREATE TABLE "InformationSystems" (
|
||||
"Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"Name" character varying(250) NULL,
|
||||
"Description" character varying(500) NULL,
|
||||
CONSTRAINT "PK_InformationSystems" PRIMARY KEY ("Id")
|
||||
create unique index if not exists "IX_InformationSystems_Id"
|
||||
on "InformationSystems" ("Id");
|
||||
|
||||
create table if not exists "LogFiles"
|
||||
(
|
||||
"InformationSystemId" bigint not null,
|
||||
"Id" bigint generated by default as identity,
|
||||
"FileName" text,
|
||||
"CreateDate" timestamp not null,
|
||||
"ModificationDate" timestamp not null,
|
||||
"LastEventNumber" bigint not null,
|
||||
"LastCurrentFileReferences" text,
|
||||
"LastCurrentFileData" text,
|
||||
"LastStreamPosition" bigint,
|
||||
constraint "PK_LogFiles"
|
||||
primary key ("InformationSystemId", "Id")
|
||||
);
|
||||
|
||||
CREATE TABLE "LogFiles" (
|
||||
"InformationSystemId" bigint NOT NULL,
|
||||
"FileName" text NOT NULL,
|
||||
"CreateDate" timestamp without time zone NOT NULL,
|
||||
"Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"ModificationDate" timestamp without time zone NOT NULL,
|
||||
"LastEventNumber" bigint NOT NULL,
|
||||
"LastCurrentFileReferences" text NULL,
|
||||
"LastCurrentFileData" text NULL,
|
||||
"LastStreamPosition" bigint NULL,
|
||||
CONSTRAINT "PK_LogFiles" PRIMARY KEY ("InformationSystemId", "FileName", "CreateDate", "Id")
|
||||
create unique index if not exists "IX_LogFiles_InformationSystemId_FileName_CreateDate_Id"
|
||||
on "LogFiles" ("InformationSystemId", "FileName", "CreateDate", "Id");
|
||||
|
||||
create table if not exists "Metadata"
|
||||
(
|
||||
"InformationSystemId" bigint not null,
|
||||
"Id" bigint generated by default as identity,
|
||||
"Name" varchar(500),
|
||||
"Uuid" uuid not null,
|
||||
constraint "PK_Metadata"
|
||||
primary key ("InformationSystemId", "Id")
|
||||
);
|
||||
|
||||
CREATE TABLE "Metadata" (
|
||||
"InformationSystemId" bigint NOT NULL,
|
||||
"Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"Uuid" uuid NOT NULL,
|
||||
"Name" character varying(250) NULL,
|
||||
CONSTRAINT "PK_Metadata" PRIMARY KEY ("InformationSystemId", "Id")
|
||||
create unique index if not exists "IX_Metadata_InformationSystemId_Id"
|
||||
on "Metadata" ("InformationSystemId", "Id");
|
||||
|
||||
create index if not exists "IX_Metadata_InformationSystemId_Name_Uuid"
|
||||
on "Metadata" ("InformationSystemId", "Name", "Uuid");
|
||||
|
||||
create table if not exists "PrimaryPorts"
|
||||
(
|
||||
"InformationSystemId" bigint not null,
|
||||
"Id" bigint generated by default as identity,
|
||||
"Name" varchar(500),
|
||||
constraint "PK_PrimaryPorts"
|
||||
primary key ("InformationSystemId", "Id")
|
||||
);
|
||||
|
||||
CREATE TABLE "PrimaryPorts" (
|
||||
"InformationSystemId" bigint NOT NULL,
|
||||
"Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"Name" character varying(250) NULL,
|
||||
CONSTRAINT "PK_PrimaryPorts" PRIMARY KEY ("InformationSystemId", "Id")
|
||||
create unique index if not exists "IX_PrimaryPorts_InformationSystemId_Id"
|
||||
on "PrimaryPorts" ("InformationSystemId", "Id");
|
||||
|
||||
create index if not exists "IX_PrimaryPorts_InformationSystemId_Name"
|
||||
on "PrimaryPorts" ("InformationSystemId", "Name");
|
||||
|
||||
create table if not exists "RowsData"
|
||||
(
|
||||
"InformationSystemId" bigint not null,
|
||||
"Id" bigint not null,
|
||||
"Period" timestamp with time zone not null,
|
||||
"SeverityId" bigint,
|
||||
"ConnectId" bigint,
|
||||
"Session" bigint,
|
||||
"TransactionStatusId" bigint,
|
||||
"TransactionDate" timestamp,
|
||||
"TransactionId" bigint,
|
||||
"UserId" bigint,
|
||||
"ComputerId" bigint,
|
||||
"ApplicationId" bigint,
|
||||
"EventId" bigint,
|
||||
"Comment" text,
|
||||
"MetadataId" bigint,
|
||||
"Data" text,
|
||||
"DataUUID" text,
|
||||
"DataPresentation" text,
|
||||
"WorkServerId" bigint,
|
||||
"PrimaryPortId" bigint,
|
||||
"SecondaryPortId" bigint,
|
||||
constraint "PK_RowsData"
|
||||
primary key ("InformationSystemId", "Period", "Id")
|
||||
);
|
||||
|
||||
CREATE TABLE "RowsData" (
|
||||
"InformationSystemId" bigint NOT NULL,
|
||||
"Period" timestamp with time zone NOT NULL,
|
||||
"Id" bigint NOT NULL,
|
||||
"SeverityId" bigint NULL,
|
||||
"ConnectId" bigint NULL,
|
||||
"Session" bigint NULL,
|
||||
"TransactionStatusId" bigint NULL,
|
||||
"TransactionDate" timestamp without time zone NULL,
|
||||
"TransactionId" bigint NULL,
|
||||
"UserId" bigint NULL,
|
||||
"ComputerId" bigint NULL,
|
||||
"ApplicationId" bigint NULL,
|
||||
"EventId" bigint NULL,
|
||||
"Comment" text NULL,
|
||||
"MetadataId" bigint NULL,
|
||||
"Data" text NULL,
|
||||
"DataUUID" text NULL,
|
||||
"DataPresentation" text NULL,
|
||||
"WorkServerId" bigint NULL,
|
||||
"PrimaryPortId" bigint NULL,
|
||||
"SecondaryPortId" bigint NULL,
|
||||
CONSTRAINT "PK_RowsData" PRIMARY KEY ("InformationSystemId", "Period", "Id")
|
||||
create index if not exists "IX_RowsData_InformationSystemId_DataUUID"
|
||||
on "RowsData" ("InformationSystemId", "DataUUID");
|
||||
|
||||
create unique index if not exists "IX_RowsData_InformationSystemId_Period_Id"
|
||||
on "RowsData" ("InformationSystemId", "Period", "Id");
|
||||
|
||||
create index if not exists "IX_RowsData_InformationSystemId_UserId_Period"
|
||||
on "RowsData" ("InformationSystemId", "UserId", "Period");
|
||||
|
||||
create table if not exists "SecondaryPorts"
|
||||
(
|
||||
"InformationSystemId" bigint not null,
|
||||
"Id" bigint generated by default as identity,
|
||||
"Name" varchar(500),
|
||||
constraint "PK_SecondaryPorts"
|
||||
primary key ("InformationSystemId", "Id")
|
||||
);
|
||||
|
||||
CREATE TABLE "SecondaryPorts" (
|
||||
"InformationSystemId" bigint NOT NULL,
|
||||
"Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"Name" character varying(250) NULL,
|
||||
CONSTRAINT "PK_SecondaryPorts" PRIMARY KEY ("InformationSystemId", "Id")
|
||||
create unique index if not exists "IX_SecondaryPorts_InformationSystemId_Id"
|
||||
on "SecondaryPorts" ("InformationSystemId", "Id");
|
||||
|
||||
create index if not exists "IX_SecondaryPorts_InformationSystemId_Name"
|
||||
on "SecondaryPorts" ("InformationSystemId", "Name");
|
||||
|
||||
create table if not exists "Severities"
|
||||
(
|
||||
"InformationSystemId" bigint not null,
|
||||
"Id" bigint generated by default as identity,
|
||||
"Name" varchar(500),
|
||||
constraint "PK_Severities"
|
||||
primary key ("InformationSystemId", "Id")
|
||||
);
|
||||
|
||||
CREATE TABLE "Severities" (
|
||||
"InformationSystemId" bigint NOT NULL,
|
||||
"Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"Name" character varying(250) NULL,
|
||||
CONSTRAINT "PK_Severities" PRIMARY KEY ("InformationSystemId", "Id")
|
||||
create unique index if not exists "IX_Severities_InformationSystemId_Id"
|
||||
on "Severities" ("InformationSystemId", "Id");
|
||||
|
||||
create index if not exists "IX_Severities_InformationSystemId_Name"
|
||||
on "Severities" ("InformationSystemId", "Name");
|
||||
|
||||
create table if not exists "TransactionStatuses"
|
||||
(
|
||||
"InformationSystemId" bigint not null,
|
||||
"Id" bigint generated by default as identity,
|
||||
"Name" varchar(500),
|
||||
constraint "PK_TransactionStatuses"
|
||||
primary key ("InformationSystemId", "Id")
|
||||
);
|
||||
|
||||
CREATE TABLE "TransactionStatuses" (
|
||||
"InformationSystemId" bigint NOT NULL,
|
||||
"Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"Name" character varying(250) NULL,
|
||||
CONSTRAINT "PK_TransactionStatuses" PRIMARY KEY ("InformationSystemId", "Id")
|
||||
create table if not exists "Users"
|
||||
(
|
||||
"InformationSystemId" bigint not null,
|
||||
"Id" bigint generated by default as identity,
|
||||
"Name" varchar(500),
|
||||
"Uuid" uuid not null,
|
||||
constraint "PK_Users"
|
||||
primary key ("InformationSystemId", "Id")
|
||||
);
|
||||
|
||||
CREATE TABLE "Users" (
|
||||
"InformationSystemId" bigint NOT NULL,
|
||||
"Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"Uuid" uuid NOT NULL,
|
||||
"Name" character varying(250) NULL,
|
||||
CONSTRAINT "PK_Users" PRIMARY KEY ("InformationSystemId", "Id")
|
||||
create unique index if not exists "IX_Users_InformationSystemId_Id"
|
||||
on "Users" ("InformationSystemId", "Id");
|
||||
|
||||
create index if not exists "IX_Users_InformationSystemId_Name_Uuid"
|
||||
on "Users" ("InformationSystemId", "Name", "Uuid");
|
||||
|
||||
create table if not exists "WorkServers"
|
||||
(
|
||||
"InformationSystemId" bigint not null,
|
||||
"Id" bigint generated by default as identity,
|
||||
"Name" varchar(500),
|
||||
constraint "PK_WorkServers"
|
||||
primary key ("InformationSystemId", "Id")
|
||||
);
|
||||
|
||||
CREATE TABLE "WorkServers" (
|
||||
"InformationSystemId" bigint NOT NULL,
|
||||
"Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"Name" character varying(250) NULL,
|
||||
CONSTRAINT "PK_WorkServers" PRIMARY KEY ("InformationSystemId", "Id")
|
||||
);
|
||||
create unique index if not exists "IX_WorkServers_InformationSystemId_Id"
|
||||
on "WorkServers" ("InformationSystemId", "Id");
|
||||
|
||||
CREATE UNIQUE INDEX "IX_Applications_InformationSystemId_Id" ON "Applications" ("InformationSystemId", "Id");
|
||||
create index if not exists "IX_WorkServers_InformationSystemId_Name"
|
||||
on "WorkServers" ("InformationSystemId", "Name");
|
||||
|
||||
CREATE UNIQUE INDEX "IX_Computers_InformationSystemId_Id" ON "Computers" ("InformationSystemId", "Id");
|
||||
|
||||
CREATE UNIQUE INDEX "IX_Events_InformationSystemId_Id" ON "Events" ("InformationSystemId", "Id");
|
||||
|
||||
CREATE UNIQUE INDEX "IX_InformationSystems_Id" ON "InformationSystems" ("Id");
|
||||
|
||||
CREATE UNIQUE INDEX "IX_LogFiles_InformationSystemId_FileName_CreateDate_Id" ON "LogFiles" ("InformationSystemId", "FileName", "CreateDate", "Id");
|
||||
|
||||
CREATE UNIQUE INDEX "IX_Metadata_InformationSystemId_Id" ON "Metadata" ("InformationSystemId", "Id");
|
||||
|
||||
CREATE UNIQUE INDEX "IX_PrimaryPorts_InformationSystemId_Id" ON "PrimaryPorts" ("InformationSystemId", "Id");
|
||||
|
||||
CREATE INDEX "IX_RowsData_InformationSystemId_DataUUID" ON "RowsData" ("InformationSystemId", "DataUUID");
|
||||
|
||||
CREATE UNIQUE INDEX "IX_RowsData_InformationSystemId_Period_Id" ON "RowsData" ("InformationSystemId", "Period", "Id");
|
||||
|
||||
CREATE INDEX "IX_RowsData_InformationSystemId_UserId_Period" ON "RowsData" ("InformationSystemId", "UserId", "Period");
|
||||
|
||||
CREATE UNIQUE INDEX "IX_SecondaryPorts_InformationSystemId_Id" ON "SecondaryPorts" ("InformationSystemId", "Id");
|
||||
|
||||
CREATE UNIQUE INDEX "IX_Severities_InformationSystemId_Id" ON "Severities" ("InformationSystemId", "Id");
|
||||
|
||||
CREATE UNIQUE INDEX "IX_TransactionStatuses_InformationSystemId_Id" ON "TransactionStatuses" ("InformationSystemId", "Id");
|
||||
|
||||
CREATE UNIQUE INDEX "IX_Users_InformationSystemId_Id" ON "Users" ("InformationSystemId", "Id");
|
||||
|
||||
CREATE UNIQUE INDEX "IX_WorkServers_InformationSystemId_Id" ON "WorkServers" ("InformationSystemId", "Id");
|
||||
|
||||
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
|
||||
VALUES ('20200509202647_Initialization', '3.1.3');
|
||||
create or replace view vw_eventlog("InformationSystemId", "InformationSystemName", "Period", "RowId", "SeverityId", "SeverityName", "Connection", "Session", "TransactionStatusId", "TransactionDate", "TransactionId", "UserId", "UserName", "UserUUID", "ComputerId", "ComputerName", "Data", "DataUUID", "DataPresentation", "Comment", "ApplicationId", "ApplicationName", "EventId", "EventName", "MetadataId", "MetadataName", "MetadataUUID", "WorkServerId", "WorkServerName", "PrimaryPortId", "PrimaryPortName", "SecondaryPortId", "SecondaryPortName") as
|
||||
SELECT "RD"."InformationSystemId",
|
||||
"IS"."Name" AS "InformationSystemName",
|
||||
"RD"."Period",
|
||||
"RD"."Id" AS "RowId",
|
||||
"RD"."SeverityId",
|
||||
"SV"."Name" AS "SeverityName",
|
||||
"RD"."ConnectId" AS "Connection",
|
||||
"RD"."Session",
|
||||
"RD"."TransactionStatusId",
|
||||
"RD"."TransactionDate",
|
||||
"RD"."TransactionId",
|
||||
"RD"."UserId",
|
||||
"USR"."Name" AS "UserName",
|
||||
"USR"."Uuid" AS "UserUUID",
|
||||
"RD"."ComputerId",
|
||||
"CMP"."Name" AS "ComputerName",
|
||||
"RD"."Data",
|
||||
"RD"."DataUUID",
|
||||
"RD"."DataPresentation",
|
||||
"RD"."Comment",
|
||||
"RD"."ApplicationId",
|
||||
"APPS"."Name" AS "ApplicationName",
|
||||
"RD"."EventId",
|
||||
"EVNT"."Name" AS "EventName",
|
||||
"RD"."MetadataId",
|
||||
"META"."Name" AS "MetadataName",
|
||||
"META"."Uuid" AS "MetadataUUID",
|
||||
"RD"."WorkServerId",
|
||||
"WSRV"."Name" AS "WorkServerName",
|
||||
"RD"."PrimaryPortId",
|
||||
"PPRT"."Name" AS "PrimaryPortName",
|
||||
"RD"."SecondaryPortId",
|
||||
"SPRT"."Name" AS "SecondaryPortName"
|
||||
FROM "RowsData" "RD"
|
||||
LEFT JOIN "InformationSystems" "IS" ON "RD"."InformationSystemId" = "IS"."Id"
|
||||
LEFT JOIN "Severities" "SV"
|
||||
ON "RD"."InformationSystemId" = "SV"."InformationSystemId" AND "RD"."SeverityId" = "SV"."Id"
|
||||
LEFT JOIN "Users" "USR"
|
||||
ON "RD"."InformationSystemId" = "USR"."InformationSystemId" AND "RD"."UserId" = "USR"."Id"
|
||||
LEFT JOIN "Computers" "CMP"
|
||||
ON "RD"."InformationSystemId" = "CMP"."InformationSystemId" AND "RD"."ComputerId" = "CMP"."Id"
|
||||
LEFT JOIN "Applications" "APPS"
|
||||
ON "RD"."InformationSystemId" = "APPS"."InformationSystemId" AND "RD"."ApplicationId" = "APPS"."Id"
|
||||
LEFT JOIN "Events" "EVNT"
|
||||
ON "RD"."InformationSystemId" = "EVNT"."InformationSystemId" AND "RD"."EventId" = "EVNT"."Id"
|
||||
LEFT JOIN "Metadata" "META"
|
||||
ON "RD"."InformationSystemId" = "META"."InformationSystemId" AND "RD"."MetadataId" = "META"."Id"
|
||||
LEFT JOIN "WorkServers" "WSRV"
|
||||
ON "RD"."InformationSystemId" = "WSRV"."InformationSystemId" AND "RD"."WorkServerId" = "WSRV"."Id"
|
||||
LEFT JOIN "PrimaryPorts" "PPRT"
|
||||
ON "RD"."InformationSystemId" = "PPRT"."InformationSystemId" AND "RD"."PrimaryPortId" = "PPRT"."Id"
|
||||
LEFT JOIN "SecondaryPorts" "SPRT" ON "RD"."InformationSystemId" = "SPRT"."InformationSystemId" AND
|
||||
"RD"."SecondaryPortId" = "SPRT"."Id";
|
||||
|
||||
|
||||
+293
-132
@@ -1,167 +1,328 @@
|
||||
IF OBJECT_ID(N'[__EFMigrationsHistory]') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE [__EFMigrationsHistory] (
|
||||
[MigrationId] nvarchar(150) NOT NULL,
|
||||
[ProductVersion] nvarchar(32) NOT NULL,
|
||||
CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId])
|
||||
);
|
||||
END;
|
||||
|
||||
CREATE TABLE [dbo].[Applications](
|
||||
[InformationSystemId] [bigint] NOT NULL,
|
||||
[Id] [bigint] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](500) NULL,
|
||||
[Presentation] [nvarchar](500) NULL,
|
||||
CONSTRAINT [PK_Applications] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE TABLE [Applications] (
|
||||
[InformationSystemId] bigint NOT NULL,
|
||||
[Id] bigint NOT NULL IDENTITY,
|
||||
[Name] nvarchar(250) NULL,
|
||||
CONSTRAINT [PK_Applications] PRIMARY KEY ([InformationSystemId], [Id])
|
||||
);
|
||||
|
||||
CREATE TABLE [dbo].[Computers](
|
||||
[InformationSystemId] [bigint] NOT NULL,
|
||||
[Id] [bigint] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](500) NULL,
|
||||
CONSTRAINT [PK_Computers] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE TABLE [Computers] (
|
||||
[InformationSystemId] bigint NOT NULL,
|
||||
[Id] bigint NOT NULL IDENTITY,
|
||||
[Name] nvarchar(250) NULL,
|
||||
CONSTRAINT [PK_Computers] PRIMARY KEY ([InformationSystemId], [Id])
|
||||
);
|
||||
|
||||
CREATE TABLE [dbo].[Events](
|
||||
[InformationSystemId] [bigint] NOT NULL,
|
||||
[Id] [bigint] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](500) NULL,
|
||||
[Presentation] [nvarchar](500) NULL,
|
||||
CONSTRAINT [PK_Events] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE TABLE [Events] (
|
||||
[InformationSystemId] bigint NOT NULL,
|
||||
[Id] bigint NOT NULL IDENTITY,
|
||||
[Name] nvarchar(250) NULL,
|
||||
CONSTRAINT [PK_Events] PRIMARY KEY ([InformationSystemId], [Id])
|
||||
);
|
||||
|
||||
CREATE TABLE [dbo].[InformationSystems](
|
||||
[Id] [bigint] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](250) NULL,
|
||||
[Description] [nvarchar](500) NULL,
|
||||
CONSTRAINT [PK_InformationSystems] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE TABLE [InformationSystems] (
|
||||
[Id] bigint NOT NULL IDENTITY,
|
||||
[Name] nvarchar(250) NULL,
|
||||
[Description] nvarchar(500) NULL,
|
||||
CONSTRAINT [PK_InformationSystems] PRIMARY KEY ([Id])
|
||||
);
|
||||
|
||||
CREATE TABLE [dbo].[Metadata](
|
||||
[InformationSystemId] [bigint] NOT NULL,
|
||||
[Id] [bigint] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](500) NULL,
|
||||
[Uuid] [uniqueidentifier] NOT NULL,
|
||||
CONSTRAINT [PK_Metadata] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE TABLE [LogFiles] (
|
||||
[InformationSystemId] bigint NOT NULL,
|
||||
[FileName] nvarchar(450) NOT NULL,
|
||||
[CreateDate] datetime2 NOT NULL,
|
||||
[Id] bigint NOT NULL IDENTITY,
|
||||
[ModificationDate] datetime2 NOT NULL,
|
||||
[LastEventNumber] bigint NOT NULL,
|
||||
[LastCurrentFileReferences] nvarchar(max) NULL,
|
||||
[LastCurrentFileData] nvarchar(max) NULL,
|
||||
[LastStreamPosition] bigint NULL,
|
||||
CONSTRAINT [PK_LogFiles] PRIMARY KEY ([InformationSystemId], [FileName], [CreateDate], [Id])
|
||||
);
|
||||
|
||||
CREATE TABLE [dbo].[PrimaryPorts](
|
||||
[InformationSystemId] [bigint] NOT NULL,
|
||||
[Id] [bigint] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](500) NULL,
|
||||
CONSTRAINT [PK_PrimaryPorts] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE TABLE [Metadata] (
|
||||
[InformationSystemId] bigint NOT NULL,
|
||||
[Id] bigint NOT NULL IDENTITY,
|
||||
[Uuid] uniqueidentifier NOT NULL,
|
||||
[Name] nvarchar(250) NULL,
|
||||
CONSTRAINT [PK_Metadata] PRIMARY KEY ([InformationSystemId], [Id])
|
||||
);
|
||||
|
||||
CREATE TABLE [dbo].[RowsData](
|
||||
[InformationSystemId] [bigint] NOT NULL,
|
||||
[Id] [bigint] NOT NULL,
|
||||
[Period] [datetimeoffset](7) NOT NULL,
|
||||
[SeverityId] [bigint] NULL,
|
||||
[ConnectId] [bigint] NULL,
|
||||
[Session] [bigint] NULL,
|
||||
[TransactionStatusId] [bigint] NULL,
|
||||
[TransactionDate] [datetime2](7) NULL,
|
||||
[TransactionId] [bigint] NULL,
|
||||
[UserId] [bigint] NULL,
|
||||
[ComputerId] [bigint] NULL,
|
||||
[ApplicationId] [bigint] NULL,
|
||||
[EventId] [bigint] NULL,
|
||||
[Comment] [nvarchar](max) NULL,
|
||||
[MetadataId] [bigint] NULL,
|
||||
[Data] [nvarchar](max) NULL,
|
||||
[DataUUID] [nvarchar](450) NULL,
|
||||
[DataPresentation] [nvarchar](max) NULL,
|
||||
[WorkServerId] [bigint] NULL,
|
||||
[PrimaryPortId] [bigint] NULL,
|
||||
[SecondaryPortId] [bigint] NULL,
|
||||
CONSTRAINT [PK_RowsData] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Period] ASC,
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE TABLE [PrimaryPorts] (
|
||||
[InformationSystemId] bigint NOT NULL,
|
||||
[Id] bigint NOT NULL IDENTITY,
|
||||
[Name] nvarchar(250) NULL,
|
||||
CONSTRAINT [PK_PrimaryPorts] PRIMARY KEY ([InformationSystemId], [Id])
|
||||
);
|
||||
|
||||
CREATE TABLE [dbo].[SecondaryPorts](
|
||||
[InformationSystemId] [bigint] NOT NULL,
|
||||
[Id] [bigint] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](500) NULL,
|
||||
CONSTRAINT [PK_SecondaryPorts] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE TABLE [RowsData] (
|
||||
[InformationSystemId] bigint NOT NULL,
|
||||
[Period] datetimeoffset NOT NULL,
|
||||
[Id] bigint NOT NULL,
|
||||
[SeverityId] bigint NULL,
|
||||
[ConnectId] bigint NULL,
|
||||
[Session] bigint NULL,
|
||||
[TransactionStatusId] bigint NULL,
|
||||
[TransactionDate] datetime2 NULL,
|
||||
[TransactionId] bigint NULL,
|
||||
[UserId] bigint NULL,
|
||||
[ComputerId] bigint NULL,
|
||||
[ApplicationId] bigint NULL,
|
||||
[EventId] bigint NULL,
|
||||
[Comment] nvarchar(max) NULL,
|
||||
[MetadataId] bigint NULL,
|
||||
[Data] nvarchar(max) NULL,
|
||||
[DataUUID] nvarchar(450) NULL,
|
||||
[DataPresentation] nvarchar(max) NULL,
|
||||
[WorkServerId] bigint NULL,
|
||||
[PrimaryPortId] bigint NULL,
|
||||
[SecondaryPortId] bigint NULL,
|
||||
CONSTRAINT [PK_RowsData] PRIMARY KEY ([InformationSystemId], [Period], [Id])
|
||||
);
|
||||
|
||||
CREATE TABLE [dbo].[Severities](
|
||||
[InformationSystemId] [bigint] NOT NULL,
|
||||
[Id] [bigint] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](500) NULL,
|
||||
[Presentation] [nvarchar](500) NULL,
|
||||
CONSTRAINT [PK_Severities] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE TABLE [SecondaryPorts] (
|
||||
[InformationSystemId] bigint NOT NULL,
|
||||
[Id] bigint NOT NULL IDENTITY,
|
||||
[Name] nvarchar(250) NULL,
|
||||
CONSTRAINT [PK_SecondaryPorts] PRIMARY KEY ([InformationSystemId], [Id])
|
||||
);
|
||||
|
||||
CREATE TABLE [dbo].[Users](
|
||||
[InformationSystemId] [bigint] NOT NULL,
|
||||
[Id] [bigint] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](500) NULL,
|
||||
[Uuid] [uniqueidentifier] NOT NULL,
|
||||
CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE TABLE [Severities] (
|
||||
[InformationSystemId] bigint NOT NULL,
|
||||
[Id] bigint NOT NULL IDENTITY,
|
||||
[Name] nvarchar(250) NULL,
|
||||
CONSTRAINT [PK_Severities] PRIMARY KEY ([InformationSystemId], [Id])
|
||||
);
|
||||
|
||||
CREATE TABLE [dbo].[WorkServers](
|
||||
[InformationSystemId] [bigint] NOT NULL,
|
||||
[Id] [bigint] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](500) NULL,
|
||||
CONSTRAINT [PK_WorkServers] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE TABLE [TransactionStatuses] (
|
||||
[InformationSystemId] bigint NOT NULL,
|
||||
[Id] bigint NOT NULL IDENTITY,
|
||||
[Name] nvarchar(250) NULL,
|
||||
CONSTRAINT [PK_TransactionStatuses] PRIMARY KEY ([InformationSystemId], [Id])
|
||||
);
|
||||
|
||||
CREATE VIEW [dbo].[vw_EventLog]
|
||||
AS
|
||||
SELECT
|
||||
[RD].[InformationSystemId] AS [InformationSystemId],
|
||||
[IS].[Name] AS [InformationSystemName],
|
||||
[RD].[Period],
|
||||
[RD].[Id] AS [RowId],
|
||||
[RD].[SeverityId] AS [SeverityId],
|
||||
[SV].[Name] AS [SeverityName],
|
||||
[RD].[ConnectId] AS [Connection],
|
||||
[RD].[Session],
|
||||
[RD].[TransactionStatusId],
|
||||
[RD].[TransactionDate],
|
||||
[RD].[TransactionId],
|
||||
[RD].[UserId] AS [UserId],
|
||||
[USR].[Name] AS [UserName],
|
||||
[USR].[Uuid] AS [UserUUID],
|
||||
[RD].[ComputerId] AS [ComputerId],
|
||||
[CMP].[Name] AS [ComputerName],
|
||||
[RD].[Data],
|
||||
[RD].[DataUUID],
|
||||
[RD].[DataPresentation],
|
||||
[RD].[Comment],
|
||||
[RD].[ApplicationId] AS [ApplicationId],
|
||||
[APPS].[Name] AS [ApplicationName],
|
||||
[RD].[EventId] AS [EventId],
|
||||
[EVNT].[Name] AS [EventName],
|
||||
[RD].[MetadataId] AS [MetadataId],
|
||||
[META].[Name] AS [MetadataName],
|
||||
[META].[Uuid] AS [MetadataUUID],
|
||||
[RD].[WorkServerId] AS [WorkServerId],
|
||||
[WSRV].[Name] AS [WorkServerName],
|
||||
[RD].[PrimaryPortId] AS [PrimaryPortId],
|
||||
[PPRT].[Name] AS [PrimaryPortName],
|
||||
[RD].[SecondaryPortId] AS [SecondaryPortId],
|
||||
[SPRT].[Name] AS [SecondaryPortName]
|
||||
FROM [dbo].[RowsData] AS [RD]
|
||||
LEFT JOIN [dbo].[InformationSystems] AS [IS]
|
||||
ON [RD].[InformationSystemId] = [IS].[Id]
|
||||
LEFT JOIN [dbo].[Severities] AS [SV]
|
||||
ON [RD].[InformationSystemId] = [SV].[InformationSystemId]
|
||||
AND [RD].[SeverityId] = [SV].[Id]
|
||||
LEFT JOIN [dbo].[Users] AS [USR]
|
||||
ON [RD].[InformationSystemId] = [USR].[InformationSystemId]
|
||||
AND [RD].[UserId] = [USR].[Id]
|
||||
LEFT JOIN [dbo].[Computers] AS [CMP]
|
||||
ON [RD].[InformationSystemId] = [CMP].[InformationSystemId]
|
||||
AND [RD].[ComputerId] = [CMP].[Id]
|
||||
LEFT JOIN [dbo].[Applications] AS [APPS]
|
||||
ON [RD].[InformationSystemId] = [APPS].[InformationSystemId]
|
||||
AND [RD].[ApplicationId] = [APPS].[Id]
|
||||
LEFT JOIN [dbo].[Events] AS [EVNT]
|
||||
ON [RD].[InformationSystemId] = [EVNT].[InformationSystemId]
|
||||
AND [RD].[EventId] = [EVNT].[Id]
|
||||
LEFT JOIN [dbo].[Metadata] AS [META]
|
||||
ON [RD].[InformationSystemId] = [META].[InformationSystemId]
|
||||
AND [RD].[MetadataId] = [META].[Id]
|
||||
LEFT JOIN [dbo].[WorkServers] AS [WSRV]
|
||||
ON [RD].[InformationSystemId] = [WSRV].[InformationSystemId]
|
||||
AND [RD].[WorkServerId] = [WSRV].[Id]
|
||||
LEFT JOIN [dbo].[PrimaryPorts] AS [PPRT]
|
||||
ON [RD].[InformationSystemId] = [PPRT].[InformationSystemId]
|
||||
AND [RD].[PrimaryPortId] = [PPRT].[Id]
|
||||
LEFT JOIN [dbo].[SecondaryPorts] AS [SPRT]
|
||||
ON [RD].[InformationSystemId] = [SPRT].[InformationSystemId]
|
||||
AND [RD].[SecondaryPortId] = [SPRT].[Id]
|
||||
GO
|
||||
|
||||
CREATE TABLE [Users] (
|
||||
[InformationSystemId] bigint NOT NULL,
|
||||
[Id] bigint NOT NULL IDENTITY,
|
||||
[Uuid] uniqueidentifier NOT NULL,
|
||||
[Name] nvarchar(250) NULL,
|
||||
CONSTRAINT [PK_Users] PRIMARY KEY ([InformationSystemId], [Id])
|
||||
);
|
||||
|
||||
CREATE TABLE [dbo].[LogFiles](
|
||||
[InformationSystemId] [bigint] NOT NULL,
|
||||
[Id] [bigint] IDENTITY(1,1) NOT NULL,
|
||||
[FileName] [nvarchar](max) NULL,
|
||||
[CreateDate] [datetime2](7) NOT NULL,
|
||||
[ModificationDate] [datetime2](7) NOT NULL,
|
||||
[LastEventNumber] [bigint] NOT NULL,
|
||||
[LastCurrentFileReferences] [nvarchar](max) NULL,
|
||||
[LastCurrentFileData] [nvarchar](max) NULL,
|
||||
[LastStreamPosition] [bigint] NULL,
|
||||
CONSTRAINT [PK_LogFiles] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE TABLE [WorkServers] (
|
||||
[InformationSystemId] bigint NOT NULL,
|
||||
[Id] bigint NOT NULL IDENTITY,
|
||||
[Name] nvarchar(250) NULL,
|
||||
CONSTRAINT [PK_WorkServers] PRIMARY KEY ([InformationSystemId], [Id])
|
||||
);
|
||||
|
||||
CREATE TABLE [dbo].[TransactionStatuses](
|
||||
[InformationSystemId] [bigint] NOT NULL,
|
||||
[Id] [bigint] IDENTITY(1,1) NOT NULL,
|
||||
[Name] [nvarchar](500) NULL,
|
||||
[Presentation] [nvarchar](500) NULL,
|
||||
CONSTRAINT [PK_TransactionStatuses] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE INDEX [IX_RowsData_InformationSystemId_DataUUID] ON [RowsData] ([InformationSystemId], [DataUUID]);
|
||||
CREATE NONCLUSTERED INDEX [IX_Applications_InformationSystemId_Name] ON [dbo].[Applications]
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Name] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX [IX_Computers_InformationSystemId_Name] ON [dbo].[Computers]
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Name] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX [IX_Events_InformationSystemId_Name] ON [dbo].[Events]
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Name] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX [IX_Metadata_InformationSystemId_Name_Uuid] ON [dbo].[Metadata]
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Name] ASC,
|
||||
[Uuid] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX [IX_PrimaryPorts_InformationSystemId_Name] ON [dbo].[PrimaryPorts]
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Name] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX [IX_RowsData_InformationSystemId_DataUUID] ON [dbo].[RowsData]
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[DataUUID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE INDEX [IX_RowsData_InformationSystemId_UserId_Period] ON [RowsData] ([InformationSystemId], [UserId], [Period]);
|
||||
|
||||
CREATE NONCLUSTERED INDEX [IX_RowsData_InformationSystemId_UserId_Period] ON [dbo].[RowsData]
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[UserId] ASC,
|
||||
[Period] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
|
||||
VALUES (N'20200509202130_Initialization', N'3.1.3');
|
||||
|
||||
CREATE NONCLUSTERED INDEX [IX_SecondaryPorts_InformationSystemId_Name] ON [dbo].[SecondaryPorts]
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Name] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE NONCLUSTERED INDEX [IX_Severities_InformationSystemId_Name] ON [dbo].[Severities]
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Name] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE NONCLUSTERED INDEX [IX_Users_InformationSystemId_Name_Uuid] ON [dbo].[Users]
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Name] ASC,
|
||||
[Uuid] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
CREATE NONCLUSTERED INDEX [IX_WorkServers_InformationSystemId_Name] ON [dbo].[WorkServers]
|
||||
(
|
||||
[InformationSystemId] ASC,
|
||||
[Name] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
Reference in New Issue
Block a user