using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Moonlight.App.Database.Migrations { /// public partial class AddedNewSubscriptionData : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "CurrentSubscriptionId", table: "Users", type: "int", nullable: true); migrationBuilder.AddColumn( name: "SubscriptionDuration", table: "Users", type: "int", nullable: false, defaultValue: 0); migrationBuilder.AddColumn( name: "SubscriptionSince", table: "Users", type: "datetime(6)", nullable: false, defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); migrationBuilder.CreateTable( name: "Subscriptions", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Name = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Description = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), LimitsJson = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_Subscriptions", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_Users_CurrentSubscriptionId", table: "Users", column: "CurrentSubscriptionId"); migrationBuilder.AddForeignKey( name: "FK_Users_Subscriptions_CurrentSubscriptionId", table: "Users", column: "CurrentSubscriptionId", principalTable: "Subscriptions", principalColumn: "Id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Users_Subscriptions_CurrentSubscriptionId", table: "Users"); migrationBuilder.DropTable( name: "Subscriptions"); migrationBuilder.DropIndex( name: "IX_Users_CurrentSubscriptionId", table: "Users"); migrationBuilder.DropColumn( name: "CurrentSubscriptionId", table: "Users"); migrationBuilder.DropColumn( name: "SubscriptionDuration", table: "Users"); migrationBuilder.DropColumn( name: "SubscriptionSince", table: "Users"); } } }