diff --git a/src/FilterLists.Api/Migrations/20180118184938_InitialCreate.Designer.cs b/src/FilterLists.Api/Migrations/20180118184938_InitialCreate.Designer.cs deleted file mode 100644 index 59de07f3b..000000000 --- a/src/FilterLists.Api/Migrations/20180118184938_InitialCreate.Designer.cs +++ /dev/null @@ -1,473 +0,0 @@ -// -using FilterLists.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Storage.Internal; -using System; - -namespace FilterLists.Api.Migrations -{ - [DbContext(typeof(FilterListsDbContext))] - [Migration("20180118184938_InitialCreate")] - partial class InitialCreate - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn) - .HasAnnotation("ProductVersion", "2.0.1-rtm-125"); - - modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("DescriptionSourceUrl") - .HasColumnType("TEXT"); - - b.Property("DiscontinuedDate"); - - b.Property("DonateUrl") - .HasColumnType("TEXT"); - - b.Property("EmailAddress") - .HasColumnType("NVARCHAR(126)"); - - b.Property("ForumUrl") - .HasColumnType("TEXT"); - - b.Property("HomeUrl") - .HasColumnType("TEXT"); - - b.Property("IssuesUrl") - .HasColumnType("TEXT"); - - b.Property("LicenseId"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); - - 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.FilterListLanguage", b => - { - b.Property("FilterListId"); - - b.Property("LanguageId"); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.HasKey("FilterListId", "LanguageId"); - - b.HasIndex("LanguageId"); - - b.ToTable("filterlists_languages"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.FilterListMaintainer", b => - { - b.Property("FilterListId"); - - b.Property("MaintainerId"); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.HasKey("FilterListId", "MaintainerId"); - - b.HasIndex("MaintainerId"); - - b.ToTable("filterlists_maintainers"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.FilterListRule", b => - { - b.Property("FilterListId"); - - b.Property("RuleId"); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.HasKey("FilterListId", "RuleId"); - - b.HasIndex("RuleId"); - - b.ToTable("filterlists_rules"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Fork", b => - { - b.Property("ForkFilterListId"); - - b.Property("UpstreamFilterListId"); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.HasKey("ForkFilterListId", "UpstreamFilterListId"); - - b.HasIndex("UpstreamFilterListId"); - - b.ToTable("forks"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Language", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("Iso6391") - .HasColumnType("NVARCHAR(2)"); - - b.Property("Iso6392") - .HasColumnType("NVARCHAR(3)"); - - b.Property("Iso6392B") - .HasColumnType("NVARCHAR(3)"); - - b.Property("Iso6392T") - .HasColumnType("NVARCHAR(3)"); - - b.Property("Iso6393") - .HasColumnType("NVARCHAR(3)"); - - b.Property("LocalName") - .HasColumnType("NVARCHAR(126)"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.Property("Name") - .HasColumnType("NVARCHAR(126)"); - - b.HasKey("Id"); - - b.ToTable("languages"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.License", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("DescriptionUrl") - .HasColumnType("TEXT"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); - - b.Property("PermissiveAdaptation"); - - b.Property("PermissiveCommercial"); - - b.HasKey("Id"); - - b.ToTable("licenses"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Maintainer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("EmailAddress") - .HasColumnType("NVARCHAR(126)"); - - b.Property("HomeUrl") - .HasColumnType("TEXT"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); - - b.Property("TwitterHandle") - .HasColumnType("NVARCHAR(126)"); - - b.HasKey("Id"); - - b.ToTable("maintainers"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Merge", b => - { - b.Property("MergeFilterListId"); - - b.Property("UpstreamFilterListId"); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.HasKey("MergeFilterListId", "UpstreamFilterListId"); - - b.HasIndex("UpstreamFilterListId"); - - b.ToTable("merges"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Rule", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.Property("Raw") - .HasColumnType("NVARCHAR(2083)"); - - b.HasKey("Id"); - - b.ToTable("rules"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Software", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("DownloadUrl") - .HasColumnType("TEXT"); - - b.Property("HomeUrl") - .HasColumnType("TEXT"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); - - b.HasKey("Id"); - - b.ToTable("software"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.SoftwareSyntax", b => - { - b.Property("SoftwareId"); - - b.Property("SyntaxId"); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.HasKey("SoftwareId", "SyntaxId"); - - b.HasIndex("SyntaxId"); - - b.ToTable("software_syntaxes"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Syntax", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("DefinitionUrl") - .HasColumnType("TEXT"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); - - b.HasKey("Id"); - - b.ToTable("syntaxes"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b => - { - b.HasOne("FilterLists.Data.Entities.License") - .WithMany("FilterLists") - .HasForeignKey("LicenseId"); - - b.HasOne("FilterLists.Data.Entities.Syntax") - .WithMany("FilterLists") - .HasForeignKey("SyntaxId"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.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.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.FilterListRule", b => - { - b.HasOne("FilterLists.Data.Entities.FilterList", "FilterList") - .WithMany("FilterListRules") - .HasForeignKey("FilterListId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("FilterLists.Data.Entities.Rule", "Rule") - .WithMany("FilterListRules") - .HasForeignKey("RuleId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Fork", b => - { - b.HasOne("FilterLists.Data.Entities.FilterList", "ForkFilterList") - .WithMany() - .HasForeignKey("ForkFilterListId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("FilterLists.Data.Entities.FilterList", "UpstreamFilterList") - .WithMany() - .HasForeignKey("UpstreamFilterListId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Merge", b => - { - b.HasOne("FilterLists.Data.Entities.FilterList", "MergeFilterList") - .WithMany() - .HasForeignKey("MergeFilterListId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("FilterLists.Data.Entities.FilterList", "UpstreamFilterList") - .WithMany() - .HasForeignKey("UpstreamFilterListId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.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); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/FilterLists.Api/Migrations/20180118184938_InitialCreate.cs b/src/FilterLists.Api/Migrations/20180118184938_InitialCreate.cs deleted file mode 100644 index 1b637f698..000000000 --- a/src/FilterLists.Api/Migrations/20180118184938_InitialCreate.cs +++ /dev/null @@ -1,389 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace FilterLists.Api.Migrations -{ - public partial class InitialCreate : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - "languages", - table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - CreatedDateUtc = table.Column("TIMESTAMP", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Iso6391 = table.Column("NVARCHAR(2)", nullable: true), - Iso6392 = table.Column("NVARCHAR(3)", nullable: true), - Iso6392B = table.Column("NVARCHAR(3)", nullable: true), - Iso6392T = table.Column("NVARCHAR(3)", nullable: true), - Iso6393 = table.Column("NVARCHAR(3)", nullable: true), - LocalName = table.Column("NVARCHAR(126)", nullable: true), - ModifiedDateUtc = table.Column("TIMESTAMP", nullable: false), - Name = table.Column("NVARCHAR(126)", nullable: true) - }, - constraints: table => { table.PrimaryKey("PK_languages", x => x.Id); }); - - migrationBuilder.CreateTable( - "licenses", - table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - CreatedDateUtc = table.Column("TIMESTAMP", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - DescriptionUrl = table.Column("TEXT", nullable: true), - ModifiedDateUtc = table.Column("TIMESTAMP", nullable: false), - Name = table.Column("NVARCHAR(126)", nullable: false), - PermissiveAdaptation = table.Column(nullable: false), - PermissiveCommercial = table.Column(nullable: false) - }, - constraints: table => { table.PrimaryKey("PK_licenses", x => x.Id); }); - - migrationBuilder.CreateTable( - "maintainers", - table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - CreatedDateUtc = table.Column("TIMESTAMP", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - EmailAddress = table.Column("NVARCHAR(126)", nullable: true), - HomeUrl = table.Column("TEXT", nullable: true), - ModifiedDateUtc = table.Column("TIMESTAMP", nullable: false), - Name = table.Column("NVARCHAR(126)", nullable: false), - TwitterHandle = table.Column("NVARCHAR(126)", nullable: true) - }, - constraints: table => { table.PrimaryKey("PK_maintainers", x => x.Id); }); - - migrationBuilder.CreateTable( - "rules", - table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - CreatedDateUtc = table.Column("TIMESTAMP", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ModifiedDateUtc = table.Column("TIMESTAMP", nullable: false), - Raw = table.Column("NVARCHAR(2083)", nullable: true) - }, - constraints: table => { table.PrimaryKey("PK_rules", x => x.Id); }); - - migrationBuilder.CreateTable( - "software", - table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - CreatedDateUtc = table.Column("TIMESTAMP", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - DownloadUrl = table.Column("TEXT", nullable: true), - HomeUrl = table.Column("TEXT", nullable: true), - ModifiedDateUtc = table.Column("TIMESTAMP", nullable: false), - Name = table.Column("NVARCHAR(126)", nullable: false) - }, - constraints: table => { table.PrimaryKey("PK_software", x => x.Id); }); - - migrationBuilder.CreateTable( - "syntaxes", - table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - CreatedDateUtc = table.Column("TIMESTAMP", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - DefinitionUrl = table.Column("TEXT", nullable: true), - ModifiedDateUtc = table.Column("TIMESTAMP", nullable: false), - Name = table.Column("NVARCHAR(126)", nullable: false) - }, - constraints: table => { table.PrimaryKey("PK_syntaxes", x => x.Id); }); - - migrationBuilder.CreateTable( - "filterlists", - table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - CreatedDateUtc = table.Column("TIMESTAMP", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Description = table.Column("TEXT", nullable: true), - DescriptionSourceUrl = table.Column("TEXT", nullable: true), - DiscontinuedDate = table.Column(nullable: true), - DonateUrl = table.Column("TEXT", nullable: true), - EmailAddress = table.Column("NVARCHAR(126)", nullable: true), - ForumUrl = table.Column("TEXT", nullable: true), - HomeUrl = table.Column("TEXT", nullable: true), - IssuesUrl = table.Column("TEXT", nullable: true), - LicenseId = table.Column(nullable: true), - ModifiedDateUtc = table.Column("TIMESTAMP", nullable: false), - Name = table.Column("NVARCHAR(126)", nullable: false), - SubmissionUrl = table.Column("TEXT", nullable: true), - SyntaxId = table.Column(nullable: true), - ViewUrl = table.Column("TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_filterlists", x => x.Id); - table.ForeignKey( - "FK_filterlists_licenses_LicenseId", - x => x.LicenseId, - "licenses", - "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - "FK_filterlists_syntaxes_SyntaxId", - x => x.SyntaxId, - "syntaxes", - "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - "software_syntaxes", - table => new - { - SoftwareId = table.Column(nullable: false), - SyntaxId = table.Column(nullable: false), - CreatedDateUtc = table.Column("TIMESTAMP", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ModifiedDateUtc = table.Column("TIMESTAMP", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_software_syntaxes", x => new {x.SoftwareId, x.SyntaxId}); - table.ForeignKey( - "FK_software_syntaxes_software_SoftwareId", - x => x.SoftwareId, - "software", - "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - "FK_software_syntaxes_syntaxes_SyntaxId", - x => x.SyntaxId, - "syntaxes", - "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - "filterlists_languages", - table => new - { - FilterListId = table.Column(nullable: false), - LanguageId = table.Column(nullable: false), - CreatedDateUtc = table.Column("TIMESTAMP", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ModifiedDateUtc = table.Column("TIMESTAMP", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_filterlists_languages", x => new {x.FilterListId, x.LanguageId}); - table.ForeignKey( - "FK_filterlists_languages_filterlists_FilterListId", - x => x.FilterListId, - "filterlists", - "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - "FK_filterlists_languages_languages_LanguageId", - x => x.LanguageId, - "languages", - "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - "filterlists_maintainers", - table => new - { - FilterListId = table.Column(nullable: false), - MaintainerId = table.Column(nullable: false), - CreatedDateUtc = table.Column("TIMESTAMP", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ModifiedDateUtc = table.Column("TIMESTAMP", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_filterlists_maintainers", x => new {x.FilterListId, x.MaintainerId}); - table.ForeignKey( - "FK_filterlists_maintainers_filterlists_FilterListId", - x => x.FilterListId, - "filterlists", - "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - "FK_filterlists_maintainers_maintainers_MaintainerId", - x => x.MaintainerId, - "maintainers", - "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - "filterlists_rules", - table => new - { - FilterListId = table.Column(nullable: false), - RuleId = table.Column(nullable: false), - CreatedDateUtc = table.Column("TIMESTAMP", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ModifiedDateUtc = table.Column("TIMESTAMP", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_filterlists_rules", x => new {x.FilterListId, x.RuleId}); - table.ForeignKey( - "FK_filterlists_rules_filterlists_FilterListId", - x => x.FilterListId, - "filterlists", - "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - "FK_filterlists_rules_rules_RuleId", - x => x.RuleId, - "rules", - "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - "forks", - table => new - { - ForkFilterListId = table.Column(nullable: false), - UpstreamFilterListId = table.Column(nullable: false), - CreatedDateUtc = table.Column("TIMESTAMP", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ModifiedDateUtc = table.Column("TIMESTAMP", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_forks", x => new {x.ForkFilterListId, x.UpstreamFilterListId}); - table.ForeignKey( - "FK_forks_filterlists_ForkFilterListId", - x => x.ForkFilterListId, - "filterlists", - "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - "FK_forks_filterlists_UpstreamFilterListId", - x => x.UpstreamFilterListId, - "filterlists", - "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - "merges", - table => new - { - MergeFilterListId = table.Column(nullable: false), - UpstreamFilterListId = table.Column(nullable: false), - CreatedDateUtc = table.Column("TIMESTAMP", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ModifiedDateUtc = table.Column("TIMESTAMP", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_merges", x => new {x.MergeFilterListId, x.UpstreamFilterListId}); - table.ForeignKey( - "FK_merges_filterlists_MergeFilterListId", - x => x.MergeFilterListId, - "filterlists", - "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - "FK_merges_filterlists_UpstreamFilterListId", - x => x.UpstreamFilterListId, - "filterlists", - "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - "IX_filterlists_LicenseId", - "filterlists", - "LicenseId"); - - migrationBuilder.CreateIndex( - "IX_filterlists_SyntaxId", - "filterlists", - "SyntaxId"); - - migrationBuilder.CreateIndex( - "IX_filterlists_languages_LanguageId", - "filterlists_languages", - "LanguageId"); - - migrationBuilder.CreateIndex( - "IX_filterlists_maintainers_MaintainerId", - "filterlists_maintainers", - "MaintainerId"); - - migrationBuilder.CreateIndex( - "IX_filterlists_rules_RuleId", - "filterlists_rules", - "RuleId"); - - migrationBuilder.CreateIndex( - "IX_forks_UpstreamFilterListId", - "forks", - "UpstreamFilterListId"); - - migrationBuilder.CreateIndex( - "IX_merges_UpstreamFilterListId", - "merges", - "UpstreamFilterListId"); - - migrationBuilder.CreateIndex( - "IX_software_syntaxes_SyntaxId", - "software_syntaxes", - "SyntaxId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - "filterlists_languages"); - - migrationBuilder.DropTable( - "filterlists_maintainers"); - - migrationBuilder.DropTable( - "filterlists_rules"); - - migrationBuilder.DropTable( - "forks"); - - migrationBuilder.DropTable( - "merges"); - - migrationBuilder.DropTable( - "software_syntaxes"); - - migrationBuilder.DropTable( - "languages"); - - migrationBuilder.DropTable( - "maintainers"); - - migrationBuilder.DropTable( - "rules"); - - migrationBuilder.DropTable( - "filterlists"); - - migrationBuilder.DropTable( - "software"); - - migrationBuilder.DropTable( - "licenses"); - - migrationBuilder.DropTable( - "syntaxes"); - } - } -} \ No newline at end of file diff --git a/src/FilterLists.Api/Migrations/20180126190529_addSnapshot.Designer.cs b/src/FilterLists.Api/Migrations/20180126190529_addSnapshot.Designer.cs deleted file mode 100644 index 5f2915a07..000000000 --- a/src/FilterLists.Api/Migrations/20180126190529_addSnapshot.Designer.cs +++ /dev/null @@ -1,507 +0,0 @@ -// -using FilterLists.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Storage.Internal; -using System; - -namespace FilterLists.Api.Migrations -{ - [DbContext(typeof(FilterListsDbContext))] - [Migration("20180126190529_addSnapshot")] - partial class addSnapshot - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn) - .HasAnnotation("ProductVersion", "2.0.1-rtm-125"); - - modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("DescriptionSourceUrl") - .HasColumnType("TEXT"); - - b.Property("DiscontinuedDate"); - - b.Property("DonateUrl") - .HasColumnType("TEXT"); - - b.Property("EmailAddress") - .HasColumnType("NVARCHAR(126)"); - - b.Property("ForumUrl") - .HasColumnType("TEXT"); - - b.Property("HomeUrl") - .HasColumnType("TEXT"); - - b.Property("IssuesUrl") - .HasColumnType("TEXT"); - - b.Property("LicenseId"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); - - 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") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("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") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.HasKey("FilterListId", "MaintainerId"); - - b.HasIndex("MaintainerId"); - - b.ToTable("filterlists_maintainers"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Junctions.FilterListRule", b => - { - b.Property("FilterListId"); - - b.Property("RuleId"); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.HasKey("FilterListId", "RuleId"); - - b.HasIndex("RuleId"); - - b.ToTable("filterlists_rules"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Fork", b => - { - b.Property("ForkFilterListId"); - - b.Property("UpstreamFilterListId"); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("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") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.HasKey("MergeFilterListId", "UpstreamFilterListId"); - - b.HasIndex("UpstreamFilterListId"); - - b.ToTable("merges"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SoftwareSyntax", b => - { - b.Property("SoftwareId"); - - b.Property("SyntaxId"); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.HasKey("SoftwareId", "SyntaxId"); - - b.HasIndex("SyntaxId"); - - b.ToTable("software_syntaxes"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Language", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("Iso6391") - .HasColumnType("NVARCHAR(2)"); - - b.Property("Iso6392") - .HasColumnType("NVARCHAR(3)"); - - b.Property("Iso6392B") - .HasColumnType("NVARCHAR(3)"); - - b.Property("Iso6392T") - .HasColumnType("NVARCHAR(3)"); - - b.Property("Iso6393") - .HasColumnType("NVARCHAR(3)"); - - b.Property("LocalName") - .HasColumnType("NVARCHAR(126)"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.Property("Name") - .HasColumnType("NVARCHAR(126)"); - - b.HasKey("Id"); - - b.ToTable("languages"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.License", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("DescriptionUrl") - .HasColumnType("TEXT"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); - - b.Property("PermissiveAdaptation"); - - b.Property("PermissiveCommercial"); - - b.HasKey("Id"); - - b.ToTable("licenses"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Maintainer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("EmailAddress") - .HasColumnType("NVARCHAR(126)"); - - b.Property("HomeUrl") - .HasColumnType("TEXT"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); - - b.Property("TwitterHandle") - .HasColumnType("NVARCHAR(126)"); - - b.HasKey("Id"); - - b.ToTable("maintainers"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Rule", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.Property("Raw") - .HasColumnType("NVARCHAR(2083)"); - - b.HasKey("Id"); - - b.ToTable("rules"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Snapshot", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Content") - .IsRequired() - .HasColumnType("MEDIUMTEXT"); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("FilterListId"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.HasKey("Id"); - - b.HasIndex("FilterListId"); - - b.ToTable("snapshots"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Software", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("DownloadUrl") - .HasColumnType("TEXT"); - - b.Property("HomeUrl") - .HasColumnType("TEXT"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); - - b.HasKey("Id"); - - b.ToTable("software"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Syntax", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("DefinitionUrl") - .HasColumnType("TEXT"); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); - - b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); - - b.HasKey("Id"); - - b.ToTable("syntaxes"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b => - { - b.HasOne("FilterLists.Data.Entities.License") - .WithMany("FilterLists") - .HasForeignKey("LicenseId"); - - b.HasOne("FilterLists.Data.Entities.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.FilterListRule", b => - { - b.HasOne("FilterLists.Data.Entities.FilterList", "FilterList") - .WithMany("FilterListRules") - .HasForeignKey("FilterListId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("FilterLists.Data.Entities.Rule", "Rule") - .WithMany("FilterListRules") - .HasForeignKey("RuleId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Fork", b => - { - b.HasOne("FilterLists.Data.Entities.FilterList", "ForkFilterList") - .WithMany() - .HasForeignKey("ForkFilterListId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("FilterLists.Data.Entities.FilterList", "UpstreamFilterList") - .WithMany() - .HasForeignKey("UpstreamFilterListId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Merge", b => - { - b.HasOne("FilterLists.Data.Entities.FilterList", "MergeFilterList") - .WithMany() - .HasForeignKey("MergeFilterListId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("FilterLists.Data.Entities.FilterList", "UpstreamFilterList") - .WithMany() - .HasForeignKey("UpstreamFilterListId") - .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") - .WithMany("Snapshots") - .HasForeignKey("FilterListId") - .OnDelete(DeleteBehavior.Cascade); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/FilterLists.Api/Migrations/20180126190529_addSnapshot.cs b/src/FilterLists.Api/Migrations/20180126190529_addSnapshot.cs deleted file mode 100644 index 1f044ea9d..000000000 --- a/src/FilterLists.Api/Migrations/20180126190529_addSnapshot.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace FilterLists.Api.Migrations -{ - public partial class addSnapshot : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - "snapshots", - table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Content = table.Column("MEDIUMTEXT", nullable: false), - CreatedDateUtc = table.Column("TIMESTAMP", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - FilterListId = table.Column(nullable: false), - ModifiedDateUtc = table.Column("TIMESTAMP", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_snapshots", x => x.Id); - table.ForeignKey( - "FK_snapshots_filterlists_FilterListId", - x => x.FilterListId, - "filterlists", - "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - "IX_snapshots_FilterListId", - "snapshots", - "FilterListId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - "snapshots"); - } - } -} \ No newline at end of file diff --git a/src/FilterLists.Api/Migrations/20180127125025_partialRemoveModDateAndMore.cs b/src/FilterLists.Api/Migrations/20180127125025_partialRemoveModDateAndMore.cs deleted file mode 100644 index 95014835d..000000000 --- a/src/FilterLists.Api/Migrations/20180127125025_partialRemoveModDateAndMore.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace FilterLists.Api.Migrations -{ - public partial class partialRemoveModDateAndMore : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - "ModifiedDateUtc", - "software_syntaxes"); - - migrationBuilder.DropColumn( - "ModifiedDateUtc", - "snapshots"); - - migrationBuilder.DropColumn( - "ModifiedDateUtc", - "rules"); - - migrationBuilder.DropColumn( - "ModifiedDateUtc", - "merges"); - - migrationBuilder.DropColumn( - "ModifiedDateUtc", - "forks"); - - migrationBuilder.DropColumn( - "ModifiedDateUtc", - "filterlists_rules"); - - migrationBuilder.DropColumn( - "ModifiedDateUtc", - "filterlists_maintainers"); - - migrationBuilder.DropColumn( - "ModifiedDateUtc", - "filterlists_languages"); - - migrationBuilder.AlterColumn( - "Raw", - "rules", - "NVARCHAR(2083)", - nullable: false, - oldClrType: typeof(string), - oldType: "NVARCHAR(2083)", - oldNullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - "ModifiedDateUtc", - "software_syntaxes", - "TIMESTAMP", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.AddColumn( - "ModifiedDateUtc", - "snapshots", - "TIMESTAMP", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.AlterColumn( - "Raw", - "rules", - "NVARCHAR(2083)", - nullable: true, - oldClrType: typeof(string), - oldType: "NVARCHAR(2083)"); - - migrationBuilder.AddColumn( - "ModifiedDateUtc", - "rules", - "TIMESTAMP", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.AddColumn( - "ModifiedDateUtc", - "merges", - "TIMESTAMP", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.AddColumn( - "ModifiedDateUtc", - "forks", - "TIMESTAMP", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.AddColumn( - "ModifiedDateUtc", - "filterlists_rules", - "TIMESTAMP", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.AddColumn( - "ModifiedDateUtc", - "filterlists_maintainers", - "TIMESTAMP", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.AddColumn( - "ModifiedDateUtc", - "filterlists_languages", - "TIMESTAMP", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - } - } -} \ No newline at end of file diff --git a/src/FilterLists.Api/Migrations/20180127125025_partialRemoveModDateAndMore.Designer.cs b/src/FilterLists.Api/Migrations/20180127171317_InitialCreate.Designer.cs similarity index 78% rename from src/FilterLists.Api/Migrations/20180127125025_partialRemoveModDateAndMore.Designer.cs rename to src/FilterLists.Api/Migrations/20180127171317_InitialCreate.Designer.cs index 839b7b1c1..6320a1d49 100644 --- a/src/FilterLists.Api/Migrations/20180127125025_partialRemoveModDateAndMore.Designer.cs +++ b/src/FilterLists.Api/Migrations/20180127171317_InitialCreate.Designer.cs @@ -11,8 +11,8 @@ namespace FilterLists.Api.Migrations { [DbContext(typeof(FilterListsDbContext))] - [Migration("20180127125025_partialRemoveModDateAndMore")] - partial class partialRemoveModDateAndMore + [Migration("20180127171317_InitialCreate")] + partial class InitialCreate { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -24,11 +24,11 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b => { b.Property("Id") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("SMALLINT UNSIGNED"); b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); b.Property("Description") .HasColumnType("TEXT"); @@ -56,12 +56,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("LicenseId"); b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); + .HasColumnType("NVARCHAR(126) NOT NULL"); b.Property("SubmissionUrl") .HasColumnType("TEXT"); @@ -69,7 +67,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SyntaxId"); b.Property("ViewUrl") - .HasColumnType("TEXT"); + .HasColumnType("TEXT NOT NULL"); b.HasKey("Id"); @@ -87,8 +85,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("LanguageId"); b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); b.HasKey("FilterListId", "LanguageId"); @@ -104,8 +101,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("MaintainerId"); b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); b.HasKey("FilterListId", "MaintainerId"); @@ -121,8 +117,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("RuleId"); b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); b.HasKey("FilterListId", "RuleId"); @@ -138,8 +133,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("UpstreamFilterListId"); b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); b.HasKey("ForkFilterListId", "UpstreamFilterListId"); @@ -155,8 +149,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("UpstreamFilterListId"); b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); b.HasKey("MergeFilterListId", "UpstreamFilterListId"); @@ -172,8 +165,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SyntaxId"); b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); b.HasKey("SoftwareId", "SyntaxId"); @@ -185,11 +177,11 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Language", b => { b.Property("Id") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("SMALLINT UNSIGNED"); b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); b.Property("Iso6391") .HasColumnType("NVARCHAR(2)"); @@ -210,8 +202,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("NVARCHAR(126)"); b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); b.Property("Name") .HasColumnType("NVARCHAR(126)"); @@ -224,22 +215,20 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.License", b => { b.Property("Id") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("SMALLINT UNSIGNED"); b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); b.Property("DescriptionUrl") .HasColumnType("TEXT"); b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); + .HasColumnType("NVARCHAR(126) NOT NULL"); b.Property("PermissiveAdaptation"); @@ -253,11 +242,11 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Maintainer", b => { b.Property("Id") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("SMALLINT UNSIGNED"); b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); b.Property("EmailAddress") .HasColumnType("NVARCHAR(126)"); @@ -266,12 +255,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("TEXT"); b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); + .HasColumnType("NVARCHAR(126) NOT NULL"); b.Property("TwitterHandle") .HasColumnType("NVARCHAR(126)"); @@ -284,51 +271,28 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Rule", b => { b.Property("Id") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("BIGINT UNSIGNED"); b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); b.Property("Raw") - .IsRequired() - .HasColumnType("NVARCHAR(2083)"); + .HasColumnType("NVARCHAR(2083) NOT NULL"); b.HasKey("Id"); b.ToTable("rules"); }); - modelBuilder.Entity("FilterLists.Data.Entities.Snapshot", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Content") - .IsRequired() - .HasColumnType("MEDIUMTEXT"); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("FilterListId"); - - b.HasKey("Id"); - - b.HasIndex("FilterListId"); - - b.ToTable("snapshots"); - }); - modelBuilder.Entity("FilterLists.Data.Entities.Software", b => { b.Property("Id") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("SMALLINT UNSIGNED"); b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); b.Property("DownloadUrl") .HasColumnType("TEXT"); @@ -337,12 +301,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("TEXT"); b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); + .HasColumnType("NVARCHAR(126) NOT NULL"); b.HasKey("Id"); @@ -352,22 +314,20 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("FilterLists.Data.Entities.Syntax", b => { b.Property("Id") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("SMALLINT UNSIGNED"); b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); b.Property("DefinitionUrl") .HasColumnType("TEXT"); b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); + .HasColumnType("NVARCHAR(126) NOT NULL"); b.HasKey("Id"); @@ -462,14 +422,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasForeignKey("SyntaxId") .OnDelete(DeleteBehavior.Cascade); }); - - modelBuilder.Entity("FilterLists.Data.Entities.Snapshot", b => - { - b.HasOne("FilterLists.Data.Entities.FilterList") - .WithMany("Snapshots") - .HasForeignKey("FilterListId") - .OnDelete(DeleteBehavior.Cascade); - }); #pragma warning restore 612, 618 } } diff --git a/src/FilterLists.Api/Migrations/20180127171317_InitialCreate.cs b/src/FilterLists.Api/Migrations/20180127171317_InitialCreate.cs new file mode 100644 index 000000000..df4844de6 --- /dev/null +++ b/src/FilterLists.Api/Migrations/20180127171317_InitialCreate.cs @@ -0,0 +1,388 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using System; +using System.Collections.Generic; + +namespace FilterLists.Api.Migrations +{ + public partial class InitialCreate : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "languages", + columns: table => new + { + Id = table.Column(type: "SMALLINT UNSIGNED", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + CreatedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable: false), + Iso6391 = table.Column(type: "NVARCHAR(2)", nullable: true), + Iso6392 = table.Column(type: "NVARCHAR(3)", nullable: true), + Iso6392B = table.Column(type: "NVARCHAR(3)", nullable: true), + Iso6392T = table.Column(type: "NVARCHAR(3)", nullable: true), + Iso6393 = table.Column(type: "NVARCHAR(3)", nullable: true), + LocalName = table.Column(type: "NVARCHAR(126)", nullable: true), + ModifiedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", nullable: false), + Name = table.Column(type: "NVARCHAR(126)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_languages", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "licenses", + columns: table => new + { + Id = table.Column(type: "SMALLINT UNSIGNED", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + CreatedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable: false), + DescriptionUrl = table.Column(type: "TEXT", nullable: true), + ModifiedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", nullable: false), + Name = table.Column(type: "NVARCHAR(126) NOT NULL", nullable: true), + PermissiveAdaptation = table.Column(nullable: false), + PermissiveCommercial = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_licenses", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "maintainers", + columns: table => new + { + Id = table.Column(type: "SMALLINT UNSIGNED", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + CreatedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable: false), + EmailAddress = table.Column(type: "NVARCHAR(126)", nullable: true), + HomeUrl = table.Column(type: "TEXT", nullable: true), + ModifiedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", nullable: false), + Name = table.Column(type: "NVARCHAR(126) NOT NULL", nullable: true), + TwitterHandle = table.Column(type: "NVARCHAR(126)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_maintainers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "rules", + columns: table => new + { + Id = table.Column(type: "BIGINT UNSIGNED", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + CreatedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable: false), + Raw = table.Column(type: "NVARCHAR(2083) NOT NULL", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_rules", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "software", + columns: table => new + { + Id = table.Column(type: "SMALLINT UNSIGNED", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + CreatedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable: false), + DownloadUrl = table.Column(type: "TEXT", nullable: true), + HomeUrl = table.Column(type: "TEXT", nullable: true), + ModifiedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", nullable: false), + Name = table.Column(type: "NVARCHAR(126) NOT NULL", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_software", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "syntaxes", + columns: table => new + { + Id = table.Column(type: "SMALLINT UNSIGNED", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + CreatedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable: false), + DefinitionUrl = table.Column(type: "TEXT", nullable: true), + ModifiedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", nullable: false), + Name = table.Column(type: "NVARCHAR(126) NOT NULL", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_syntaxes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "filterlists", + columns: table => new + { + Id = table.Column(type: "SMALLINT UNSIGNED", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + CreatedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable: false), + Description = table.Column(type: "TEXT", nullable: true), + DescriptionSourceUrl = table.Column(type: "TEXT", nullable: true), + DiscontinuedDate = table.Column(nullable: true), + DonateUrl = table.Column(type: "TEXT", nullable: true), + EmailAddress = table.Column(type: "NVARCHAR(126)", nullable: true), + ForumUrl = table.Column(type: "TEXT", nullable: true), + HomeUrl = table.Column(type: "TEXT", nullable: true), + IssuesUrl = table.Column(type: "TEXT", nullable: true), + LicenseId = table.Column(nullable: true), + ModifiedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", nullable: false), + Name = table.Column(type: "NVARCHAR(126) NOT NULL", nullable: true), + SubmissionUrl = table.Column(type: "TEXT", nullable: true), + SyntaxId = table.Column(nullable: true), + ViewUrl = table.Column(type: "TEXT NOT NULL", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_filterlists", x => x.Id); + table.ForeignKey( + name: "FK_filterlists_licenses_LicenseId", + column: x => x.LicenseId, + principalTable: "licenses", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_filterlists_syntaxes_SyntaxId", + column: x => x.SyntaxId, + principalTable: "syntaxes", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "software_syntaxes", + columns: table => new + { + SoftwareId = table.Column(nullable: false), + SyntaxId = table.Column(nullable: false), + CreatedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_software_syntaxes", x => new { x.SoftwareId, x.SyntaxId }); + table.ForeignKey( + name: "FK_software_syntaxes_software_SoftwareId", + column: x => x.SoftwareId, + principalTable: "software", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_software_syntaxes_syntaxes_SyntaxId", + column: x => x.SyntaxId, + principalTable: "syntaxes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "filterlists_languages", + columns: table => new + { + FilterListId = table.Column(nullable: false), + LanguageId = table.Column(nullable: false), + CreatedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_filterlists_languages", x => new { x.FilterListId, x.LanguageId }); + table.ForeignKey( + name: "FK_filterlists_languages_filterlists_FilterListId", + column: x => x.FilterListId, + principalTable: "filterlists", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_filterlists_languages_languages_LanguageId", + column: x => x.LanguageId, + principalTable: "languages", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "filterlists_maintainers", + columns: table => new + { + FilterListId = table.Column(nullable: false), + MaintainerId = table.Column(nullable: false), + CreatedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_filterlists_maintainers", x => new { x.FilterListId, x.MaintainerId }); + table.ForeignKey( + name: "FK_filterlists_maintainers_filterlists_FilterListId", + column: x => x.FilterListId, + principalTable: "filterlists", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_filterlists_maintainers_maintainers_MaintainerId", + column: x => x.MaintainerId, + principalTable: "maintainers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "filterlists_rules", + columns: table => new + { + FilterListId = table.Column(nullable: false), + RuleId = table.Column(nullable: false), + CreatedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_filterlists_rules", x => new { x.FilterListId, x.RuleId }); + table.ForeignKey( + name: "FK_filterlists_rules_filterlists_FilterListId", + column: x => x.FilterListId, + principalTable: "filterlists", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_filterlists_rules_rules_RuleId", + column: x => x.RuleId, + principalTable: "rules", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "forks", + columns: table => new + { + ForkFilterListId = table.Column(nullable: false), + UpstreamFilterListId = table.Column(nullable: false), + CreatedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_forks", x => new { x.ForkFilterListId, x.UpstreamFilterListId }); + table.ForeignKey( + name: "FK_forks_filterlists_ForkFilterListId", + column: x => x.ForkFilterListId, + principalTable: "filterlists", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_forks_filterlists_UpstreamFilterListId", + column: x => x.UpstreamFilterListId, + principalTable: "filterlists", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "merges", + columns: table => new + { + MergeFilterListId = table.Column(nullable: false), + UpstreamFilterListId = table.Column(nullable: false), + CreatedDateUtc = table.Column(type: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_merges", x => new { x.MergeFilterListId, x.UpstreamFilterListId }); + table.ForeignKey( + name: "FK_merges_filterlists_MergeFilterListId", + column: x => x.MergeFilterListId, + principalTable: "filterlists", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_merges_filterlists_UpstreamFilterListId", + column: x => x.UpstreamFilterListId, + principalTable: "filterlists", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_filterlists_LicenseId", + table: "filterlists", + column: "LicenseId"); + + migrationBuilder.CreateIndex( + name: "IX_filterlists_SyntaxId", + table: "filterlists", + column: "SyntaxId"); + + migrationBuilder.CreateIndex( + name: "IX_filterlists_languages_LanguageId", + table: "filterlists_languages", + column: "LanguageId"); + + migrationBuilder.CreateIndex( + name: "IX_filterlists_maintainers_MaintainerId", + table: "filterlists_maintainers", + column: "MaintainerId"); + + migrationBuilder.CreateIndex( + name: "IX_filterlists_rules_RuleId", + table: "filterlists_rules", + column: "RuleId"); + + migrationBuilder.CreateIndex( + name: "IX_forks_UpstreamFilterListId", + table: "forks", + column: "UpstreamFilterListId"); + + migrationBuilder.CreateIndex( + name: "IX_merges_UpstreamFilterListId", + table: "merges", + column: "UpstreamFilterListId"); + + migrationBuilder.CreateIndex( + name: "IX_software_syntaxes_SyntaxId", + table: "software_syntaxes", + column: "SyntaxId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "filterlists_languages"); + + migrationBuilder.DropTable( + name: "filterlists_maintainers"); + + migrationBuilder.DropTable( + name: "filterlists_rules"); + + migrationBuilder.DropTable( + name: "forks"); + + migrationBuilder.DropTable( + name: "merges"); + + migrationBuilder.DropTable( + name: "software_syntaxes"); + + migrationBuilder.DropTable( + name: "languages"); + + migrationBuilder.DropTable( + name: "maintainers"); + + migrationBuilder.DropTable( + name: "rules"); + + migrationBuilder.DropTable( + name: "filterlists"); + + migrationBuilder.DropTable( + name: "software"); + + migrationBuilder.DropTable( + name: "licenses"); + + migrationBuilder.DropTable( + name: "syntaxes"); + } + } +} diff --git a/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs b/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs index 22114b02f..fab777929 100644 --- a/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs +++ b/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs @@ -1,15 +1,17 @@ // - -using System; using FilterLists.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.EntityFrameworkCore.Storage.Internal; +using System; namespace FilterLists.Api.Migrations { [DbContext(typeof(FilterListsDbContext))] - internal class FilterListsDbContextModelSnapshot : ModelSnapshot + partial class FilterListsDbContextModelSnapshot : ModelSnapshot { protected override void BuildModel(ModelBuilder modelBuilder) { @@ -19,455 +21,407 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasAnnotation("ProductVersion", "2.0.1-rtm-125"); modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("SMALLINT UNSIGNED"); - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + b.Property("CreatedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); - b.Property("Description") - .HasColumnType("TEXT"); + b.Property("Description") + .HasColumnType("TEXT"); - b.Property("DescriptionSourceUrl") - .HasColumnType("TEXT"); + b.Property("DescriptionSourceUrl") + .HasColumnType("TEXT"); - b.Property("DiscontinuedDate"); + b.Property("DiscontinuedDate"); - b.Property("DonateUrl") - .HasColumnType("TEXT"); + b.Property("DonateUrl") + .HasColumnType("TEXT"); - b.Property("EmailAddress") - .HasColumnType("NVARCHAR(126)"); + b.Property("EmailAddress") + .HasColumnType("NVARCHAR(126)"); - b.Property("ForumUrl") - .HasColumnType("TEXT"); + b.Property("ForumUrl") + .HasColumnType("TEXT"); - b.Property("HomeUrl") - .HasColumnType("TEXT"); + b.Property("HomeUrl") + .HasColumnType("TEXT"); - b.Property("IssuesUrl") - .HasColumnType("TEXT"); + b.Property("IssuesUrl") + .HasColumnType("TEXT"); - b.Property("LicenseId"); + b.Property("LicenseId"); - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + b.Property("ModifiedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); - b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); + b.Property("Name") + .HasColumnType("NVARCHAR(126) NOT NULL"); - b.Property("SubmissionUrl") - .HasColumnType("TEXT"); + b.Property("SubmissionUrl") + .HasColumnType("TEXT"); - b.Property("SyntaxId"); + b.Property("SyntaxId"); - b.Property("ViewUrl") - .HasColumnType("TEXT"); + b.Property("ViewUrl") + .HasColumnType("TEXT NOT NULL"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("LicenseId"); + b.HasIndex("LicenseId"); - b.HasIndex("SyntaxId"); + b.HasIndex("SyntaxId"); - b.ToTable("filterlists"); - }); + b.ToTable("filterlists"); + }); modelBuilder.Entity("FilterLists.Data.Entities.Junctions.FilterListLanguage", b => - { - b.Property("FilterListId"); + { + b.Property("FilterListId"); - b.Property("LanguageId"); + b.Property("LanguageId"); - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + b.Property("CreatedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); - b.HasKey("FilterListId", "LanguageId"); + b.HasKey("FilterListId", "LanguageId"); - b.HasIndex("LanguageId"); + b.HasIndex("LanguageId"); - b.ToTable("filterlists_languages"); - }); + b.ToTable("filterlists_languages"); + }); modelBuilder.Entity("FilterLists.Data.Entities.Junctions.FilterListMaintainer", b => - { - b.Property("FilterListId"); + { + b.Property("FilterListId"); - b.Property("MaintainerId"); + b.Property("MaintainerId"); - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + b.Property("CreatedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); - b.HasKey("FilterListId", "MaintainerId"); + b.HasKey("FilterListId", "MaintainerId"); - b.HasIndex("MaintainerId"); + b.HasIndex("MaintainerId"); - b.ToTable("filterlists_maintainers"); - }); + b.ToTable("filterlists_maintainers"); + }); modelBuilder.Entity("FilterLists.Data.Entities.Junctions.FilterListRule", b => - { - b.Property("FilterListId"); + { + b.Property("FilterListId"); - b.Property("RuleId"); + b.Property("RuleId"); - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + b.Property("CreatedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); - b.HasKey("FilterListId", "RuleId"); + b.HasKey("FilterListId", "RuleId"); - b.HasIndex("RuleId"); + b.HasIndex("RuleId"); - b.ToTable("filterlists_rules"); - }); + b.ToTable("filterlists_rules"); + }); modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Fork", b => - { - b.Property("ForkFilterListId"); + { + b.Property("ForkFilterListId"); - b.Property("UpstreamFilterListId"); + b.Property("UpstreamFilterListId"); - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + b.Property("CreatedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); - b.HasKey("ForkFilterListId", "UpstreamFilterListId"); + b.HasKey("ForkFilterListId", "UpstreamFilterListId"); - b.HasIndex("UpstreamFilterListId"); + b.HasIndex("UpstreamFilterListId"); - b.ToTable("forks"); - }); + b.ToTable("forks"); + }); modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Merge", b => - { - b.Property("MergeFilterListId"); + { + b.Property("MergeFilterListId"); - b.Property("UpstreamFilterListId"); + b.Property("UpstreamFilterListId"); - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + b.Property("CreatedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); - b.HasKey("MergeFilterListId", "UpstreamFilterListId"); + b.HasKey("MergeFilterListId", "UpstreamFilterListId"); - b.HasIndex("UpstreamFilterListId"); + b.HasIndex("UpstreamFilterListId"); - b.ToTable("merges"); - }); + b.ToTable("merges"); + }); modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SoftwareSyntax", b => - { - b.Property("SoftwareId"); + { + b.Property("SoftwareId"); - b.Property("SyntaxId"); + b.Property("SyntaxId"); - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + b.Property("CreatedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); - b.HasKey("SoftwareId", "SyntaxId"); + b.HasKey("SoftwareId", "SyntaxId"); - b.HasIndex("SyntaxId"); + b.HasIndex("SyntaxId"); - b.ToTable("software_syntaxes"); - }); + b.ToTable("software_syntaxes"); + }); modelBuilder.Entity("FilterLists.Data.Entities.Language", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("SMALLINT UNSIGNED"); - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + b.Property("CreatedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); - b.Property("Iso6391") - .HasColumnType("NVARCHAR(2)"); + b.Property("Iso6391") + .HasColumnType("NVARCHAR(2)"); - b.Property("Iso6392") - .HasColumnType("NVARCHAR(3)"); + b.Property("Iso6392") + .HasColumnType("NVARCHAR(3)"); - b.Property("Iso6392B") - .HasColumnType("NVARCHAR(3)"); + b.Property("Iso6392B") + .HasColumnType("NVARCHAR(3)"); - b.Property("Iso6392T") - .HasColumnType("NVARCHAR(3)"); + b.Property("Iso6392T") + .HasColumnType("NVARCHAR(3)"); - b.Property("Iso6393") - .HasColumnType("NVARCHAR(3)"); + b.Property("Iso6393") + .HasColumnType("NVARCHAR(3)"); - b.Property("LocalName") - .HasColumnType("NVARCHAR(126)"); + b.Property("LocalName") + .HasColumnType("NVARCHAR(126)"); - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + b.Property("ModifiedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); - b.Property("Name") - .HasColumnType("NVARCHAR(126)"); + b.Property("Name") + .HasColumnType("NVARCHAR(126)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("languages"); - }); + b.ToTable("languages"); + }); modelBuilder.Entity("FilterLists.Data.Entities.License", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("SMALLINT UNSIGNED"); - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + b.Property("CreatedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); - b.Property("DescriptionUrl") - .HasColumnType("TEXT"); + b.Property("DescriptionUrl") + .HasColumnType("TEXT"); - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + b.Property("ModifiedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); - b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); + b.Property("Name") + .HasColumnType("NVARCHAR(126) NOT NULL"); - b.Property("PermissiveAdaptation"); + b.Property("PermissiveAdaptation"); - b.Property("PermissiveCommercial"); + b.Property("PermissiveCommercial"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("licenses"); - }); + b.ToTable("licenses"); + }); modelBuilder.Entity("FilterLists.Data.Entities.Maintainer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("SMALLINT UNSIGNED"); - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + b.Property("CreatedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); - b.Property("EmailAddress") - .HasColumnType("NVARCHAR(126)"); + b.Property("EmailAddress") + .HasColumnType("NVARCHAR(126)"); - b.Property("HomeUrl") - .HasColumnType("TEXT"); + b.Property("HomeUrl") + .HasColumnType("TEXT"); - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + b.Property("ModifiedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); - b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); + b.Property("Name") + .HasColumnType("NVARCHAR(126) NOT NULL"); - b.Property("TwitterHandle") - .HasColumnType("NVARCHAR(126)"); + b.Property("TwitterHandle") + .HasColumnType("NVARCHAR(126)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("maintainers"); - }); + b.ToTable("maintainers"); + }); modelBuilder.Entity("FilterLists.Data.Entities.Rule", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("BIGINT UNSIGNED"); - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + b.Property("CreatedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); - b.Property("Raw") - .IsRequired() - .HasColumnType("NVARCHAR(2083)"); + b.Property("Raw") + .HasColumnType("NVARCHAR(2083) NOT NULL"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("rules"); - }); - - modelBuilder.Entity("FilterLists.Data.Entities.Snapshot", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Content") - .IsRequired() - .HasColumnType("MEDIUMTEXT"); - - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); - - b.Property("FilterListId"); - - b.HasKey("Id"); - - b.HasIndex("FilterListId"); - - b.ToTable("snapshots"); - }); + b.ToTable("rules"); + }); modelBuilder.Entity("FilterLists.Data.Entities.Software", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("SMALLINT UNSIGNED"); - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + b.Property("CreatedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); - b.Property("DownloadUrl") - .HasColumnType("TEXT"); + b.Property("DownloadUrl") + .HasColumnType("TEXT"); - b.Property("HomeUrl") - .HasColumnType("TEXT"); + b.Property("HomeUrl") + .HasColumnType("TEXT"); - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + b.Property("ModifiedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); - b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); + b.Property("Name") + .HasColumnType("NVARCHAR(126) NOT NULL"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("software"); - }); + b.ToTable("software"); + }); modelBuilder.Entity("FilterLists.Data.Entities.Syntax", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("SMALLINT UNSIGNED"); - b.Property("CreatedDateUtc") - .ValueGeneratedOnAdd() - .HasColumnType("TIMESTAMP"); + b.Property("CreatedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); - b.Property("DefinitionUrl") - .HasColumnType("TEXT"); + b.Property("DefinitionUrl") + .HasColumnType("TEXT"); - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("TIMESTAMP"); + b.Property("ModifiedDateUtc") + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); - b.Property("Name") - .IsRequired() - .HasColumnType("NVARCHAR(126)"); + b.Property("Name") + .HasColumnType("NVARCHAR(126) NOT NULL"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("syntaxes"); - }); + b.ToTable("syntaxes"); + }); modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b => - { - b.HasOne("FilterLists.Data.Entities.License") - .WithMany("FilterLists") - .HasForeignKey("LicenseId"); + { + b.HasOne("FilterLists.Data.Entities.License") + .WithMany("FilterLists") + .HasForeignKey("LicenseId"); - b.HasOne("FilterLists.Data.Entities.Syntax") - .WithMany("FilterLists") - .HasForeignKey("SyntaxId"); - }); + b.HasOne("FilterLists.Data.Entities.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.FilterList", "FilterList") + .WithMany("FilterListLanguages") + .HasForeignKey("FilterListId") + .OnDelete(DeleteBehavior.Cascade); - b.HasOne("FilterLists.Data.Entities.Language", "Language") - .WithMany("FilterListLanguages") - .HasForeignKey("LanguageId") - .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.FilterList", "FilterList") + .WithMany("FilterListMaintainers") + .HasForeignKey("FilterListId") + .OnDelete(DeleteBehavior.Cascade); - b.HasOne("FilterLists.Data.Entities.Maintainer", "Maintainer") - .WithMany("FilterListMaintainers") - .HasForeignKey("MaintainerId") - .OnDelete(DeleteBehavior.Cascade); - }); + b.HasOne("FilterLists.Data.Entities.Maintainer", "Maintainer") + .WithMany("FilterListMaintainers") + .HasForeignKey("MaintainerId") + .OnDelete(DeleteBehavior.Cascade); + }); modelBuilder.Entity("FilterLists.Data.Entities.Junctions.FilterListRule", b => - { - b.HasOne("FilterLists.Data.Entities.FilterList", "FilterList") - .WithMany("FilterListRules") - .HasForeignKey("FilterListId") - .OnDelete(DeleteBehavior.Cascade); + { + b.HasOne("FilterLists.Data.Entities.FilterList", "FilterList") + .WithMany("FilterListRules") + .HasForeignKey("FilterListId") + .OnDelete(DeleteBehavior.Cascade); - b.HasOne("FilterLists.Data.Entities.Rule", "Rule") - .WithMany("FilterListRules") - .HasForeignKey("RuleId") - .OnDelete(DeleteBehavior.Cascade); - }); + b.HasOne("FilterLists.Data.Entities.Rule", "Rule") + .WithMany("FilterListRules") + .HasForeignKey("RuleId") + .OnDelete(DeleteBehavior.Cascade); + }); modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Fork", b => - { - b.HasOne("FilterLists.Data.Entities.FilterList", "ForkFilterList") - .WithMany() - .HasForeignKey("ForkFilterListId") - .OnDelete(DeleteBehavior.Cascade); + { + b.HasOne("FilterLists.Data.Entities.FilterList", "ForkFilterList") + .WithMany() + .HasForeignKey("ForkFilterListId") + .OnDelete(DeleteBehavior.Cascade); - b.HasOne("FilterLists.Data.Entities.FilterList", "UpstreamFilterList") - .WithMany() - .HasForeignKey("UpstreamFilterListId") - .OnDelete(DeleteBehavior.Cascade); - }); + b.HasOne("FilterLists.Data.Entities.FilterList", "UpstreamFilterList") + .WithMany() + .HasForeignKey("UpstreamFilterListId") + .OnDelete(DeleteBehavior.Cascade); + }); modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Merge", b => - { - b.HasOne("FilterLists.Data.Entities.FilterList", "MergeFilterList") - .WithMany() - .HasForeignKey("MergeFilterListId") - .OnDelete(DeleteBehavior.Cascade); + { + b.HasOne("FilterLists.Data.Entities.FilterList", "MergeFilterList") + .WithMany() + .HasForeignKey("MergeFilterListId") + .OnDelete(DeleteBehavior.Cascade); - b.HasOne("FilterLists.Data.Entities.FilterList", "UpstreamFilterList") - .WithMany() - .HasForeignKey("UpstreamFilterListId") - .OnDelete(DeleteBehavior.Cascade); - }); + b.HasOne("FilterLists.Data.Entities.FilterList", "UpstreamFilterList") + .WithMany() + .HasForeignKey("UpstreamFilterListId") + .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.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") - .WithMany("Snapshots") - .HasForeignKey("FilterListId") - .OnDelete(DeleteBehavior.Cascade); - }); + b.HasOne("FilterLists.Data.Entities.Syntax", "Syntax") + .WithMany("SoftwareSyntaxes") + .HasForeignKey("SyntaxId") + .OnDelete(DeleteBehavior.Cascade); + }); #pragma warning restore 612, 618 } } -} \ No newline at end of file +} diff --git a/src/FilterLists.Data/Entities/BaseEntity.cs b/src/FilterLists.Data/Entities/BaseEntity.cs deleted file mode 100644 index 10c6c1e5c..000000000 --- a/src/FilterLists.Data/Entities/BaseEntity.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace FilterLists.Data.Entities -{ - public abstract class BaseEntity - { - public int Id { get; set; } - public DateTime CreatedDateUtc { get; set; } - } -} \ No newline at end of file diff --git a/src/FilterLists.Data/Entities/FilterList.cs b/src/FilterLists.Data/Entities/FilterList.cs index 3d43c279a..05a3c2ddb 100644 --- a/src/FilterLists.Data/Entities/FilterList.cs +++ b/src/FilterLists.Data/Entities/FilterList.cs @@ -4,25 +4,28 @@ namespace FilterLists.Data.Entities { - public class FilterList : BaseEntity + public class FilterList { + public int Id { get; set; } + public DateTime CreatedDateUtc { get; set; } public DateTime ModifiedDateUtc { get; set; } + public string Description { get; set; } public string DescriptionSourceUrl { get; set; } public DateTime? DiscontinuedDate { get; set; } public string DonateUrl { get; set; } public string EmailAddress { get; set; } - public ICollection FilterListLanguages { get; set; } - public ICollection FilterListMaintainers { get; set; } - public ICollection FilterListRules { get; set; } public string ForumUrl { get; set; } public string HomeUrl { get; set; } public string IssuesUrl { get; set; } public int? LicenseId { get; set; } public string Name { get; set; } - public ICollection Snapshots { get; set; } public string SubmissionUrl { get; set; } public int? SyntaxId { get; set; } public string ViewUrl { get; set; } + + public ICollection FilterListLanguages { get; set; } + public ICollection FilterListMaintainers { get; set; } + public ICollection FilterListRules { get; set; } } } \ No newline at end of file diff --git a/src/FilterLists.Data/Entities/Junctions/FilterListLanguage.cs b/src/FilterLists.Data/Entities/Junctions/FilterListLanguage.cs index 58d6c3254..69696ceb7 100644 --- a/src/FilterLists.Data/Entities/Junctions/FilterListLanguage.cs +++ b/src/FilterLists.Data/Entities/Junctions/FilterListLanguage.cs @@ -1,7 +1,11 @@ -namespace FilterLists.Data.Entities.Junctions +using System; + +namespace FilterLists.Data.Entities.Junctions { - public class FilterListLanguage : BaseEntity + public class FilterListLanguage { + public DateTime CreatedDateUtc { get; set; } + public int FilterListId { get; set; } public FilterList FilterList { get; set; } diff --git a/src/FilterLists.Data/Entities/Junctions/FilterListMaintainer.cs b/src/FilterLists.Data/Entities/Junctions/FilterListMaintainer.cs index 3a8aeac0e..c68b16eb7 100644 --- a/src/FilterLists.Data/Entities/Junctions/FilterListMaintainer.cs +++ b/src/FilterLists.Data/Entities/Junctions/FilterListMaintainer.cs @@ -1,7 +1,11 @@ -namespace FilterLists.Data.Entities.Junctions +using System; + +namespace FilterLists.Data.Entities.Junctions { - public class FilterListMaintainer : BaseEntity + public class FilterListMaintainer { + public DateTime CreatedDateUtc { get; set; } + public int FilterListId { get; set; } public FilterList FilterList { get; set; } diff --git a/src/FilterLists.Data/Entities/Junctions/FilterListRule.cs b/src/FilterLists.Data/Entities/Junctions/FilterListRule.cs index 406814a8a..03fba3384 100644 --- a/src/FilterLists.Data/Entities/Junctions/FilterListRule.cs +++ b/src/FilterLists.Data/Entities/Junctions/FilterListRule.cs @@ -1,7 +1,11 @@ -namespace FilterLists.Data.Entities.Junctions +using System; + +namespace FilterLists.Data.Entities.Junctions { - public class FilterListRule : BaseEntity + public class FilterListRule { + public DateTime CreatedDateUtc { get; set; } + public int FilterListId { get; set; } public FilterList FilterList { get; set; } diff --git a/src/FilterLists.Data/Entities/Junctions/Fork.cs b/src/FilterLists.Data/Entities/Junctions/Fork.cs index b2dc13952..6e43f2723 100644 --- a/src/FilterLists.Data/Entities/Junctions/Fork.cs +++ b/src/FilterLists.Data/Entities/Junctions/Fork.cs @@ -1,7 +1,11 @@ -namespace FilterLists.Data.Entities.Junctions +using System; + +namespace FilterLists.Data.Entities.Junctions { - public class Fork : BaseEntity + public class Fork { + public DateTime CreatedDateUtc { get; set; } + public int ForkFilterListId { get; set; } public FilterList ForkFilterList { get; set; } diff --git a/src/FilterLists.Data/Entities/Junctions/Merge.cs b/src/FilterLists.Data/Entities/Junctions/Merge.cs index 3b19f4e9e..3528b3f44 100644 --- a/src/FilterLists.Data/Entities/Junctions/Merge.cs +++ b/src/FilterLists.Data/Entities/Junctions/Merge.cs @@ -1,7 +1,11 @@ -namespace FilterLists.Data.Entities.Junctions +using System; + +namespace FilterLists.Data.Entities.Junctions { - public class Merge : BaseEntity + public class Merge { + public DateTime CreatedDateUtc { get; set; } + public int MergeFilterListId { get; set; } public FilterList MergeFilterList { get; set; } diff --git a/src/FilterLists.Data/Entities/Junctions/SoftwareSyntax.cs b/src/FilterLists.Data/Entities/Junctions/SoftwareSyntax.cs index 247e214ca..3f9fb6e83 100644 --- a/src/FilterLists.Data/Entities/Junctions/SoftwareSyntax.cs +++ b/src/FilterLists.Data/Entities/Junctions/SoftwareSyntax.cs @@ -1,7 +1,11 @@ -namespace FilterLists.Data.Entities.Junctions +using System; + +namespace FilterLists.Data.Entities.Junctions { - public class SoftwareSyntax : BaseEntity + public class SoftwareSyntax { + public DateTime CreatedDateUtc { get; set; } + public int SoftwareId { get; set; } public Software Software { get; set; } diff --git a/src/FilterLists.Data/Entities/Language.cs b/src/FilterLists.Data/Entities/Language.cs index d8b0760f7..8ce4c8043 100644 --- a/src/FilterLists.Data/Entities/Language.cs +++ b/src/FilterLists.Data/Entities/Language.cs @@ -4,10 +4,12 @@ namespace FilterLists.Data.Entities { - public class Language : BaseEntity + public class Language { + public int Id { get; set; } + public DateTime CreatedDateUtc { get; set; } public DateTime ModifiedDateUtc { get; set; } - public ICollection FilterListLanguages { get; set; } + public string Iso6391 { get; set; } public string Iso6392 { get; set; } public string Iso6392B { get; set; } @@ -15,5 +17,7 @@ public class Language : BaseEntity public string Iso6393 { get; set; } public string LocalName { get; set; } public string Name { get; set; } + + public ICollection FilterListLanguages { get; set; } } } \ No newline at end of file diff --git a/src/FilterLists.Data/Entities/License.cs b/src/FilterLists.Data/Entities/License.cs index 22a16d8b4..d36f5e58a 100644 --- a/src/FilterLists.Data/Entities/License.cs +++ b/src/FilterLists.Data/Entities/License.cs @@ -3,9 +3,12 @@ namespace FilterLists.Data.Entities { - public class License : BaseEntity + public class License { + public int Id { get; set; } + public DateTime CreatedDateUtc { get; set; } public DateTime ModifiedDateUtc { get; set; } + public string DescriptionUrl { get; set; } public ICollection FilterLists { get; set; } public string Name { get; set; } diff --git a/src/FilterLists.Data/Entities/Maintainer.cs b/src/FilterLists.Data/Entities/Maintainer.cs index 5db1cd6b0..ecf64541d 100644 --- a/src/FilterLists.Data/Entities/Maintainer.cs +++ b/src/FilterLists.Data/Entities/Maintainer.cs @@ -4,13 +4,17 @@ namespace FilterLists.Data.Entities { - public class Maintainer : BaseEntity + public class Maintainer { + public int Id { get; set; } + public DateTime CreatedDateUtc { get; set; } public DateTime ModifiedDateUtc { get; set; } + public string EmailAddress { get; set; } - public ICollection FilterListMaintainers { get; set; } public string HomeUrl { get; set; } public string Name { get; set; } public string TwitterHandle { get; set; } + + public ICollection FilterListMaintainers { get; set; } } } \ No newline at end of file diff --git a/src/FilterLists.Data/Entities/Rule.cs b/src/FilterLists.Data/Entities/Rule.cs index 41b15b313..03c91ec22 100644 --- a/src/FilterLists.Data/Entities/Rule.cs +++ b/src/FilterLists.Data/Entities/Rule.cs @@ -1,11 +1,16 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using FilterLists.Data.Entities.Junctions; namespace FilterLists.Data.Entities { - public class Rule : BaseEntity + public class Rule { - public ICollection FilterListRules { get; set; } + public int Id { get; set; } + public DateTime CreatedDateUtc { get; set; } + public string Raw { get; set; } + + public ICollection FilterListRules { get; set; } } } \ No newline at end of file diff --git a/src/FilterLists.Data/Entities/Snapshot.cs b/src/FilterLists.Data/Entities/Snapshot.cs deleted file mode 100644 index 6b9ced6a4..000000000 --- a/src/FilterLists.Data/Entities/Snapshot.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace FilterLists.Data.Entities -{ - public class Snapshot : BaseEntity - { - public string Content { get; set; } - public int FilterListId { get; set; } - } -} \ No newline at end of file diff --git a/src/FilterLists.Data/Entities/Software.cs b/src/FilterLists.Data/Entities/Software.cs index 380297260..1651bad43 100644 --- a/src/FilterLists.Data/Entities/Software.cs +++ b/src/FilterLists.Data/Entities/Software.cs @@ -4,12 +4,16 @@ namespace FilterLists.Data.Entities { - public class Software : BaseEntity + public class Software { + public int Id { get; set; } + public DateTime CreatedDateUtc { get; set; } public DateTime ModifiedDateUtc { get; set; } + public string DownloadUrl { get; set; } public string HomeUrl { get; set; } public string Name { get; set; } + public ICollection SoftwareSyntaxes { get; set; } } } \ No newline at end of file diff --git a/src/FilterLists.Data/Entities/Syntax.cs b/src/FilterLists.Data/Entities/Syntax.cs index d7c5e86e4..f9ca4ed21 100644 --- a/src/FilterLists.Data/Entities/Syntax.cs +++ b/src/FilterLists.Data/Entities/Syntax.cs @@ -4,12 +4,16 @@ namespace FilterLists.Data.Entities { - public class Syntax : BaseEntity + public class Syntax { + public int Id { get; set; } + public DateTime CreatedDateUtc { get; set; } public DateTime ModifiedDateUtc { get; set; } + public string DefinitionUrl { get; set; } public ICollection FilterLists { get; set; } public string Name { get; set; } + public ICollection SoftwareSyntaxes { get; set; } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/BaseEntityConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/BaseEntityConfiguration.cs deleted file mode 100644 index 0fb6e84b6..000000000 --- a/src/FilterLists.Data/EntityTypeConfigurations/BaseEntityConfiguration.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FilterLists.Data.Entities; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace FilterLists.Data.EntityTypeConfigurations -{ - public class BaseEntityTypeConfiguration : IEntityTypeConfiguration where TBase : BaseEntity - { - public virtual void Configure(EntityTypeBuilder entityTypeBuilder) - { - entityTypeBuilder.Property(x => x.CreatedDateUtc) - .HasColumnType("TIMESTAMP") - .ValueGeneratedOnAdd(); - } - } -} \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/FilterListTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/FilterListTypeConfiguration.cs index e0f103e86..4a68b0c72 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/FilterListTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/FilterListTypeConfiguration.cs @@ -4,14 +4,19 @@ namespace FilterLists.Data.EntityTypeConfigurations { - public class FilterListTypeConfiguration : BaseEntityTypeConfiguration + public class FilterListTypeConfiguration : IEntityTypeConfiguration { - public override void Configure(EntityTypeBuilder entityTypeBuilder) + public void Configure(EntityTypeBuilder entityTypeBuilder) { entityTypeBuilder.ToTable("filterlists"); + + entityTypeBuilder.Property(x => x.Id) + .HasColumnType("SMALLINT UNSIGNED"); + entityTypeBuilder.Property(x => x.CreatedDateUtc) + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); entityTypeBuilder.Property(x => x.ModifiedDateUtc) - .HasColumnType("TIMESTAMP") - .ValueGeneratedOnAddOrUpdate(); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); + entityTypeBuilder.Property(x => x.Description) .HasColumnType("TEXT"); entityTypeBuilder.Property(x => x.DescriptionSourceUrl) @@ -27,13 +32,11 @@ public override void Configure(EntityTypeBuilder entityTypeBuilder) entityTypeBuilder.Property(x => x.IssuesUrl) .HasColumnType("TEXT"); entityTypeBuilder.Property(x => x.Name) - .HasColumnType("NVARCHAR(126)") - .IsRequired(); + .HasColumnType("NVARCHAR(126) NOT NULL"); entityTypeBuilder.Property(x => x.SubmissionUrl) .HasColumnType("TEXT"); entityTypeBuilder.Property(x => x.ViewUrl) - .HasColumnType("TEXT"); - base.Configure(entityTypeBuilder); + .HasColumnType("TEXT NOT NULL"); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs index 1e462ba2e..5dfeb125c 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs @@ -4,14 +4,14 @@ namespace FilterLists.Data.EntityTypeConfigurations.Junctions { - public class FilterListLanguageTypeConfiguration : BaseEntityTypeConfiguration + public class FilterListLanguageTypeConfiguration : IEntityTypeConfiguration { - public override void Configure(EntityTypeBuilder entityTypeBuilder) + public void Configure(EntityTypeBuilder entityTypeBuilder) { entityTypeBuilder.ToTable("filterlists_languages"); entityTypeBuilder.HasKey(x => new {x.FilterListId, x.LanguageId}); - entityTypeBuilder.Ignore(x => x.Id); - base.Configure(entityTypeBuilder); + entityTypeBuilder.Property(x => x.CreatedDateUtc) + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListMaintainerTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListMaintainerTypeConfiguration.cs index ee6746836..a9bb26b2d 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListMaintainerTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListMaintainerTypeConfiguration.cs @@ -4,14 +4,14 @@ namespace FilterLists.Data.EntityTypeConfigurations.Junctions { - public class FilterListMaintainerTypeConfiguration : BaseEntityTypeConfiguration + public class FilterListMaintainerTypeConfiguration : IEntityTypeConfiguration { - public override void Configure(EntityTypeBuilder entityTypeBuilder) + public void Configure(EntityTypeBuilder entityTypeBuilder) { entityTypeBuilder.ToTable("filterlists_maintainers"); entityTypeBuilder.HasKey(x => new {x.FilterListId, x.MaintainerId}); - entityTypeBuilder.Ignore(x => x.Id); - base.Configure(entityTypeBuilder); + entityTypeBuilder.Property(x => x.CreatedDateUtc) + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListRuleTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListRuleTypeConfiguration.cs index c67d4e184..1ed2ad5bc 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListRuleTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListRuleTypeConfiguration.cs @@ -4,14 +4,14 @@ namespace FilterLists.Data.EntityTypeConfigurations.Junctions { - public class FilterListRuleTypeConfiguration : BaseEntityTypeConfiguration + public class FilterListRuleTypeConfiguration : IEntityTypeConfiguration { - public override void Configure(EntityTypeBuilder entityTypeBuilder) + public void Configure(EntityTypeBuilder entityTypeBuilder) { entityTypeBuilder.ToTable("filterlists_rules"); entityTypeBuilder.HasKey(x => new {x.FilterListId, x.RuleId}); - entityTypeBuilder.Ignore(x => x.Id); - base.Configure(entityTypeBuilder); + entityTypeBuilder.Property(x => x.CreatedDateUtc) + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/ForkTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/ForkTypeConfiguration.cs index c2b4aae21..5871f94dd 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/ForkTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/ForkTypeConfiguration.cs @@ -4,14 +4,14 @@ namespace FilterLists.Data.EntityTypeConfigurations.Junctions { - public class ForkTypeConfiguration : BaseEntityTypeConfiguration + public class ForkTypeConfiguration : IEntityTypeConfiguration { - public override void Configure(EntityTypeBuilder entityTypeBuilder) + public void Configure(EntityTypeBuilder entityTypeBuilder) { entityTypeBuilder.ToTable("forks"); entityTypeBuilder.HasKey(x => new {x.ForkFilterListId, x.UpstreamFilterListId}); - entityTypeBuilder.Ignore(x => x.Id); - base.Configure(entityTypeBuilder); + entityTypeBuilder.Property(x => x.CreatedDateUtc) + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/MergeTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/MergeTypeConfiguration.cs index f5a8a9bf1..f3f052f03 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/MergeTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/MergeTypeConfiguration.cs @@ -4,14 +4,14 @@ namespace FilterLists.Data.EntityTypeConfigurations.Junctions { - public class MergeTypeConfiguration : BaseEntityTypeConfiguration + public class MergeTypeConfiguration : IEntityTypeConfiguration { - public override void Configure(EntityTypeBuilder entityTypeBuilder) + public void Configure(EntityTypeBuilder entityTypeBuilder) { entityTypeBuilder.ToTable("merges"); entityTypeBuilder.HasKey(x => new {x.MergeFilterListId, x.UpstreamFilterListId}); - entityTypeBuilder.Ignore(x => x.Id); - base.Configure(entityTypeBuilder); + entityTypeBuilder.Property(x => x.CreatedDateUtc) + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs index 4121b3908..425a8597f 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs @@ -4,14 +4,14 @@ namespace FilterLists.Data.EntityTypeConfigurations.Junctions { - public class SoftwareSyntaxTypeConfiguration : BaseEntityTypeConfiguration + public class SoftwareSyntaxTypeConfiguration : IEntityTypeConfiguration { - public override void Configure(EntityTypeBuilder entityTypeBuilder) + public void Configure(EntityTypeBuilder entityTypeBuilder) { entityTypeBuilder.ToTable("software_syntaxes"); entityTypeBuilder.HasKey(x => new {x.SoftwareId, x.SyntaxId}); - entityTypeBuilder.Ignore(x => x.Id); - base.Configure(entityTypeBuilder); + entityTypeBuilder.Property(x => x.CreatedDateUtc) + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/LanguageTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/LanguageTypeConfiguration.cs index c2a74ae00..77d40eac1 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/LanguageTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/LanguageTypeConfiguration.cs @@ -4,14 +4,19 @@ namespace FilterLists.Data.EntityTypeConfigurations { - public class LanguageTypeConfiguration : BaseEntityTypeConfiguration + public class LanguageTypeConfiguration : IEntityTypeConfiguration { - public override void Configure(EntityTypeBuilder entityTypeBuilder) + public void Configure(EntityTypeBuilder entityTypeBuilder) { entityTypeBuilder.ToTable("languages"); + + entityTypeBuilder.Property(x => x.Id) + .HasColumnType("SMALLINT UNSIGNED"); + entityTypeBuilder.Property(x => x.CreatedDateUtc) + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); entityTypeBuilder.Property(x => x.ModifiedDateUtc) - .HasColumnType("TIMESTAMP") - .ValueGeneratedOnAddOrUpdate(); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); + entityTypeBuilder.Property(x => x.Iso6391) .HasColumnType("NVARCHAR(2)"); entityTypeBuilder.Property(x => x.Iso6392) @@ -26,7 +31,6 @@ public override void Configure(EntityTypeBuilder entityTypeBuilder) .HasColumnType("NVARCHAR(126)"); entityTypeBuilder.Property(x => x.Name) .HasColumnType("NVARCHAR(126)"); - base.Configure(entityTypeBuilder); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/LicenseTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/LicenseTypeConfiguration.cs index e76bad580..5c794086e 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/LicenseTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/LicenseTypeConfiguration.cs @@ -4,20 +4,23 @@ namespace FilterLists.Data.EntityTypeConfigurations { - public class LicenseTypeConfiguration : BaseEntityTypeConfiguration + public class LicenseTypeConfiguration : IEntityTypeConfiguration { - public override void Configure(EntityTypeBuilder entityTypeBuilder) + public void Configure(EntityTypeBuilder entityTypeBuilder) { entityTypeBuilder.ToTable("licenses"); + + entityTypeBuilder.Property(x => x.Id) + .HasColumnType("SMALLINT UNSIGNED"); + entityTypeBuilder.Property(x => x.CreatedDateUtc) + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); entityTypeBuilder.Property(x => x.ModifiedDateUtc) - .HasColumnType("TIMESTAMP") - .ValueGeneratedOnAddOrUpdate(); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); + entityTypeBuilder.Property(x => x.DescriptionUrl) .HasColumnType("TEXT"); entityTypeBuilder.Property(x => x.Name) - .HasColumnType("NVARCHAR(126)") - .IsRequired(); - base.Configure(entityTypeBuilder); + .HasColumnType("NVARCHAR(126) NOT NULL"); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/MaintainerTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/MaintainerTypeConfiguration.cs index fa5278675..12f88836e 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/MaintainerTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/MaintainerTypeConfiguration.cs @@ -4,24 +4,27 @@ namespace FilterLists.Data.EntityTypeConfigurations { - public class MaintainerTypeConfiguration : BaseEntityTypeConfiguration + public class MaintainerTypeConfiguration : IEntityTypeConfiguration { - public override void Configure(EntityTypeBuilder entityTypeBuilder) + public void Configure(EntityTypeBuilder entityTypeBuilder) { entityTypeBuilder.ToTable("maintainers"); + + entityTypeBuilder.Property(x => x.Id) + .HasColumnType("SMALLINT UNSIGNED"); + entityTypeBuilder.Property(x => x.CreatedDateUtc) + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); entityTypeBuilder.Property(x => x.ModifiedDateUtc) - .HasColumnType("TIMESTAMP") - .ValueGeneratedOnAddOrUpdate(); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); + entityTypeBuilder.Property(x => x.EmailAddress) .HasColumnType("NVARCHAR(126)"); entityTypeBuilder.Property(x => x.HomeUrl) .HasColumnType("TEXT"); entityTypeBuilder.Property(x => x.Name) - .HasColumnType("NVARCHAR(126)") - .IsRequired(); + .HasColumnType("NVARCHAR(126) NOT NULL"); entityTypeBuilder.Property(x => x.TwitterHandle) .HasColumnType("NVARCHAR(126)"); - base.Configure(entityTypeBuilder); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/RuleTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/RuleTypeConfiguration.cs index 3f6670de3..733c800e9 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/RuleTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/RuleTypeConfiguration.cs @@ -4,15 +4,19 @@ namespace FilterLists.Data.EntityTypeConfigurations { - public class RuleTypeConfiguration : BaseEntityTypeConfiguration + public class RuleTypeConfiguration : IEntityTypeConfiguration { - public override void Configure(EntityTypeBuilder entityTypeBuilder) + public void Configure(EntityTypeBuilder entityTypeBuilder) { entityTypeBuilder.ToTable("rules"); + + entityTypeBuilder.Property(x => x.Id) + .HasColumnType("BIGINT UNSIGNED"); + entityTypeBuilder.Property(x => x.CreatedDateUtc) + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); + entityTypeBuilder.Property(x => x.Raw) - .HasColumnType("NVARCHAR(2083)") - .IsRequired(); - base.Configure(entityTypeBuilder); + .HasColumnType("NVARCHAR(2083) NOT NULL"); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/SnapshotTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/SnapshotTypeConfiguration.cs deleted file mode 100644 index 2582c927e..000000000 --- a/src/FilterLists.Data/EntityTypeConfigurations/SnapshotTypeConfiguration.cs +++ /dev/null @@ -1,18 +0,0 @@ -using FilterLists.Data.Entities; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace FilterLists.Data.EntityTypeConfigurations -{ - public class SnapshotTypeConfiguration : BaseEntityTypeConfiguration - { - public override void Configure(EntityTypeBuilder entityTypeBuilder) - { - entityTypeBuilder.ToTable("snapshots"); - entityTypeBuilder.Property(x => x.Content) - .HasColumnType("MEDIUMTEXT") - .IsRequired(); - base.Configure(entityTypeBuilder); - } - } -} \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/SoftwareTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/SoftwareTypeConfiguration.cs index f0026e115..893b5312d 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/SoftwareTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/SoftwareTypeConfiguration.cs @@ -4,22 +4,25 @@ namespace FilterLists.Data.EntityTypeConfigurations { - public class SoftwareTypeConfiguration : BaseEntityTypeConfiguration + public class SoftwareTypeConfiguration : IEntityTypeConfiguration { - public override void Configure(EntityTypeBuilder entityTypeBuilder) + public void Configure(EntityTypeBuilder entityTypeBuilder) { entityTypeBuilder.ToTable("software"); + + entityTypeBuilder.Property(x => x.Id) + .HasColumnType("SMALLINT UNSIGNED"); + entityTypeBuilder.Property(x => x.CreatedDateUtc) + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); entityTypeBuilder.Property(x => x.ModifiedDateUtc) - .HasColumnType("TIMESTAMP") - .ValueGeneratedOnAddOrUpdate(); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); + entityTypeBuilder.Property(x => x.DownloadUrl) .HasColumnType("TEXT"); entityTypeBuilder.Property(x => x.HomeUrl) .HasColumnType("TEXT"); entityTypeBuilder.Property(x => x.Name) - .HasColumnType("NVARCHAR(126)") - .IsRequired(); - base.Configure(entityTypeBuilder); + .HasColumnType("NVARCHAR(126) NOT NULL"); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/SyntaxTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/SyntaxTypeConfiguration.cs index 6ca7c03d6..bfd9ed45d 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/SyntaxTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/SyntaxTypeConfiguration.cs @@ -4,20 +4,23 @@ namespace FilterLists.Data.EntityTypeConfigurations { - public class SyntaxTypeConfiguration : BaseEntityTypeConfiguration + public class SyntaxTypeConfiguration : IEntityTypeConfiguration { - public override void Configure(EntityTypeBuilder entityTypeBuilder) + public void Configure(EntityTypeBuilder entityTypeBuilder) { entityTypeBuilder.ToTable("syntaxes"); + + entityTypeBuilder.Property(x => x.Id) + .HasColumnType("SMALLINT UNSIGNED"); + entityTypeBuilder.Property(x => x.CreatedDateUtc) + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); entityTypeBuilder.Property(x => x.ModifiedDateUtc) - .HasColumnType("TIMESTAMP") - .ValueGeneratedOnAddOrUpdate(); + .HasColumnType("TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"); + entityTypeBuilder.Property(x => x.DefinitionUrl) .HasColumnType("TEXT"); entityTypeBuilder.Property(x => x.Name) - .HasColumnType("NVARCHAR(126)") - .IsRequired(); - base.Configure(entityTypeBuilder); + .HasColumnType("NVARCHAR(126) NOT NULL"); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/FilterListsDbContext.cs b/src/FilterLists.Data/FilterListsDbContext.cs index 47b262081..7e86403ea 100644 --- a/src/FilterLists.Data/FilterListsDbContext.cs +++ b/src/FilterLists.Data/FilterListsDbContext.cs @@ -27,7 +27,6 @@ private static void ApplyConfigurationsEntities(ModelBuilder modelBuilder) modelBuilder.ApplyConfiguration(new LicenseTypeConfiguration()); modelBuilder.ApplyConfiguration(new MaintainerTypeConfiguration()); modelBuilder.ApplyConfiguration(new RuleTypeConfiguration()); - modelBuilder.ApplyConfiguration(new SnapshotTypeConfiguration()); modelBuilder.ApplyConfiguration(new SoftwareTypeConfiguration()); modelBuilder.ApplyConfiguration(new SyntaxTypeConfiguration()); } @@ -49,7 +48,6 @@ private static void ApplyConfigurationsJunctions(ModelBuilder modelBuilder) public DbSet Licenses { get; set; } public DbSet Maintainers { get; set; } public DbSet Rules { get; set; } - public DbSet Snapshots { get; set; } public DbSet Software { get; set; } public DbSet Syntaxes { get; set; } diff --git a/src/FilterLists.Data/Seed/Extensions/SeedFilterListsDbContext.cs b/src/FilterLists.Data/Seed/Extensions/SeedFilterListsDbContext.cs index 85a607083..21a51cd61 100644 --- a/src/FilterLists.Data/Seed/Extensions/SeedFilterListsDbContext.cs +++ b/src/FilterLists.Data/Seed/Extensions/SeedFilterListsDbContext.cs @@ -47,8 +47,8 @@ private static void InsertOnDuplicateKeyUpdate(this DbContext dbCon private static List GetPropertiesLessValueGeneratedTimestamps(IEntityType entityType) { - return entityType.GetProperties() - .Where(x => x.ClrType != typeof(DateTime) || x.ValueGenerated == ValueGenerated.Never).ToList(); + return entityType.GetProperties().Where(x => x.Name != "CreatedDateUtc" && x.Name != "ModifiedDateUtc") + .ToList(); } private static string CreateValues(IReadOnlyCollection properties, string dataPath) diff --git a/src/FilterLists.Services/Services/ScrapeService.cs b/src/FilterLists.Services/Services/ScrapeService.cs index 65f5bbcef..6a934387b 100644 --- a/src/FilterLists.Services/Services/ScrapeService.cs +++ b/src/FilterLists.Services/Services/ScrapeService.cs @@ -20,6 +20,7 @@ public ScrapeService(FilterListsDbContext filterListsDbContext) public async Task Scrape() { + //TEMP: remove Take(1) when algorithm complete var lists = await filterListsDbContext.FilterLists.Take(1).ToListAsync(); foreach (var list in lists) await ScrapeList(list); } @@ -37,7 +38,6 @@ private async Task ScrapeList(FilterList list) return; } - await AddSnapshot(list.Id, snapshot); await AddRules(list, snapshot); } @@ -55,24 +55,6 @@ private static async Task GetContent(string url) return null; } - private async Task AddSnapshot(int listId, string snapshot) - { - filterListsDbContext.Snapshots.Add(new Snapshot - { - Content = snapshot, - FilterListId = listId - }); - - try - { - await filterListsDbContext.SaveChangesAsync(); - } - catch (Exception) - { - //TODO: log exception - } - } - private async Task AddRules(FilterList list, string snapshot) { var lines = snapshot.Split(new[] {"\r\n", "\r", "\n"}, StringSplitOptions.None);