From b89ae349ca4f6b162afd468adabe840f1f9cf007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=A4felfinger?= Date: Thu, 6 Feb 2020 23:09:24 +0100 Subject: [PATCH] addes migration for sqlite to make sure the new id field is text --- ...06214445_DotnetCore3_1_upgrade.Designer.cs | 75 +++++++++++++++++++ .../20200206214445_DotnetCore3_1_upgrade.cs | 73 ++++++++++++++++++ .../PlaylistContextModelSnapshot.cs | 41 ++++++---- Tv7Playlist.Data/Tv7Playlist.Data.csproj | 2 +- 4 files changed, 176 insertions(+), 15 deletions(-) create mode 100644 Tv7Playlist.Data/Migrations/20200206214445_DotnetCore3_1_upgrade.Designer.cs create mode 100644 Tv7Playlist.Data/Migrations/20200206214445_DotnetCore3_1_upgrade.cs diff --git a/Tv7Playlist.Data/Migrations/20200206214445_DotnetCore3_1_upgrade.Designer.cs b/Tv7Playlist.Data/Migrations/20200206214445_DotnetCore3_1_upgrade.Designer.cs new file mode 100644 index 0000000..55aa331 --- /dev/null +++ b/Tv7Playlist.Data/Migrations/20200206214445_DotnetCore3_1_upgrade.Designer.cs @@ -0,0 +1,75 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Tv7Playlist.Data; + +namespace Tv7Playlist.Data.Migrations +{ + [DbContext(typeof(PlaylistContext))] + [Migration("20200206214445_DotnetCore3_1_upgrade")] + partial class DotnetCore3_1_upgrade + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "3.1.1"); + + modelBuilder.Entity("Tv7Playlist.Data.PlaylistEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("ChannelNumberExport") + .HasColumnType("INTEGER"); + + b.Property("ChannelNumberImport") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("EpgMatchName") + .HasColumnType("TEXT"); + + b.Property("IsAvailable") + .HasColumnType("INTEGER"); + + b.Property("IsEnabled") + .HasColumnType("INTEGER"); + + b.Property("LogoUrl") + .HasColumnType("TEXT"); + + b.Property("Modified") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Position") + .HasColumnType("INTEGER"); + + b.Property("UrlOriginal") + .HasColumnType("TEXT"); + + b.Property("UrlProxy") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ChannelNumberImport") + .IsUnique(); + + b.HasIndex("Name"); + + b.ToTable("PlaylistEntries"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Tv7Playlist.Data/Migrations/20200206214445_DotnetCore3_1_upgrade.cs b/Tv7Playlist.Data/Migrations/20200206214445_DotnetCore3_1_upgrade.cs new file mode 100644 index 0000000..dbca141 --- /dev/null +++ b/Tv7Playlist.Data/Migrations/20200206214445_DotnetCore3_1_upgrade.cs @@ -0,0 +1,73 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Tv7Playlist.Data.Migrations +{ + public partial class DotnetCore3_1_upgrade : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + "PlaylistEntriesTemp", + table => new + { + Id = table.Column(), + Position = table.Column(), + ChannelNumberImport = table.Column(), + ChannelNumberExport = table.Column(), + Name = table.Column(nullable: true), + EpgMatchName = table.Column(nullable: true), + UrlProxy = table.Column(nullable: true), + UrlOriginal = table.Column(nullable: true), + LogoUrl = table.Column(nullable: true), + IsAvailable = table.Column(), + IsEnabled = table.Column(), + Created = table.Column(), + Modified = table.Column() + }); + + migrationBuilder.Sql("INSERT INTO PlaylistEntriesTemp SELECT * From PlaylistEntries"); + + migrationBuilder.DropTable("PlaylistEntries"); + + migrationBuilder.CreateTable( + "PlaylistEntries", + table => new + { + Id = table.Column(), + Position = table.Column(), + ChannelNumberImport = table.Column(), + ChannelNumberExport = table.Column(), + Name = table.Column(nullable: true), + EpgMatchName = table.Column(nullable: true), + UrlProxy = table.Column(nullable: true), + UrlOriginal = table.Column(nullable: true), + LogoUrl = table.Column(nullable: true), + IsAvailable = table.Column(), + IsEnabled = table.Column(), + Created = table.Column(), + Modified = table.Column() + }, + constraints: table => { table.PrimaryKey("PK_PlaylistEntries", x => x.Id); }); + + migrationBuilder.Sql("INSERT INTO PlaylistEntries SELECT * From PlaylistEntriesTemp"); + + migrationBuilder.CreateIndex( + "IX_PlaylistEntries_ChannelNumberImport", + "PlaylistEntries", + "ChannelNumberImport", + unique: true); + + migrationBuilder.CreateIndex( + "IX_PlaylistEntries_Name", + "PlaylistEntries", + "Name"); + + migrationBuilder.DropTable("PlaylistEntriesTemp"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + } + } +} \ No newline at end of file diff --git a/Tv7Playlist.Data/Migrations/PlaylistContextModelSnapshot.cs b/Tv7Playlist.Data/Migrations/PlaylistContextModelSnapshot.cs index c708c93..017e9d7 100644 --- a/Tv7Playlist.Data/Migrations/PlaylistContextModelSnapshot.cs +++ b/Tv7Playlist.Data/Migrations/PlaylistContextModelSnapshot.cs @@ -14,36 +14,49 @@ namespace Tv7Playlist.Data.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.1-servicing-10028"); + .HasAnnotation("ProductVersion", "3.1.1"); modelBuilder.Entity("Tv7Playlist.Data.PlaylistEntry", b => { b.Property("Id") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); - b.Property("ChannelNumberExport"); + b.Property("ChannelNumberExport") + .HasColumnType("INTEGER"); - b.Property("ChannelNumberImport"); + b.Property("ChannelNumberImport") + .HasColumnType("INTEGER"); - b.Property("Created"); + b.Property("Created") + .HasColumnType("TEXT"); - b.Property("EpgMatchName"); + b.Property("EpgMatchName") + .HasColumnType("TEXT"); - b.Property("IsAvailable"); + b.Property("IsAvailable") + .HasColumnType("INTEGER"); - b.Property("IsEnabled"); + b.Property("IsEnabled") + .HasColumnType("INTEGER"); - b.Property("LogoUrl"); + b.Property("LogoUrl") + .HasColumnType("TEXT"); - b.Property("Modified"); + b.Property("Modified") + .HasColumnType("TEXT"); - b.Property("Name"); + b.Property("Name") + .HasColumnType("TEXT"); - b.Property("Position"); + b.Property("Position") + .HasColumnType("INTEGER"); - b.Property("UrlOriginal"); + b.Property("UrlOriginal") + .HasColumnType("TEXT"); - b.Property("UrlProxy"); + b.Property("UrlProxy") + .HasColumnType("TEXT"); b.HasKey("Id"); diff --git a/Tv7Playlist.Data/Tv7Playlist.Data.csproj b/Tv7Playlist.Data/Tv7Playlist.Data.csproj index d410207..08b2509 100644 --- a/Tv7Playlist.Data/Tv7Playlist.Data.csproj +++ b/Tv7Playlist.Data/Tv7Playlist.Data.csproj @@ -1,8 +1,8 @@  - netstandard2.1 latest + netstandard2.1