Добавил скрипты для создания баз данных вручную

This commit is contained in:
YPermitin
2020-05-10 15:57:47 +05:00
parent 9d6e763821
commit c3c3278c17
3 changed files with 329 additions and 0 deletions
@@ -0,0 +1,156 @@
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 "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 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 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 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 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 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 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 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 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 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 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 "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 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 "IX_Applications_InformationSystemId_Id" ON "Applications" ("InformationSystemId", "Id");
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');
@@ -0,0 +1,167 @@
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;
GO
CREATE TABLE [Applications] (
[InformationSystemId] bigint NOT NULL,
[Id] bigint NOT NULL IDENTITY,
[Name] nvarchar(250) NULL,
CONSTRAINT [PK_Applications] PRIMARY KEY ([InformationSystemId], [Id])
);
GO
CREATE TABLE [Computers] (
[InformationSystemId] bigint NOT NULL,
[Id] bigint NOT NULL IDENTITY,
[Name] nvarchar(250) NULL,
CONSTRAINT [PK_Computers] PRIMARY KEY ([InformationSystemId], [Id])
);
GO
CREATE TABLE [Events] (
[InformationSystemId] bigint NOT NULL,
[Id] bigint NOT NULL IDENTITY,
[Name] nvarchar(250) NULL,
CONSTRAINT [PK_Events] PRIMARY KEY ([InformationSystemId], [Id])
);
GO
CREATE TABLE [InformationSystems] (
[Id] bigint NOT NULL IDENTITY,
[Name] nvarchar(250) NULL,
[Description] nvarchar(500) NULL,
CONSTRAINT [PK_InformationSystems] PRIMARY KEY ([Id])
);
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])
);
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])
);
GO
CREATE TABLE [PrimaryPorts] (
[InformationSystemId] bigint NOT NULL,
[Id] bigint NOT NULL IDENTITY,
[Name] nvarchar(250) NULL,
CONSTRAINT [PK_PrimaryPorts] PRIMARY KEY ([InformationSystemId], [Id])
);
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])
);
GO
CREATE TABLE [SecondaryPorts] (
[InformationSystemId] bigint NOT NULL,
[Id] bigint NOT NULL IDENTITY,
[Name] nvarchar(250) NULL,
CONSTRAINT [PK_SecondaryPorts] PRIMARY KEY ([InformationSystemId], [Id])
);
GO
CREATE TABLE [Severities] (
[InformationSystemId] bigint NOT NULL,
[Id] bigint NOT NULL IDENTITY,
[Name] nvarchar(250) NULL,
CONSTRAINT [PK_Severities] PRIMARY KEY ([InformationSystemId], [Id])
);
GO
CREATE TABLE [TransactionStatuses] (
[InformationSystemId] bigint NOT NULL,
[Id] bigint NOT NULL IDENTITY,
[Name] nvarchar(250) NULL,
CONSTRAINT [PK_TransactionStatuses] PRIMARY KEY ([InformationSystemId], [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])
);
GO
CREATE TABLE [WorkServers] (
[InformationSystemId] bigint NOT NULL,
[Id] bigint NOT NULL IDENTITY,
[Name] nvarchar(250) NULL,
CONSTRAINT [PK_WorkServers] PRIMARY KEY ([InformationSystemId], [Id])
);
GO
CREATE INDEX [IX_RowsData_InformationSystemId_DataUUID] ON [RowsData] ([InformationSystemId], [DataUUID]);
GO
CREATE INDEX [IX_RowsData_InformationSystemId_UserId_Period] ON [RowsData] ([InformationSystemId], [UserId], [Period]);
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20200509202130_Initialization', N'3.1.3');
GO
+6
View File
@@ -40,6 +40,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YY.EventLogExportToSQLServe
{2B04B71E-4785-401C-AED7-751A1C0B7DB1} = {2B04B71E-4785-401C-AED7-751A1C0B7DB1}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scripts", "Scripts", "{AF6C4D18-9F7B-4E44-9531-A191AA6F725E}"
ProjectSection(SolutionItems) = preProject
Scripts\PostgreSQL. Скрипт создания базы для хранения данных журнала регистрации.sql = Scripts\PostgreSQL. Скрипт создания базы для хранения данных журнала регистрации.sql
Scripts\SQL Server. Скрипт создания базы для хранения данных журнала регистрации.sql = Scripts\SQL Server. Скрипт создания базы для хранения данных журнала регистрации.sql
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU