98 lines
3.2 KiB
C#
98 lines
3.2 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace ManagerService.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddSubscriptionPlanAndQuota : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<long>(
|
|
name: "SizeBytes",
|
|
table: "Resources",
|
|
type: "bigint",
|
|
nullable: false,
|
|
defaultValue: 0L);
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "AiRequestsThisMonth",
|
|
table: "Instances",
|
|
type: "integer",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "AiUsageMonthKey",
|
|
table: "Instances",
|
|
type: "text",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "SubscriptionPlanId",
|
|
table: "Instances",
|
|
type: "text",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SubscriptionPlans",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<string>(type: "text", nullable: false),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
StorageQuotaBytes = table.Column<long>(type: "bigint", nullable: false),
|
|
AiRequestsPerMonth = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SubscriptionPlans", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Instances_SubscriptionPlanId",
|
|
table: "Instances",
|
|
column: "SubscriptionPlanId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Instances_SubscriptionPlans_SubscriptionPlanId",
|
|
table: "Instances",
|
|
column: "SubscriptionPlanId",
|
|
principalTable: "SubscriptionPlans",
|
|
principalColumn: "Id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Instances_SubscriptionPlans_SubscriptionPlanId",
|
|
table: "Instances");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SubscriptionPlans");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Instances_SubscriptionPlanId",
|
|
table: "Instances");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "SizeBytes",
|
|
table: "Resources");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "AiRequestsThisMonth",
|
|
table: "Instances");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "AiUsageMonthKey",
|
|
table: "Instances");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "SubscriptionPlanId",
|
|
table: "Instances");
|
|
}
|
|
}
|
|
}
|