using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CredentialManager.Migrations
{
///
public partial class ReplaceRecordAssociationsWithKeyAssociations : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Credentials",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", maxLength: 100, nullable: false),
Type = table.Column(type: "TEXT", maxLength: 50, nullable: false),
DatabaseType = table.Column(type: "TEXT", maxLength: 50, nullable: true),
ConnectionString = table.Column(type: "TEXT", maxLength: 500, nullable: true),
Host = table.Column(type: "TEXT", maxLength: 200, nullable: true),
Port = table.Column(type: "INTEGER", nullable: true),
DatabaseName = table.Column(type: "TEXT", maxLength: 100, nullable: true),
Username = table.Column(type: "TEXT", maxLength: 100, nullable: true),
EncryptedPassword = table.Column(type: "TEXT", nullable: true),
EncryptedApiKey = table.Column(type: "TEXT", maxLength: 500, nullable: true),
EncryptedAuthToken = table.Column(type: "TEXT", maxLength: 500, nullable: true),
CommandTimeout = table.Column(type: "INTEGER", nullable: false, defaultValue: 30),
TimeoutSeconds = table.Column(type: "INTEGER", nullable: false, defaultValue: 100),
IgnoreSslErrors = table.Column(type: "INTEGER", nullable: false, defaultValue: false),
RestServiceType = table.Column(type: "TEXT", maxLength: 50, nullable: true),
Headers = table.Column(type: "TEXT", maxLength: 2000, nullable: true),
AdditionalParameters = table.Column(type: "TEXT", maxLength: 2000, nullable: true),
CreatedAt = table.Column(type: "TEXT", nullable: false),
UpdatedAt = table.Column(type: "TEXT", nullable: true),
CreatedBy = table.Column(type: "TEXT", maxLength: 100, nullable: true),
IsActive = table.Column(type: "INTEGER", nullable: false, defaultValue: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Credentials", x => x.Id);
});
migrationBuilder.CreateTable(
name: "KeyAssociations",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
KeyValue = table.Column(type: "TEXT", maxLength: 500, nullable: false),
SourceKeyField = table.Column(type: "TEXT", maxLength: 200, nullable: false),
DestinationKeyField = table.Column(type: "TEXT", maxLength: 200, nullable: false),
DestinationEntity = table.Column(type: "TEXT", maxLength: 200, nullable: false),
DestinationId = table.Column(type: "TEXT", maxLength: 200, nullable: false),
RestCredentialName = table.Column(type: "TEXT", maxLength: 100, nullable: false),
CreatedAt = table.Column(type: "TEXT", nullable: false),
UpdatedAt = table.Column(type: "TEXT", nullable: true),
LastVerifiedAt = table.Column(type: "TEXT", nullable: true),
IsActive = table.Column(type: "INTEGER", nullable: false, defaultValue: true),
SourcesInfo = table.Column(type: "TEXT", maxLength: 2000, nullable: true),
AdditionalInfo = table.Column(type: "TEXT", maxLength: 2000, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_KeyAssociations", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Credentials_DatabaseType",
table: "Credentials",
column: "DatabaseType");
migrationBuilder.CreateIndex(
name: "IX_Credentials_IsActive",
table: "Credentials",
column: "IsActive");
migrationBuilder.CreateIndex(
name: "IX_Credentials_Name",
table: "Credentials",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Credentials_Type",
table: "Credentials",
column: "Type");
migrationBuilder.CreateIndex(
name: "IX_KeyAssociations_CreatedAt",
table: "KeyAssociations",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_KeyAssociations_DestinationEntity",
table: "KeyAssociations",
column: "DestinationEntity");
migrationBuilder.CreateIndex(
name: "IX_KeyAssociations_IsActive",
table: "KeyAssociations",
column: "IsActive");
migrationBuilder.CreateIndex(
name: "IX_KeyAssociations_KeyValue",
table: "KeyAssociations",
column: "KeyValue");
migrationBuilder.CreateIndex(
name: "IX_KeyAssociations_LastVerifiedAt",
table: "KeyAssociations",
column: "LastVerifiedAt");
migrationBuilder.CreateIndex(
name: "IX_KeyAssociations_RestCredentialName",
table: "KeyAssociations",
column: "RestCredentialName");
migrationBuilder.CreateIndex(
name: "IX_KeyAssociations_Unique",
table: "KeyAssociations",
columns: new[] { "KeyValue", "DestinationEntity", "RestCredentialName" },
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Credentials");
migrationBuilder.DropTable(
name: "KeyAssociations");
}
}
}