using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace LANCommander.Migrations { /// public partial class UseCustomIdentityModels : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_UserCustomField_Users_CreatedById", table: "UserCustomField"); migrationBuilder.DropForeignKey( name: "FK_UserCustomField_Users_UpdatedById", table: "UserCustomField"); migrationBuilder.DropColumn( name: "Discriminator", table: "Users"); migrationBuilder.DropColumn( name: "Discriminator", table: "Roles"); migrationBuilder.AlterColumn( name: "RefreshTokenExpiration", table: "Users", type: "TEXT", nullable: false, defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), oldClrType: typeof(DateTime), oldType: "TEXT", oldNullable: true); migrationBuilder.AlterColumn( name: "Approved", table: "Users", type: "INTEGER", nullable: false, defaultValue: false, oldClrType: typeof(bool), oldType: "INTEGER", oldNullable: true); migrationBuilder.AddColumn( name: "CreatedById", table: "Users", type: "TEXT", nullable: true); migrationBuilder.AddColumn( name: "CreatedOn", table: "Users", type: "TEXT", nullable: false, defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); migrationBuilder.AddColumn( name: "UpdatedById", table: "Users", type: "TEXT", nullable: true); migrationBuilder.AddColumn( name: "UpdatedOn", table: "Users", type: "TEXT", nullable: false, defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); migrationBuilder.AddColumn( name: "CreatedById", table: "Roles", type: "TEXT", nullable: true); migrationBuilder.AddColumn( name: "CreatedOn", table: "Roles", type: "TEXT", nullable: false, defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); migrationBuilder.AddColumn( name: "UpdatedById", table: "Roles", type: "TEXT", nullable: true); migrationBuilder.AddColumn( name: "UpdatedOn", table: "Roles", type: "TEXT", nullable: false, defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); migrationBuilder.AddColumn( name: "UserId", table: "Roles", type: "TEXT", nullable: true); migrationBuilder.CreateIndex( name: "IX_Users_CreatedById", table: "Users", column: "CreatedById"); migrationBuilder.CreateIndex( name: "IX_Users_UpdatedById", table: "Users", column: "UpdatedById"); migrationBuilder.CreateIndex( name: "IX_Roles_CreatedById", table: "Roles", column: "CreatedById"); migrationBuilder.CreateIndex( name: "IX_Roles_UpdatedById", table: "Roles", column: "UpdatedById"); migrationBuilder.CreateIndex( name: "IX_Roles_UserId", table: "Roles", column: "UserId"); migrationBuilder.AddForeignKey( name: "FK_Roles_Users_CreatedById", table: "Roles", column: "CreatedById", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.SetNull); migrationBuilder.AddForeignKey( name: "FK_Roles_Users_UpdatedById", table: "Roles", column: "UpdatedById", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.SetNull); migrationBuilder.AddForeignKey( name: "FK_Roles_Users_UserId", table: "Roles", column: "UserId", principalTable: "Users", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_UserCustomField_Users_CreatedById", table: "UserCustomField", column: "CreatedById", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.SetNull); migrationBuilder.AddForeignKey( name: "FK_UserCustomField_Users_UpdatedById", table: "UserCustomField", column: "UpdatedById", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.SetNull); migrationBuilder.AddForeignKey( name: "FK_Users_Users_CreatedById", table: "Users", column: "CreatedById", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.SetNull); migrationBuilder.AddForeignKey( name: "FK_Users_Users_UpdatedById", table: "Users", column: "UpdatedById", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.SetNull); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Roles_Users_CreatedById", table: "Roles"); migrationBuilder.DropForeignKey( name: "FK_Roles_Users_UpdatedById", table: "Roles"); migrationBuilder.DropForeignKey( name: "FK_Roles_Users_UserId", table: "Roles"); migrationBuilder.DropForeignKey( name: "FK_UserCustomField_Users_CreatedById", table: "UserCustomField"); migrationBuilder.DropForeignKey( name: "FK_UserCustomField_Users_UpdatedById", table: "UserCustomField"); migrationBuilder.DropForeignKey( name: "FK_Users_Users_CreatedById", table: "Users"); migrationBuilder.DropForeignKey( name: "FK_Users_Users_UpdatedById", table: "Users"); migrationBuilder.DropIndex( name: "IX_Users_CreatedById", table: "Users"); migrationBuilder.DropIndex( name: "IX_Users_UpdatedById", table: "Users"); migrationBuilder.DropIndex( name: "IX_Roles_CreatedById", table: "Roles"); migrationBuilder.DropIndex( name: "IX_Roles_UpdatedById", table: "Roles"); migrationBuilder.DropIndex( name: "IX_Roles_UserId", table: "Roles"); migrationBuilder.DropColumn( name: "CreatedById", table: "Users"); migrationBuilder.DropColumn( name: "CreatedOn", table: "Users"); migrationBuilder.DropColumn( name: "UpdatedById", table: "Users"); migrationBuilder.DropColumn( name: "UpdatedOn", table: "Users"); migrationBuilder.DropColumn( name: "CreatedById", table: "Roles"); migrationBuilder.DropColumn( name: "CreatedOn", table: "Roles"); migrationBuilder.DropColumn( name: "UpdatedById", table: "Roles"); migrationBuilder.DropColumn( name: "UpdatedOn", table: "Roles"); migrationBuilder.DropColumn( name: "UserId", table: "Roles"); migrationBuilder.AlterColumn( name: "RefreshTokenExpiration", table: "Users", type: "TEXT", nullable: true, oldClrType: typeof(DateTime), oldType: "TEXT"); migrationBuilder.AlterColumn( name: "Approved", table: "Users", type: "INTEGER", nullable: true, oldClrType: typeof(bool), oldType: "INTEGER"); migrationBuilder.AddColumn( name: "Discriminator", table: "Users", type: "TEXT", maxLength: 21, nullable: false, defaultValue: ""); migrationBuilder.AddColumn( name: "Discriminator", table: "Roles", type: "TEXT", maxLength: 21, nullable: false, defaultValue: ""); migrationBuilder.AddForeignKey( name: "FK_UserCustomField_Users_CreatedById", table: "UserCustomField", column: "CreatedById", principalTable: "Users", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_UserCustomField_Users_UpdatedById", table: "UserCustomField", column: "UpdatedById", principalTable: "Users", principalColumn: "Id"); } } }