From 6ced620dc7508d0611957dca70997cc51200d181 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Wed, 15 Aug 2018 12:53:05 -0500 Subject: [PATCH] fix up timestamp issues with ef code-first --- ...1_fixTimestampNullsAndDefaults.Designer.cs | 592 ++++++++++++++++++ ...0815174531_fixTimestampNullsAndDefaults.cs | 476 ++++++++++++++ .../FilterListsDbContextModelSnapshot.cs | 212 ++++--- src/FilterLists.Data/Entities/BaseEntity.cs | 4 +- src/FilterLists.Data/Entities/IBaseEntity.cs | 2 +- .../Entities/Junctions/BaseJunctionEntity.cs | 2 +- .../Entities/Junctions/SnapshotRule.cs | 2 +- .../BaseEntityTypeConfiguration.cs | 8 +- .../BaseJunctionTypeConfiguration.cs | 6 +- .../SnapshotRuleTypeConfiguration.cs | 4 +- .../SnapshotTypeConfiguration.cs | 2 - 11 files changed, 1217 insertions(+), 93 deletions(-) create mode 100644 src/FilterLists.Api/Migrations/20180815174531_fixTimestampNullsAndDefaults.Designer.cs create mode 100644 src/FilterLists.Api/Migrations/20180815174531_fixTimestampNullsAndDefaults.cs diff --git a/src/FilterLists.Api/Migrations/20180815174531_fixTimestampNullsAndDefaults.Designer.cs b/src/FilterLists.Api/Migrations/20180815174531_fixTimestampNullsAndDefaults.Designer.cs new file mode 100644 index 000000000..587e8795c --- /dev/null +++ b/src/FilterLists.Api/Migrations/20180815174531_fixTimestampNullsAndDefaults.Designer.cs @@ -0,0 +1,592 @@ +// + +using System; +using FilterLists.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace FilterLists.Api.Migrations +{ + [DbContext(typeof(FilterListsDbContext))] + [Migration("20180815174531_fixTimestampNullsAndDefaults")] + partial class fixTimestampNullsAndDefaults + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.1.1-rtm-30846") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("SMALLINT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + b.Property("ChatUrl") + .HasColumnType("TEXT"); + + b.Property("CreatedDateUtc") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("DescriptionSourceUrl") + .HasColumnType("TEXT"); + + b.Property("DiscontinuedDate") + .ValueGeneratedOnAdd() + .HasColumnType("DATE") + .HasDefaultValueSql("NULL"); + + b.Property("DonateUrl") + .HasColumnType("TEXT"); + + b.Property("EmailAddress") + .ValueGeneratedOnAdd() + .HasColumnType("VARCHAR(126)") + .HasDefaultValueSql("NULL"); + + b.Property("ForumUrl") + .HasColumnType("TEXT"); + + b.Property("HomeUrl") + .HasColumnType("TEXT"); + + b.Property("IssuesUrl") + .HasColumnType("TEXT"); + + b.Property("LicenseId") + .ValueGeneratedOnAdd() + .HasDefaultValue((byte)5); + + b.Property("ModifiedDateUtc") + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); + + b.Property("Name") + .IsRequired() + .HasColumnType("VARCHAR(126)"); + + b.Property("PolicyUrl") + .HasColumnType("TEXT"); + + b.Property("PublishedDate") + .ValueGeneratedOnAdd() + .HasColumnType("DATE") + .HasDefaultValueSql("NULL"); + + b.Property("SubmissionUrl") + .HasColumnType("TEXT"); + + b.Property("SyntaxId"); + + b.Property("ViewUrl") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("LicenseId"); + + b.HasIndex("SyntaxId"); + + b.ToTable("filterlists"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Junctions.FilterListLanguage", b => + { + b.Property("FilterListId"); + + b.Property("LanguageId"); + + b.Property("CreatedDateUtc") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); + + b.HasKey("FilterListId", "LanguageId"); + + b.HasIndex("LanguageId"); + + b.ToTable("filterlists_languages"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Junctions.FilterListMaintainer", b => + { + b.Property("FilterListId"); + + b.Property("MaintainerId"); + + b.Property("CreatedDateUtc") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); + + b.HasKey("FilterListId", "MaintainerId"); + + b.HasIndex("MaintainerId"); + + b.ToTable("filterlists_maintainers"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Fork", b => + { + b.Property("ForkFilterListId"); + + b.Property("UpstreamFilterListId"); + + b.Property("CreatedDateUtc") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); + + b.HasKey("ForkFilterListId", "UpstreamFilterListId"); + + b.HasIndex("UpstreamFilterListId"); + + b.ToTable("forks"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Merge", b => + { + b.Property("MergeFilterListId"); + + b.Property("UpstreamFilterListId"); + + b.Property("CreatedDateUtc") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); + + b.HasKey("MergeFilterListId", "UpstreamFilterListId"); + + b.HasIndex("UpstreamFilterListId"); + + b.ToTable("merges"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SnapshotRule", b => + { + b.Property("AddedBySnapshotId"); + + b.Property("RuleId"); + + b.Property("CreatedDateUtc") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); + + b.Property("ModifiedDateUtc") + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); + + b.Property("RemovedBySnapshotId"); + + b.HasKey("AddedBySnapshotId", "RuleId"); + + b.HasIndex("RemovedBySnapshotId"); + + b.HasIndex("RuleId"); + + b.ToTable("snapshots_rules"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SoftwareSyntax", b => + { + b.Property("SyntaxId"); + + b.Property("SoftwareId"); + + b.Property("CreatedDateUtc") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); + + b.HasKey("SyntaxId", "SoftwareId"); + + b.HasIndex("SoftwareId"); + + b.ToTable("software_syntaxes"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Language", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("SMALLINT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + b.Property("CreatedDateUtc") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); + + b.Property("Iso6391") + .ValueGeneratedOnAdd() + .HasColumnType("VARCHAR(2)") + .HasDefaultValueSql("NULL"); + + b.Property("Iso6392") + .ValueGeneratedOnAdd() + .HasColumnType("VARCHAR(3)") + .HasDefaultValueSql("NULL"); + + b.Property("Iso6392B") + .ValueGeneratedOnAdd() + .HasColumnType("VARCHAR(3)") + .HasDefaultValueSql("NULL"); + + b.Property("Iso6392T") + .ValueGeneratedOnAdd() + .HasColumnType("VARCHAR(3)") + .HasDefaultValueSql("NULL"); + + b.Property("Iso6393") + .ValueGeneratedOnAdd() + .HasColumnType("VARCHAR(3)") + .HasDefaultValueSql("NULL"); + + b.Property("LocalName") + .ValueGeneratedOnAdd() + .HasColumnType("VARCHAR(126)") + .HasDefaultValueSql("NULL"); + + b.Property("ModifiedDateUtc") + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); + + b.Property("Name") + .ValueGeneratedOnAdd() + .HasColumnType("VARCHAR(126)") + .HasDefaultValueSql("NULL"); + + b.HasKey("Id"); + + b.ToTable("languages"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.License", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TINYINT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + b.Property("CreatedDateUtc") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); + + b.Property("DescriptionUrl") + .HasColumnType("TEXT"); + + b.Property("ModifiedDateUtc") + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); + + b.Property("Name") + .IsRequired() + .HasColumnType("VARCHAR(126)"); + + b.Property("PermissiveAdaptation"); + + b.Property("PermissiveCommercial"); + + b.HasKey("Id"); + + b.ToTable("licenses"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Maintainer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("SMALLINT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + b.Property("CreatedDateUtc") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); + + b.Property("EmailAddress") + .ValueGeneratedOnAdd() + .HasColumnType("VARCHAR(126)") + .HasDefaultValueSql("NULL"); + + b.Property("HomeUrl") + .HasColumnType("TEXT"); + + b.Property("ModifiedDateUtc") + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); + + b.Property("Name") + .IsRequired() + .HasColumnType("VARCHAR(126)"); + + b.Property("TwitterHandle") + .ValueGeneratedOnAdd() + .HasColumnType("VARCHAR(126)") + .HasDefaultValueSql("NULL"); + + b.HasKey("Id"); + + b.ToTable("maintainers"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Rule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + b.Property("CreatedDateUtc") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); + + b.Property("Raw") + .IsRequired() + .HasColumnType("VARCHAR(8192)"); + + b.HasKey("Id"); + + b.ToTable("rules"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Snapshot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("MEDIUMINT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + b.Property("CreatedDateUtc") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); + + b.Property("FilterListId"); + + b.Property("HttpStatusCode") + .ValueGeneratedOnAdd() + .HasColumnType("VARCHAR(3)") + .HasDefaultValueSql("NULL"); + + b.Property("IsCompleted"); + + b.Property("ModifiedDateUtc") + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); + + b.HasKey("Id"); + + b.HasIndex("FilterListId"); + + b.ToTable("snapshots"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Software", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TINYINT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + b.Property("CreatedDateUtc") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); + + b.Property("DownloadUrl") + .HasColumnType("TEXT"); + + b.Property("HomeUrl") + .HasColumnType("TEXT"); + + b.Property("ModifiedDateUtc") + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); + + b.Property("Name") + .IsRequired() + .HasColumnType("VARCHAR(126)"); + + b.HasKey("Id"); + + b.ToTable("software"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Syntax", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TINYINT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + b.Property("CreatedDateUtc") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); + + b.Property("DefinitionUrl") + .HasColumnType("TEXT"); + + b.Property("ModifiedDateUtc") + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); + + b.Property("Name") + .IsRequired() + .HasColumnType("VARCHAR(126)"); + + b.HasKey("Id"); + + b.ToTable("syntaxes"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b => + { + b.HasOne("FilterLists.Data.Entities.License", "License") + .WithMany("FilterLists") + .HasForeignKey("LicenseId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("FilterLists.Data.Entities.Syntax", "Syntax") + .WithMany("FilterLists") + .HasForeignKey("SyntaxId"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Junctions.FilterListLanguage", b => + { + b.HasOne("FilterLists.Data.Entities.FilterList", "FilterList") + .WithMany("FilterListLanguages") + .HasForeignKey("FilterListId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("FilterLists.Data.Entities.Language", "Language") + .WithMany("FilterListLanguages") + .HasForeignKey("LanguageId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Junctions.FilterListMaintainer", b => + { + b.HasOne("FilterLists.Data.Entities.FilterList", "FilterList") + .WithMany("FilterListMaintainers") + .HasForeignKey("FilterListId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("FilterLists.Data.Entities.Maintainer", "Maintainer") + .WithMany("FilterListMaintainers") + .HasForeignKey("MaintainerId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Fork", b => + { + b.HasOne("FilterLists.Data.Entities.FilterList", "ForkFilterList") + .WithMany("ForkFilterLists") + .HasForeignKey("ForkFilterListId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("FilterLists.Data.Entities.FilterList", "UpstreamFilterList") + .WithMany("UpstreamForkFilterLists") + .HasForeignKey("UpstreamFilterListId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Merge", b => + { + b.HasOne("FilterLists.Data.Entities.FilterList", "MergeFilterList") + .WithMany("MergeFilterLists") + .HasForeignKey("MergeFilterListId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("FilterLists.Data.Entities.FilterList", "UpstreamFilterList") + .WithMany("UpstreamMergeFilterLists") + .HasForeignKey("UpstreamFilterListId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SnapshotRule", b => + { + b.HasOne("FilterLists.Data.Entities.Snapshot", "AddedBySnapshot") + .WithMany("AddedSnapshotRules") + .HasForeignKey("AddedBySnapshotId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("FilterLists.Data.Entities.Snapshot", "RemovedBySnapshot") + .WithMany("RemovedSnapshotRules") + .HasForeignKey("RemovedBySnapshotId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("FilterLists.Data.Entities.Rule", "Rule") + .WithMany("SnapshotRules") + .HasForeignKey("RuleId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SoftwareSyntax", b => + { + b.HasOne("FilterLists.Data.Entities.Software", "Software") + .WithMany("SoftwareSyntaxes") + .HasForeignKey("SoftwareId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("FilterLists.Data.Entities.Syntax", "Syntax") + .WithMany("SoftwareSyntaxes") + .HasForeignKey("SyntaxId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Snapshot", b => + { + b.HasOne("FilterLists.Data.Entities.FilterList", "FilterList") + .WithMany("Snapshots") + .HasForeignKey("FilterListId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} \ No newline at end of file diff --git a/src/FilterLists.Api/Migrations/20180815174531_fixTimestampNullsAndDefaults.cs b/src/FilterLists.Api/Migrations/20180815174531_fixTimestampNullsAndDefaults.cs new file mode 100644 index 000000000..cea310be7 --- /dev/null +++ b/src/FilterLists.Api/Migrations/20180815174531_fixTimestampNullsAndDefaults.cs @@ -0,0 +1,476 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace FilterLists.Api.Migrations +{ + public partial class fixTimestampNullsAndDefaults : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "syntaxes", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp() ON UPDATE current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "syntaxes", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "software_syntaxes", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "software", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp() ON UPDATE current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "software", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "snapshots_rules", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp() ON UPDATE current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "snapshots_rules", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "snapshots", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp() ON UPDATE current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "CURRENT_TIMESTAMP()"); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "snapshots", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "rules", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "merges", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "maintainers", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp() ON UPDATE current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "maintainers", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "licenses", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp() ON UPDATE current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "licenses", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "languages", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp() ON UPDATE current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "languages", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "forks", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "filterlists_maintainers", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "filterlists_languages", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "filterlists", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp() ON UPDATE current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "filterlists", + "TIMESTAMP", + nullable: false, + defaultValueSql: "current_timestamp()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP") + .OldAnnotation("MySql:ValueGenerationStrategy", + MySqlValueGenerationStrategy.IdentityColumn); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "syntaxes", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp() ON UPDATE current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "syntaxes", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "software_syntaxes", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "software", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp() ON UPDATE current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "software", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "snapshots_rules", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp() ON UPDATE current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "snapshots_rules", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "snapshots", + "TIMESTAMP", + nullable: false, + defaultValueSql: "CURRENT_TIMESTAMP()", + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp() ON UPDATE current_timestamp()"); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "snapshots", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "rules", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "merges", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "maintainers", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp() ON UPDATE current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "maintainers", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "licenses", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp() ON UPDATE current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "licenses", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "languages", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp() ON UPDATE current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "languages", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "forks", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "filterlists_maintainers", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "filterlists_languages", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + "ModifiedDateUtc", + "filterlists", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp() ON UPDATE current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + "CreatedDateUtc", + "filterlists", + "TIMESTAMP", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "TIMESTAMP", + oldDefaultValueSql: "current_timestamp()") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + } + } +} \ No newline at end of file diff --git a/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs b/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs index d6c93c1bc..18ff9a2e3 100644 --- a/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs +++ b/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs @@ -2,14 +2,12 @@ using System; using FilterLists.Data; -using JetBrains.Annotations; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; namespace FilterLists.Api.Migrations { - [UsedImplicitly] [DbContext(typeof(FilterListsDbContext))] internal class FilterListsDbContextModelSnapshot : ModelSnapshot { @@ -17,21 +15,24 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn) - .HasAnnotation("ProductVersion", "2.0.2-rtm-10011"); + .HasAnnotation("ProductVersion", "2.1.1-rtm-30846") + .HasAnnotation("Relational:MaxIdentifierLength", 64); modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("SMALLINT UNSIGNED"); + .HasColumnType("SMALLINT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); b.Property("ChatUrl") .HasColumnType("TEXT"); - b.Property("CreatedDateUtc") + b.Property("CreatedDateUtc") + .IsRequired() .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); b.Property("Description") .HasColumnType("TEXT"); @@ -61,14 +62,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("IssuesUrl") .HasColumnType("TEXT"); - b.Property("LicenseId") - .IsRequired() + b.Property("LicenseId") .ValueGeneratedOnAdd() - .HasDefaultValue(5); + .HasDefaultValue((byte)5); - b.Property("ModifiedDateUtc") + b.Property("ModifiedDateUtc") + .IsRequired() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); b.Property("Name") .IsRequired() @@ -85,7 +87,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("SubmissionUrl") .HasColumnType("TEXT"); - b.Property("SyntaxId"); + b.Property("SyntaxId"); b.Property("ViewUrl") .HasColumnType("TEXT"); @@ -101,13 +103,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Junctions.FilterListLanguage", b => { - b.Property("FilterListId"); + b.Property("FilterListId"); - b.Property("LanguageId"); + b.Property("LanguageId"); - b.Property("CreatedDateUtc") + b.Property("CreatedDateUtc") + .IsRequired() .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); b.HasKey("FilterListId", "LanguageId"); @@ -118,13 +122,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Junctions.FilterListMaintainer", b => { - b.Property("FilterListId"); + b.Property("FilterListId"); - b.Property("MaintainerId"); + b.Property("MaintainerId"); - b.Property("CreatedDateUtc") + b.Property("CreatedDateUtc") + .IsRequired() .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); b.HasKey("FilterListId", "MaintainerId"); @@ -135,13 +141,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Fork", b => { - b.Property("ForkFilterListId"); + b.Property("ForkFilterListId"); - b.Property("UpstreamFilterListId"); + b.Property("UpstreamFilterListId"); - b.Property("CreatedDateUtc") + b.Property("CreatedDateUtc") + .IsRequired() .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); b.HasKey("ForkFilterListId", "UpstreamFilterListId"); @@ -152,13 +160,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Merge", b => { - b.Property("MergeFilterListId"); + b.Property("MergeFilterListId"); - b.Property("UpstreamFilterListId"); + b.Property("UpstreamFilterListId"); - b.Property("CreatedDateUtc") + b.Property("CreatedDateUtc") + .IsRequired() .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); b.HasKey("MergeFilterListId", "UpstreamFilterListId"); @@ -169,19 +179,23 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SnapshotRule", b => { - b.Property("AddedBySnapshotId"); + b.Property("AddedBySnapshotId"); - b.Property("RuleId"); + b.Property("RuleId"); - b.Property("CreatedDateUtc") + b.Property("CreatedDateUtc") + .IsRequired() .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); - b.Property("ModifiedDateUtc") + b.Property("ModifiedDateUtc") + .IsRequired() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); - b.Property("RemovedBySnapshotId"); + b.Property("RemovedBySnapshotId"); b.HasKey("AddedBySnapshotId", "RuleId"); @@ -194,13 +208,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SoftwareSyntax", b => { - b.Property("SyntaxId"); + b.Property("SyntaxId"); - b.Property("SoftwareId"); + b.Property("SoftwareId"); - b.Property("CreatedDateUtc") + b.Property("CreatedDateUtc") + .IsRequired() .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); b.HasKey("SyntaxId", "SoftwareId"); @@ -211,13 +227,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Language", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("SMALLINT UNSIGNED"); + .HasColumnType("SMALLINT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); - b.Property("CreatedDateUtc") + b.Property("CreatedDateUtc") + .IsRequired() .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); b.Property("Iso6391") .ValueGeneratedOnAdd() @@ -249,9 +268,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("VARCHAR(126)") .HasDefaultValueSql("NULL"); - b.Property("ModifiedDateUtc") + b.Property("ModifiedDateUtc") + .IsRequired() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); b.Property("Name") .ValueGeneratedOnAdd() @@ -265,20 +286,25 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.License", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("TINYINT UNSIGNED"); + .HasColumnType("TINYINT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); - b.Property("CreatedDateUtc") + b.Property("CreatedDateUtc") + .IsRequired() .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); b.Property("DescriptionUrl") .HasColumnType("TEXT"); - b.Property("ModifiedDateUtc") + b.Property("ModifiedDateUtc") + .IsRequired() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); b.Property("Name") .IsRequired() @@ -295,13 +321,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Maintainer", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("SMALLINT UNSIGNED"); + .HasColumnType("SMALLINT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); - b.Property("CreatedDateUtc") + b.Property("CreatedDateUtc") + .IsRequired() .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); b.Property("EmailAddress") .ValueGeneratedOnAdd() @@ -311,9 +340,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("HomeUrl") .HasColumnType("TEXT"); - b.Property("ModifiedDateUtc") + b.Property("ModifiedDateUtc") + .IsRequired() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); b.Property("Name") .IsRequired() @@ -331,13 +362,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Rule", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INT UNSIGNED"); + .HasColumnType("INT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); - b.Property("CreatedDateUtc") + b.Property("CreatedDateUtc") + .IsRequired() .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); b.Property("Raw") .IsRequired() @@ -350,15 +384,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Snapshot", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("MEDIUMINT UNSIGNED"); + .HasColumnType("MEDIUMINT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); - b.Property("CreatedDateUtc") + b.Property("CreatedDateUtc") + .IsRequired() .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); - b.Property("FilterListId"); + b.Property("FilterListId"); b.Property("HttpStatusCode") .ValueGeneratedOnAdd() @@ -367,10 +404,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("IsCompleted"); - b.Property("ModifiedDateUtc") + b.Property("ModifiedDateUtc") + .IsRequired() .ValueGeneratedOnAddOrUpdate() .HasColumnType("TIMESTAMP") - .HasDefaultValueSql("CURRENT_TIMESTAMP()"); + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); b.HasKey("Id"); @@ -381,13 +419,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Software", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("TINYINT UNSIGNED"); + .HasColumnType("TINYINT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); - b.Property("CreatedDateUtc") + b.Property("CreatedDateUtc") + .IsRequired() .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); b.Property("DownloadUrl") .HasColumnType("TEXT"); @@ -395,9 +436,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("HomeUrl") .HasColumnType("TEXT"); - b.Property("ModifiedDateUtc") + b.Property("ModifiedDateUtc") + .IsRequired() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); b.Property("Name") .IsRequired() @@ -410,20 +453,25 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Syntax", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("TINYINT UNSIGNED"); + .HasColumnType("TINYINT UNSIGNED") + .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); - b.Property("CreatedDateUtc") + b.Property("CreatedDateUtc") + .IsRequired() .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp()"); b.Property("DefinitionUrl") .HasColumnType("TEXT"); - b.Property("ModifiedDateUtc") + b.Property("ModifiedDateUtc") + .IsRequired() .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP") + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); b.Property("Name") .IsRequired() diff --git a/src/FilterLists.Data/Entities/BaseEntity.cs b/src/FilterLists.Data/Entities/BaseEntity.cs index 731e6c3c3..152d47316 100644 --- a/src/FilterLists.Data/Entities/BaseEntity.cs +++ b/src/FilterLists.Data/Entities/BaseEntity.cs @@ -5,7 +5,7 @@ namespace FilterLists.Data.Entities public class BaseEntity : IBaseEntity { public uint Id { get; set; } - public DateTime CreatedDateUtc { get; set; } - public DateTime ModifiedDateUtc { get; set; } + public DateTime? CreatedDateUtc { get; set; } + public DateTime? ModifiedDateUtc { get; set; } } } \ No newline at end of file diff --git a/src/FilterLists.Data/Entities/IBaseEntity.cs b/src/FilterLists.Data/Entities/IBaseEntity.cs index 698faad3f..8f0a6ac6f 100644 --- a/src/FilterLists.Data/Entities/IBaseEntity.cs +++ b/src/FilterLists.Data/Entities/IBaseEntity.cs @@ -4,6 +4,6 @@ namespace FilterLists.Data.Entities { public interface IBaseEntity { - DateTime CreatedDateUtc { get; set; } + DateTime? CreatedDateUtc { get; set; } } } \ No newline at end of file diff --git a/src/FilterLists.Data/Entities/Junctions/BaseJunctionEntity.cs b/src/FilterLists.Data/Entities/Junctions/BaseJunctionEntity.cs index 1c0c0cc9f..d39fd8865 100644 --- a/src/FilterLists.Data/Entities/Junctions/BaseJunctionEntity.cs +++ b/src/FilterLists.Data/Entities/Junctions/BaseJunctionEntity.cs @@ -4,6 +4,6 @@ namespace FilterLists.Data.Entities.Junctions { public class BaseJunctionEntity : IBaseEntity { - public DateTime CreatedDateUtc { get; set; } + public DateTime? CreatedDateUtc { get; set; } } } \ No newline at end of file diff --git a/src/FilterLists.Data/Entities/Junctions/SnapshotRule.cs b/src/FilterLists.Data/Entities/Junctions/SnapshotRule.cs index 634d0f61a..4bc330ecf 100644 --- a/src/FilterLists.Data/Entities/Junctions/SnapshotRule.cs +++ b/src/FilterLists.Data/Entities/Junctions/SnapshotRule.cs @@ -4,7 +4,7 @@ namespace FilterLists.Data.Entities.Junctions { public class SnapshotRule : BaseJunctionEntity { - public DateTime ModifiedDateUtc { get; set; } + public DateTime? ModifiedDateUtc { get; set; } public uint AddedBySnapshotId { get; set; } public Snapshot AddedBySnapshot { get; set; } public uint? RemovedBySnapshotId { get; set; } diff --git a/src/FilterLists.Data/EntityTypeConfigurations/BaseEntityTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/BaseEntityTypeConfiguration.cs index cbe539283..72149cc67 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/BaseEntityTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/BaseEntityTypeConfiguration.cs @@ -13,10 +13,14 @@ public virtual void Configure(EntityTypeBuilder entityTypeBuilder) .HasColumnType("SMALLINT UNSIGNED"); entityTypeBuilder.Property(x => x.CreatedDateUtc) .HasColumnType("TIMESTAMP") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .IsRequired() + .HasDefaultValueSql("current_timestamp()"); entityTypeBuilder.Property(x => x.ModifiedDateUtc) .HasColumnType("TIMESTAMP") - .ValueGeneratedOnAddOrUpdate(); + .ValueGeneratedOnAddOrUpdate() + .IsRequired() + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/BaseJunctionTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/BaseJunctionTypeConfiguration.cs index 42697a2ef..66ae065eb 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/BaseJunctionTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/BaseJunctionTypeConfiguration.cs @@ -8,6 +8,10 @@ public class BaseJunctionTypeConfiguration : IEntityTypeConfiguration where TJunction : BaseJunctionEntity { public virtual void Configure(EntityTypeBuilder entityTypeBuilder) => - entityTypeBuilder.Property(x => x.CreatedDateUtc).HasColumnType("TIMESTAMP").ValueGeneratedOnAdd(); + entityTypeBuilder.Property(x => x.CreatedDateUtc) + .HasColumnType("TIMESTAMP") + .ValueGeneratedOnAdd() + .IsRequired() + .HasDefaultValueSql("current_timestamp()"); } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SnapshotRuleTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SnapshotRuleTypeConfiguration.cs index 2f16a59b3..68088f440 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SnapshotRuleTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SnapshotRuleTypeConfiguration.cs @@ -13,7 +13,9 @@ public override void Configure(EntityTypeBuilder entityTypeBuilder entityTypeBuilder.HasKey(x => new {x.AddedBySnapshotId, x.RuleId}); entityTypeBuilder.Property(x => x.ModifiedDateUtc) .HasColumnType("TIMESTAMP") - .ValueGeneratedOnAddOrUpdate(); + .ValueGeneratedOnAddOrUpdate() + .IsRequired() + .HasDefaultValueSql("current_timestamp() ON UPDATE current_timestamp()"); entityTypeBuilder.HasOne(x => x.AddedBySnapshot) .WithMany(x => x.AddedSnapshotRules) .HasForeignKey(x => x.AddedBySnapshotId); diff --git a/src/FilterLists.Data/EntityTypeConfigurations/SnapshotTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/SnapshotTypeConfiguration.cs index da0d0eac6..946c4a730 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/SnapshotTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/SnapshotTypeConfiguration.cs @@ -12,8 +12,6 @@ public override void Configure(EntityTypeBuilder entityTypeBuilder) entityTypeBuilder.ToTable("snapshots"); entityTypeBuilder.Property(x => x.Id) .HasColumnType("MEDIUMINT UNSIGNED"); - entityTypeBuilder.Property(x => x.ModifiedDateUtc) - .HasDefaultValueSql("CURRENT_TIMESTAMP()"); entityTypeBuilder.Property(x => x.HttpStatusCode) .HasColumnType("VARCHAR(3)") .HasDefaultValueSql("NULL");