134 lines
6.8 KiB
C#
134 lines
6.8 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace YarpGateway.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class InitialCreate : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "ServiceInstances",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
ClusterId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
DestinationId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
Address = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
|
|
Health = table.Column<int>(type: "integer", nullable: false),
|
|
Weight = table.Column<int>(type: "integer", nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
CreatedBy = table.Column<long>(type: "bigint", nullable: true),
|
|
CreatedTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
|
|
UpdatedTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "boolean", nullable: false),
|
|
Version = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ServiceInstances", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Tenants",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
TenantCode = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
TenantName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
CreatedBy = table.Column<long>(type: "bigint", nullable: true),
|
|
CreatedTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
|
|
UpdatedTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "boolean", nullable: false),
|
|
Version = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Tenants", x => x.Id);
|
|
table.UniqueConstraint("AK_Tenants_TenantCode", x => x.TenantCode);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "TenantRoutes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
TenantCode = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
ServiceName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
ClusterId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
PathPattern = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
|
|
Priority = table.Column<int>(type: "integer", nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
CreatedBy = table.Column<long>(type: "bigint", nullable: true),
|
|
CreatedTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
|
|
UpdatedTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "boolean", nullable: false),
|
|
Version = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_TenantRoutes", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_TenantRoutes_Tenants_TenantCode",
|
|
column: x => x.TenantCode,
|
|
principalTable: "Tenants",
|
|
principalColumn: "TenantCode",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ServiceInstances_ClusterId_DestinationId",
|
|
table: "ServiceInstances",
|
|
columns: new[] { "ClusterId", "DestinationId" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ServiceInstances_Health",
|
|
table: "ServiceInstances",
|
|
column: "Health");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_TenantRoutes_ClusterId",
|
|
table: "TenantRoutes",
|
|
column: "ClusterId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_TenantRoutes_TenantCode_ServiceName",
|
|
table: "TenantRoutes",
|
|
columns: new[] { "TenantCode", "ServiceName" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Tenants_TenantCode",
|
|
table: "Tenants",
|
|
column: "TenantCode",
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "ServiceInstances");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "TenantRoutes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Tenants");
|
|
}
|
|
}
|
|
}
|