ActiveAllocator/ActiveAllocator.API/Migrations/20240405024649_Integrations.cs

83 lines
3.6 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ActiveAllocator.API.Migrations
{
/// <inheritdoc />
public partial class Integrations : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Integrations",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Version = table.Column<string>(type: "text", nullable: false),
ApiUrl = table.Column<string>(type: "text", nullable: false),
CreatedOn = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Type = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Integrations", x => x.Id);
});
migrationBuilder.CreateTable(
name: "IntegrationAccounts",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
ApiKey = table.Column<string>(type: "text", nullable: false),
CreatedOn = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
IntegrationId = table.Column<int>(type: "integer", nullable: false),
LinkedAccountId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IntegrationAccounts", x => x.Id);
table.ForeignKey(
name: "FK_IntegrationAccounts_Accounts_LinkedAccountId",
column: x => x.LinkedAccountId,
principalTable: "Accounts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_IntegrationAccounts_Integrations_IntegrationId",
column: x => x.IntegrationId,
principalTable: "Integrations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_IntegrationAccounts_IntegrationId",
table: "IntegrationAccounts",
column: "IntegrationId");
migrationBuilder.CreateIndex(
name: "IX_IntegrationAccounts_LinkedAccountId",
table: "IntegrationAccounts",
column: "LinkedAccountId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "IntegrationAccounts");
migrationBuilder.DropTable(
name: "Integrations");
}
}
}