add 1st migration, seed Languages

This commit is contained in:
Collin M. Barrett 2017-10-27 20:51:54 -05:00
parent 14f19ea147
commit 6fd07f3966
8 changed files with 2673 additions and 1771 deletions

View file

@ -1,32 +1,45 @@
{
"Email": "john.smith@protonmail.com",
"FilterLists": [
{
"Languages": null,
"Description": "A sample list to filter out advertisements.",
"DescriptionSourceUrl": "https://mysample.list/advertisements",
"DonateUrl": "https://mysample.list/donate/",
"Email": "contact@mysample.list",
"EmailAddress": "contact@mysample.list",
"ForumUrl": "https://mysample.list/forum/",
"HomeUrl": "https://mysample.list/",
"IssuesUrl": "https://github.com/johnsmith/mysamplelist/issues",
"FilterListLanguages": null,
"FilterListSoftware": null,
"MaintainerId": 0,
"Name": "My Sample Advertisement Filter List",
"ViewUrl": "https://mysample.list/list.txt"
"ViewUrl": "https://mysample.list/list.txt",
"Id": 0,
"CreatedDateUtc": "0001-01-01T00:00:00",
"ModifiedDateUtc": "0001-01-01T00:00:00"
},
{
"Languages": null,
"Description": "A sample list to filter out malware.",
"DescriptionSourceUrl": "https://mysample.list/malware",
"DonateUrl": "https://mysample.list/donate/",
"Email": "contact@mysample.list",
"EmailAddress": "contact@mysample.list",
"ForumUrl": "https://mysample.list/forum/",
"HomeUrl": "https://mysample.list/",
"IssuesUrl": "https://github.com/johnsmith/mysamplelist/issues",
"FilterListLanguages": null,
"FilterListSoftware": null,
"MaintainerId": 0,
"Name": "My Sample Malware Filter List",
"ViewUrl": "https://mysample.list/list.txt"
"ViewUrl": "https://mysample.list/list.txt",
"Id": 0,
"CreatedDateUtc": "0001-01-01T00:00:00",
"ModifiedDateUtc": "0001-01-01T00:00:00"
}
],
"Email": "john.smith@protonmail.com",
"HomeUrl": "https://johnsmith.com",
"Name": "John Smith",
"TwitterHandle": "@johnsmith"
"TwitterHandle": "@johnsmith",
"Id": 0,
"CreatedDateUtc": "0001-01-01T00:00:00",
"ModifiedDateUtc": "0001-01-01T00:00:00"
}

View file

@ -6,107 +6,189 @@
"null"
],
"properties": {
"Languages": {
"Description": {
"type": [
"string",
"null"
]
},
"DescriptionSourceUrl": {
"type": [
"string",
"null"
]
},
"DonateUrl": {
"type": [
"string",
"null"
]
},
"EmailAddress": {
"type": [
"string",
"null"
]
},
"ForumUrl": {
"type": [
"string",
"null"
]
},
"HomeUrl": {
"type": [
"string",
"null"
]
},
"IssuesUrl": {
"type": [
"string",
"null"
]
},
"FilterListLanguages": {
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/Language"
"$ref": "#/definitions/FilterListLanguage"
}
},
"Description": {
"description": "A brief description of the list's functionality. Preferably, this is quoted (if non-English, translate to English via translator or Google Translate for consistency) from the list's documentation or composed by a maintainer of the list. If neither are available, a generic description should be composed by the FilterLists contributor.",
"FilterListSoftware": {
"type": [
"string",
"array",
"null"
],
"maxLength": 1022
"items": {
"$ref": "#/definitions/FilterListSoftware"
}
},
"DescriptionSourceUrl": {
"description": "The URL to the list's documentation page from which the description was quoted if applicable.",
"type": [
"string",
"null"
],
"minLength": 6,
"maxLength": 2083,
"format": "uri"
},
"DonateUrl": {
"description": "The URL to the list's donation page. This could be a custom PayPal or similar link, or a link to a web page discussing various donation options. Pull requests that include changes to this link will undergo further verification to prevent fraud.",
"type": [
"string",
"null"
],
"minLength": 6,
"maxLength": 2083,
"format": "uri"
},
"Email": {
"description": "The email address of the list's maintainer(s) if publicly available.",
"type": [
"string",
"null"
],
"minLength": 7,
"maxLength": 126,
"format": "email"
},
"ForumUrl": {
"description": "The URL to the list's forum where issues, change requests, etc. are discussed.",
"type": [
"string",
"null"
],
"minLength": 6,
"maxLength": 2083,
"format": "uri"
},
"HomeUrl": {
"description": "The URL to the list's home page. Preferably, this is stated in the header of the list. Alternatively, it could be a custom domain, GitHub page, blog post, forum post, etc. that serves as a primary source of information for the list.",
"type": [
"string",
"null"
],
"minLength": 6,
"maxLength": 2083,
"format": "uri"
},
"IssuesUrl": {
"description": "The URL to the list's GitHub Issues.",
"type": [
"string",
"null"
],
"minLength": 6,
"maxLength": 2083,
"format": "uri"
"MaintainerId": {
"type": "integer"
},
"Name": {
"description": "The name of the list as stated by the list maintainer(s) in title case.",
"type": "string",
"maxLength": 126
"type": [
"string",
"null"
]
},
"ViewUrl": {
"description": "The URL to the list in raw text format. zip files and other formats are acceptable if no text format is available.",
"type": [
"string",
"null"
]
},
"Id": {
"type": "integer"
},
"CreatedDateUtc": {
"type": "string",
"minLength": 6,
"maxLength": 2083,
"format": "uri"
"format": "date-time"
},
"ModifiedDateUtc": {
"type": "string",
"format": "date-time"
}
},
"required": [
"Languages",
"Description",
"DescriptionSourceUrl",
"DonateUrl",
"Email",
"EmailAddress",
"ForumUrl",
"HomeUrl",
"IssuesUrl",
"FilterListLanguages",
"FilterListSoftware",
"MaintainerId",
"Name",
"ViewUrl"
"ViewUrl",
"Id",
"CreatedDateUtc",
"ModifiedDateUtc"
]
},
"FilterListLanguage": {
"type": [
"object",
"null"
],
"properties": {
"FilterListId": {
"type": "integer"
},
"FilterList": {
"$ref": "#/definitions/FilterList"
},
"LanguageId": {
"type": "integer"
},
"Language": {
"$ref": "#/definitions/Language"
},
"Id": {
"type": "integer"
},
"CreatedDateUtc": {
"type": "string",
"format": "date-time"
},
"ModifiedDateUtc": {
"type": "string",
"format": "date-time"
}
},
"required": [
"FilterListId",
"FilterList",
"LanguageId",
"Language",
"Id",
"CreatedDateUtc",
"ModifiedDateUtc"
]
},
"FilterListSoftware": {
"type": [
"object",
"null"
],
"properties": {
"FilterListId": {
"type": "integer"
},
"FilterList": {
"$ref": "#/definitions/FilterList"
},
"SoftwareId": {
"type": "integer"
},
"Software": {
"$ref": "#/definitions/Software"
},
"Id": {
"type": "integer"
},
"CreatedDateUtc": {
"type": "string",
"format": "date-time"
},
"ModifiedDateUtc": {
"type": "string",
"format": "date-time"
}
},
"required": [
"FilterListId",
"FilterList",
"SoftwareId",
"Software",
"Id",
"CreatedDateUtc",
"ModifiedDateUtc"
]
},
"Language": {
@ -115,6 +197,15 @@
"null"
],
"properties": {
"FilterListLanguages": {
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/FilterListLanguage"
}
},
"Iso6391": {
"type": [
"string",
@ -156,21 +247,97 @@
"string",
"null"
]
},
"Id": {
"type": "integer"
},
"CreatedDateUtc": {
"type": "string",
"format": "date-time"
},
"ModifiedDateUtc": {
"type": "string",
"format": "date-time"
}
},
"required": [
"FilterListLanguages",
"Iso6391",
"Iso6392",
"Iso6392B",
"Iso6392T",
"Iso6393",
"LocalName",
"Name"
"Name",
"Id",
"CreatedDateUtc",
"ModifiedDateUtc"
]
},
"Software": {
"type": [
"object",
"null"
],
"properties": {
"DownloadUrl": {
"type": [
"string",
"null"
]
},
"HomeUrl": {
"type": [
"string",
"null"
]
},
"FilterListSoftware": {
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/FilterListSoftware"
}
},
"Name": {
"type": [
"string",
"null"
]
},
"Id": {
"type": "integer"
},
"CreatedDateUtc": {
"type": "string",
"format": "date-time"
},
"ModifiedDateUtc": {
"type": "string",
"format": "date-time"
}
},
"required": [
"DownloadUrl",
"HomeUrl",
"FilterListSoftware",
"Name",
"Id",
"CreatedDateUtc",
"ModifiedDateUtc"
]
}
},
"type": "object",
"properties": {
"Email": {
"type": [
"string",
"null"
]
},
"FilterLists": {
"type": [
"array",
@ -180,45 +347,44 @@
"$ref": "#/definitions/FilterList"
}
},
"Email": {
"description": "The email address of the list maintainer.",
"type": [
"string",
"null"
],
"minLength": 7,
"maxLength": 126,
"format": "email"
},
"HomeUrl": {
"description": "The URL to the list maintainer's home page.",
"type": [
"string",
"null"
],
"minLength": 6,
"maxLength": 2083,
"format": "uri"
]
},
"Name": {
"description": "The name of the list maintainer.",
"type": "string",
"maxLength": 126
},
"TwitterHandle": {
"description": "The Twitter handle of the list maintainer.",
"type": [
"string",
"null"
],
"maxLength": 126
]
},
"TwitterHandle": {
"type": [
"string",
"null"
]
},
"Id": {
"type": "integer"
},
"CreatedDateUtc": {
"type": "string",
"format": "date-time"
},
"ModifiedDateUtc": {
"type": "string",
"format": "date-time"
}
},
"required": [
"FilterLists",
"Email",
"FilterLists",
"HomeUrl",
"Name",
"TwitterHandle"
"TwitterHandle",
"Id",
"CreatedDateUtc",
"ModifiedDateUtc"
]
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,249 @@
// <auto-generated />
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("20171028013855_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.0-rtm-26452");
modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreatedDateUtc")
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
b.Property<string>("Description")
.HasMaxLength(4096);
b.Property<string>("DescriptionSourceUrl")
.HasMaxLength(2083);
b.Property<string>("DonateUrl")
.HasMaxLength(2083);
b.Property<string>("EmailAddress")
.HasMaxLength(126);
b.Property<string>("ForumUrl")
.HasMaxLength(2083);
b.Property<string>("HomeUrl")
.HasMaxLength(2083);
b.Property<string>("IssuesUrl")
.HasMaxLength(2083);
b.Property<int>("MaintainerId");
b.Property<DateTime>("ModifiedDateUtc")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TIMESTAMP");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(126);
b.Property<string>("ViewUrl")
.HasMaxLength(2083);
b.HasKey("Id");
b.HasIndex("MaintainerId");
b.ToTable("filterlists");
});
modelBuilder.Entity("FilterLists.Data.Entities.FilterListLanguage", b =>
{
b.Property<int>("FilterListId");
b.Property<int>("LanguageId");
b.Property<DateTime>("CreatedDateUtc")
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
b.Property<DateTime>("ModifiedDateUtc")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TIMESTAMP");
b.HasKey("FilterListId", "LanguageId");
b.HasIndex("LanguageId");
b.ToTable("filterlists_languages");
});
modelBuilder.Entity("FilterLists.Data.Entities.FilterListSoftware", b =>
{
b.Property<int>("FilterListId");
b.Property<int>("SoftwareId");
b.Property<DateTime>("CreatedDateUtc")
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
b.Property<DateTime>("ModifiedDateUtc")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TIMESTAMP");
b.HasKey("FilterListId", "SoftwareId");
b.HasIndex("SoftwareId");
b.ToTable("filterlists_software");
});
modelBuilder.Entity("FilterLists.Data.Entities.Language", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreatedDateUtc")
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
b.Property<string>("Iso6391")
.HasMaxLength(2);
b.Property<string>("Iso6392")
.HasMaxLength(3);
b.Property<string>("Iso6392B")
.HasMaxLength(3);
b.Property<string>("Iso6392T")
.HasMaxLength(3);
b.Property<string>("Iso6393")
.HasMaxLength(3);
b.Property<string>("LocalName")
.HasMaxLength(126);
b.Property<DateTime>("ModifiedDateUtc")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TIMESTAMP");
b.Property<string>("Name")
.HasMaxLength(126);
b.HasKey("Id");
b.ToTable("languages");
});
modelBuilder.Entity("FilterLists.Data.Entities.Maintainer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreatedDateUtc")
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
b.Property<string>("Email")
.HasMaxLength(126);
b.Property<string>("HomeUrl")
.HasMaxLength(2083);
b.Property<DateTime>("ModifiedDateUtc")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TIMESTAMP");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(126);
b.Property<string>("TwitterHandle")
.HasMaxLength(126);
b.HasKey("Id");
b.ToTable("maintainers");
});
modelBuilder.Entity("FilterLists.Data.Entities.Software", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreatedDateUtc")
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
b.Property<string>("DownloadUrl")
.HasMaxLength(2083);
b.Property<string>("HomeUrl")
.HasMaxLength(2083);
b.Property<DateTime>("ModifiedDateUtc")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TIMESTAMP");
b.Property<string>("Name")
.HasMaxLength(126);
b.HasKey("Id");
b.ToTable("software");
});
modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b =>
{
b.HasOne("FilterLists.Data.Entities.Maintainer")
.WithMany("FilterLists")
.HasForeignKey("MaintainerId")
.OnDelete(DeleteBehavior.Cascade);
});
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.FilterListSoftware", b =>
{
b.HasOne("FilterLists.Data.Entities.FilterList", "FilterList")
.WithMany("FilterListSoftware")
.HasForeignKey("FilterListId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("FilterLists.Data.Entities.Software", "Software")
.WithMany("FilterListSoftware")
.HasForeignKey("SoftwareId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,193 @@
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<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
CreatedDateUtc = table.Column<DateTime>(type: "TIMESTAMP", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Iso6391 = table.Column<string>(type: "varchar(2)", maxLength: 2, nullable: true),
Iso6392 = table.Column<string>(type: "varchar(3)", maxLength: 3, nullable: true),
Iso6392B = table.Column<string>(type: "varchar(3)", maxLength: 3, nullable: true),
Iso6392T = table.Column<string>(type: "varchar(3)", maxLength: 3, nullable: true),
Iso6393 = table.Column<string>(type: "varchar(3)", maxLength: 3, nullable: true),
LocalName = table.Column<string>(type: "varchar(126)", maxLength: 126, nullable: true),
ModifiedDateUtc = table.Column<DateTime>(type: "TIMESTAMP", nullable: false),
Name = table.Column<string>(type: "varchar(126)", maxLength: 126, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_languages", x => x.Id);
});
migrationBuilder.CreateTable(
name: "maintainers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
CreatedDateUtc = table.Column<DateTime>(type: "TIMESTAMP", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Email = table.Column<string>(type: "varchar(126)", maxLength: 126, nullable: true),
HomeUrl = table.Column<string>(type: "varchar(2083)", maxLength: 2083, nullable: true),
ModifiedDateUtc = table.Column<DateTime>(type: "TIMESTAMP", nullable: false),
Name = table.Column<string>(type: "varchar(126)", maxLength: 126, nullable: false),
TwitterHandle = table.Column<string>(type: "varchar(126)", maxLength: 126, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_maintainers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "software",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
CreatedDateUtc = table.Column<DateTime>(type: "TIMESTAMP", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
DownloadUrl = table.Column<string>(type: "varchar(2083)", maxLength: 2083, nullable: true),
HomeUrl = table.Column<string>(type: "varchar(2083)", maxLength: 2083, nullable: true),
ModifiedDateUtc = table.Column<DateTime>(type: "TIMESTAMP", nullable: false),
Name = table.Column<string>(type: "varchar(126)", maxLength: 126, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_software", x => x.Id);
});
migrationBuilder.CreateTable(
name: "filterlists",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
CreatedDateUtc = table.Column<DateTime>(type: "TIMESTAMP", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Description = table.Column<string>(type: "varchar(4096)", maxLength: 4096, nullable: true),
DescriptionSourceUrl = table.Column<string>(type: "varchar(2083)", maxLength: 2083, nullable: true),
DonateUrl = table.Column<string>(type: "varchar(2083)", maxLength: 2083, nullable: true),
EmailAddress = table.Column<string>(type: "varchar(126)", maxLength: 126, nullable: true),
ForumUrl = table.Column<string>(type: "varchar(2083)", maxLength: 2083, nullable: true),
HomeUrl = table.Column<string>(type: "varchar(2083)", maxLength: 2083, nullable: true),
IssuesUrl = table.Column<string>(type: "varchar(2083)", maxLength: 2083, nullable: true),
MaintainerId = table.Column<int>(type: "int", nullable: false),
ModifiedDateUtc = table.Column<DateTime>(type: "TIMESTAMP", nullable: false),
Name = table.Column<string>(type: "varchar(126)", maxLength: 126, nullable: false),
ViewUrl = table.Column<string>(type: "varchar(2083)", maxLength: 2083, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_filterlists", x => x.Id);
table.ForeignKey(
name: "FK_filterlists_maintainers_MaintainerId",
column: x => x.MaintainerId,
principalTable: "maintainers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "filterlists_languages",
columns: table => new
{
FilterListId = table.Column<int>(type: "int", nullable: false),
LanguageId = table.Column<int>(type: "int", nullable: false),
CreatedDateUtc = table.Column<DateTime>(type: "TIMESTAMP", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
ModifiedDateUtc = table.Column<DateTime>(type: "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_software",
columns: table => new
{
FilterListId = table.Column<int>(type: "int", nullable: false),
SoftwareId = table.Column<int>(type: "int", nullable: false),
CreatedDateUtc = table.Column<DateTime>(type: "TIMESTAMP", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
ModifiedDateUtc = table.Column<DateTime>(type: "TIMESTAMP", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_filterlists_software", x => new { x.FilterListId, x.SoftwareId });
table.ForeignKey(
name: "FK_filterlists_software_filterlists_FilterListId",
column: x => x.FilterListId,
principalTable: "filterlists",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_filterlists_software_software_SoftwareId",
column: x => x.SoftwareId,
principalTable: "software",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_filterlists_MaintainerId",
table: "filterlists",
column: "MaintainerId");
migrationBuilder.CreateIndex(
name: "IX_filterlists_languages_LanguageId",
table: "filterlists_languages",
column: "LanguageId");
migrationBuilder.CreateIndex(
name: "IX_filterlists_software_SoftwareId",
table: "filterlists_software",
column: "SoftwareId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "filterlists_languages");
migrationBuilder.DropTable(
name: "filterlists_software");
migrationBuilder.DropTable(
name: "languages");
migrationBuilder.DropTable(
name: "filterlists");
migrationBuilder.DropTable(
name: "software");
migrationBuilder.DropTable(
name: "maintainers");
}
}
}

View file

@ -0,0 +1,248 @@
// <auto-generated />
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))]
partial class FilterListsDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
.HasAnnotation("ProductVersion", "2.0.0-rtm-26452");
modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreatedDateUtc")
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
b.Property<string>("Description")
.HasMaxLength(4096);
b.Property<string>("DescriptionSourceUrl")
.HasMaxLength(2083);
b.Property<string>("DonateUrl")
.HasMaxLength(2083);
b.Property<string>("EmailAddress")
.HasMaxLength(126);
b.Property<string>("ForumUrl")
.HasMaxLength(2083);
b.Property<string>("HomeUrl")
.HasMaxLength(2083);
b.Property<string>("IssuesUrl")
.HasMaxLength(2083);
b.Property<int>("MaintainerId");
b.Property<DateTime>("ModifiedDateUtc")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TIMESTAMP");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(126);
b.Property<string>("ViewUrl")
.HasMaxLength(2083);
b.HasKey("Id");
b.HasIndex("MaintainerId");
b.ToTable("filterlists");
});
modelBuilder.Entity("FilterLists.Data.Entities.FilterListLanguage", b =>
{
b.Property<int>("FilterListId");
b.Property<int>("LanguageId");
b.Property<DateTime>("CreatedDateUtc")
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
b.Property<DateTime>("ModifiedDateUtc")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TIMESTAMP");
b.HasKey("FilterListId", "LanguageId");
b.HasIndex("LanguageId");
b.ToTable("filterlists_languages");
});
modelBuilder.Entity("FilterLists.Data.Entities.FilterListSoftware", b =>
{
b.Property<int>("FilterListId");
b.Property<int>("SoftwareId");
b.Property<DateTime>("CreatedDateUtc")
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
b.Property<DateTime>("ModifiedDateUtc")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TIMESTAMP");
b.HasKey("FilterListId", "SoftwareId");
b.HasIndex("SoftwareId");
b.ToTable("filterlists_software");
});
modelBuilder.Entity("FilterLists.Data.Entities.Language", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreatedDateUtc")
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
b.Property<string>("Iso6391")
.HasMaxLength(2);
b.Property<string>("Iso6392")
.HasMaxLength(3);
b.Property<string>("Iso6392B")
.HasMaxLength(3);
b.Property<string>("Iso6392T")
.HasMaxLength(3);
b.Property<string>("Iso6393")
.HasMaxLength(3);
b.Property<string>("LocalName")
.HasMaxLength(126);
b.Property<DateTime>("ModifiedDateUtc")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TIMESTAMP");
b.Property<string>("Name")
.HasMaxLength(126);
b.HasKey("Id");
b.ToTable("languages");
});
modelBuilder.Entity("FilterLists.Data.Entities.Maintainer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreatedDateUtc")
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
b.Property<string>("Email")
.HasMaxLength(126);
b.Property<string>("HomeUrl")
.HasMaxLength(2083);
b.Property<DateTime>("ModifiedDateUtc")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TIMESTAMP");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(126);
b.Property<string>("TwitterHandle")
.HasMaxLength(126);
b.HasKey("Id");
b.ToTable("maintainers");
});
modelBuilder.Entity("FilterLists.Data.Entities.Software", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreatedDateUtc")
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
b.Property<string>("DownloadUrl")
.HasMaxLength(2083);
b.Property<string>("HomeUrl")
.HasMaxLength(2083);
b.Property<DateTime>("ModifiedDateUtc")
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("TIMESTAMP");
b.Property<string>("Name")
.HasMaxLength(126);
b.HasKey("Id");
b.ToTable("software");
});
modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b =>
{
b.HasOne("FilterLists.Data.Entities.Maintainer")
.WithMany("FilterLists")
.HasForeignKey("MaintainerId")
.OnDelete(DeleteBehavior.Cascade);
});
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.FilterListSoftware", b =>
{
b.HasOne("FilterLists.Data.Entities.FilterList", "FilterList")
.WithMany("FilterListSoftware")
.HasForeignKey("FilterListId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("FilterLists.Data.Entities.Software", "Software")
.WithMany("FilterListSoftware")
.HasForeignKey("SoftwareId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View file

@ -1,6 +1,8 @@
using FilterLists.Data.Json;
using FilterLists.Data;
using FilterLists.Data.Json;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace FilterLists.Api
{
@ -10,7 +12,12 @@ public static void Main(string[] args)
{
JsonSchemaGenerator.WriteSchemaToFile();
JsonSampleGenerator.WriteSampleToFile();
BuildWebHost(args).Run();
var host = BuildWebHost(args);
using (var scope = host.Services.CreateScope())
{
DbInitializer.Initialize(scope.ServiceProvider.GetRequiredService<FilterListsDbContext>());
}
host.Run();
}
public static IWebHost BuildWebHost(string[] args)

View file

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FilterLists.Data.Entities;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
namespace FilterLists.Data
{
public static class DbInitializer
{
public static void Initialize(FilterListsDbContext filterListsDbContext)
{
filterListsDbContext.Database.Migrate();
InitializeLanguages(filterListsDbContext);
}
private static void InitializeLanguages(FilterListsDbContext filterListsDbContext)
{
if (filterListsDbContext.Languages.Any()) return;
filterListsDbContext.AddRange(JsonConvert.DeserializeObject<List<Language>>(
File.ReadAllText(Path.GetFullPath(Path.Combine(AppContext.BaseDirectory + @"\",
@"..\..\..\..\..\data\Languages.json")))));
filterListsDbContext.SaveChanges();
}
}
}