using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace CleanArchitecture.Infrastructure.Migrations { /// public partial class AddTenants : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DeleteData( table: "Users", keyColumn: "Id", keyValue: new Guid("28fc3d91-6a15-448e-b0b5-0c91a3948961")); migrationBuilder.AddColumn( name: "TenantId", table: "Users", type: "uniqueidentifier", nullable: false, defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); migrationBuilder.CreateTable( name: "Tenants", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), Name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), Deleted = table.Column(type: "bit", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Tenants", x => x.Id); }); migrationBuilder.InsertData( table: "Tenants", columns: new[] { "Id", "Deleted", "Name" }, values: new object[] { new Guid("b542bf25-134c-47a2-a0df-84ed14d03c4a"), false, "Admin Tenant" }); migrationBuilder.InsertData( table: "Users", columns: new[] { "Id", "Deleted", "Email", "FirstName", "LastName", "Password", "Role", "TenantId" }, values: new object[] { new Guid("7e3892c0-9374-49fa-a3fd-53db637a40ae"), false, "admin@email.com", "Admin", "User", "$2a$12$Blal/uiFIJdYsCLTMUik/egLbfg3XhbnxBC6Sb5IKz2ZYhiU/MzL2", 0, new Guid("b542bf25-134c-47a2-a0df-84ed14d03c4a") }); migrationBuilder.CreateIndex( name: "IX_Users_TenantId", table: "Users", column: "TenantId"); migrationBuilder.AddForeignKey( name: "FK_Users_Tenants_TenantId", table: "Users", column: "TenantId", principalTable: "Tenants", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Users_Tenants_TenantId", table: "Users"); migrationBuilder.DropTable( name: "Tenants"); migrationBuilder.DropIndex( name: "IX_Users_TenantId", table: "Users"); migrationBuilder.DeleteData( table: "Users", keyColumn: "Id", keyValue: new Guid("7e3892c0-9374-49fa-a3fd-53db637a40ae")); migrationBuilder.DropColumn( name: "TenantId", table: "Users"); migrationBuilder.InsertData( table: "Users", columns: new[] { "Id", "Deleted", "Email", "FirstName", "LastName", "Password", "Role" }, values: new object[] { new Guid("28fc3d91-6a15-448e-b0b5-0c91a3948961"), false, "admin@email.com", "Admin", "User", "$2a$12$Blal/uiFIJdYsCLTMUik/egLbfg3XhbnxBC6Sb5IKz2ZYhiU/MzL2", 0 }); } } }