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

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');