using Microsoft.EntityFrameworkCore.Migrations; using System; namespace Ombi.Store.Migrations.OmbiSqlite { public partial class RemoveEmbyConnectionid : Migration { protected override void Up(MigrationBuilder migrationBuilder) { //migrationBuilder.DropColumn( // name: "EmbyConnectUserId", // table: "AspNetUsers"); migrationBuilder.CreateTable( name: "AspNetUsers_New", columns: table => new { Id = table.Column(nullable: false), UserName = table.Column(maxLength: 256, nullable: true), NormalizedUserName = table.Column(maxLength: 256, nullable: true), Email = table.Column(maxLength: 256, nullable: true), NormalizedEmail = table.Column(maxLength: 256, nullable: true), EmailConfirmed = table.Column(nullable: false), PhoneNumber = table.Column(nullable: true), PhoneNumberConfirmed = table.Column(nullable: false), TwoFactorEnabled = table.Column(nullable: false), LockoutEnd = table.Column(nullable: true), LockoutEnabled = table.Column(nullable: false), AccessFailedCount = table.Column(nullable: false), Alias = table.Column(nullable: true), UserType = table.Column(nullable: false), ProviderUserId = table.Column(nullable: true), LastLoggedIn = table.Column(nullable: true), MovieRequestLimit = table.Column(nullable: true), EpisodeRequestLimit = table.Column(nullable: true), MusicRequestLimit = table.Column(nullable: true), UserAccessToken = table.Column(nullable: true), PasswordHash = table.Column(nullable: true), SecurityStamp = table.Column(nullable: true), ConcurrencyStamp = table.Column(nullable: true), Language = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUsers", x => x.Id); }); migrationBuilder.Sql("UPDATE AspNetUsers SET UserType = 4 WHERE EmbyConnectUserId IS NOT NULL"); migrationBuilder.Sql(@"INSERT INTO AspNetUsers_New SELECT `Id`,`UserName`,`NormalizedUserName`,`Email`,`NormalizedEmail`,`EmailConfirmed`,`PhoneNumber`, `PhoneNumberConfirmed`,`TwoFactorEnabled`,`LockoutEnd`,`LockoutEnabled`,`AccessFailedCount`,`Alias`,`UserType`,`ProviderUserId`,`LastLoggedIn`,`MovieRequestLimit`, `EpisodeRequestLimit`,`MusicRequestLimit`,`UserAccessToken`,`PasswordHash`,`SecurityStamp`,`ConcurrencyStamp`,`Language` FROM AspNetUsers;"); migrationBuilder.Sql("PRAGMA foreign_keys=\"0\"", true); migrationBuilder.Sql("DROP TABLE AspNetUsers", true); migrationBuilder.Sql("ALTER TABLE AspNetUsers_New RENAME TO AspNetUsers", true); migrationBuilder.Sql("PRAGMA foreign_keys=\"1\"", true); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "EmbyConnectUserId", table: "AspNetUsers", type: "TEXT", nullable: true); } } }