diff --git a/src/Ombi.Store/Migrations/OmbiMySql/20200731151314_RemoveEmbyConnectionid.cs b/src/Ombi.Store/Migrations/OmbiMySql/20200731151314_RemoveEmbyConnectionid.cs index 80d93c543..35fd4fa8a 100644 --- a/src/Ombi.Store/Migrations/OmbiMySql/20200731151314_RemoveEmbyConnectionid.cs +++ b/src/Ombi.Store/Migrations/OmbiMySql/20200731151314_RemoveEmbyConnectionid.cs @@ -9,6 +9,7 @@ namespace Ombi.Store.Migrations.OmbiMySql migrationBuilder.DropColumn( name: "EmbyConnectUserId", table: "AspNetUsers"); + migrationBuilder.Sql("UPDATE AspNetUsers SET UserType = 4 WHERE EmbyConnectUserId IS NOT NULL"); } protected override void Down(MigrationBuilder migrationBuilder) diff --git a/src/Ombi.Store/Migrations/OmbiSqlite/20200731151356_RemoveEmbyConnectionid.cs b/src/Ombi.Store/Migrations/OmbiSqlite/20200731151356_RemoveEmbyConnectionid.cs index a811f1685..0549a9f25 100644 --- a/src/Ombi.Store/Migrations/OmbiSqlite/20200731151356_RemoveEmbyConnectionid.cs +++ b/src/Ombi.Store/Migrations/OmbiSqlite/20200731151356_RemoveEmbyConnectionid.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore.Migrations; +using System; namespace Ombi.Store.Migrations.OmbiSqlite { @@ -6,9 +7,52 @@ namespace Ombi.Store.Migrations.OmbiSqlite { protected override void Up(MigrationBuilder migrationBuilder) { - migrationBuilder.DropColumn( - name: "EmbyConnectUserId", - table: "AspNetUsers"); + //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)