added first working db init and startup
This commit is contained in:
@@ -1,41 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Tv7Playlist.Data;
|
|
||||||
|
|
||||||
namespace Tv7Playlist.Data.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(PlaylistContext))]
|
|
||||||
[Migration("20181209233600_InitialCreate")]
|
|
||||||
partial class InitialCreate
|
|
||||||
{
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687");
|
|
||||||
|
|
||||||
modelBuilder.Entity("Tv7Playlist.Data.PlaylistEntry", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd();
|
|
||||||
|
|
||||||
b.Property<string>("Name");
|
|
||||||
|
|
||||||
b.Property<int>("TrackNumber");
|
|
||||||
|
|
||||||
b.Property<string>("Url");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasAlternateKey("TrackNumber");
|
|
||||||
|
|
||||||
b.ToTable("PlaylistEntries");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,70 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace Tv7Playlist.Data.Migrations
|
|
||||||
{
|
|
||||||
public partial class AddedEnabledAvailableNameOverride : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropUniqueConstraint(
|
|
||||||
name: "AK_PlaylistEntries_TrackNumber",
|
|
||||||
table: "PlaylistEntries");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
|
||||||
name: "IsAvailable",
|
|
||||||
table: "PlaylistEntries",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
|
||||||
name: "IsEnabled",
|
|
||||||
table: "PlaylistEntries",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "NameOverride",
|
|
||||||
table: "PlaylistEntries",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_PlaylistEntries_Name",
|
|
||||||
table: "PlaylistEntries",
|
|
||||||
column: "Name");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_PlaylistEntries_TrackNumber",
|
|
||||||
table: "PlaylistEntries",
|
|
||||||
column: "TrackNumber",
|
|
||||||
unique: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_PlaylistEntries_Name",
|
|
||||||
table: "PlaylistEntries");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_PlaylistEntries_TrackNumber",
|
|
||||||
table: "PlaylistEntries");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "IsAvailable",
|
|
||||||
table: "PlaylistEntries");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "IsEnabled",
|
|
||||||
table: "PlaylistEntries");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "NameOverride",
|
|
||||||
table: "PlaylistEntries");
|
|
||||||
|
|
||||||
migrationBuilder.AddUniqueConstraint(
|
|
||||||
name: "AK_PlaylistEntries_TrackNumber",
|
|
||||||
table: "PlaylistEntries",
|
|
||||||
column: "TrackNumber");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -9,8 +9,8 @@ using Tv7Playlist.Data;
|
|||||||
namespace Tv7Playlist.Data.Migrations
|
namespace Tv7Playlist.Data.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(PlaylistContext))]
|
[DbContext(typeof(PlaylistContext))]
|
||||||
[Migration("20190124221302_AddedEnabledAvailableNameOverride")]
|
[Migration("20190124230424_InitialCreate")]
|
||||||
partial class AddedEnabledAvailableNameOverride
|
partial class InitialCreate
|
||||||
{
|
{
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
@@ -8,25 +8,38 @@ namespace Tv7Playlist.Data.Migrations
|
|||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
"PlaylistEntries",
|
name: "PlaylistEntries",
|
||||||
table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(nullable: false),
|
Id = table.Column<Guid>(nullable: false),
|
||||||
TrackNumber = table.Column<int>(nullable: false),
|
TrackNumber = table.Column<int>(nullable: false),
|
||||||
Name = table.Column<string>(nullable: true),
|
Name = table.Column<string>(nullable: true),
|
||||||
Url = table.Column<string>(nullable: true)
|
NameOverride = table.Column<string>(nullable: true),
|
||||||
|
Url = table.Column<string>(nullable: true),
|
||||||
|
IsAvailable = table.Column<bool>(nullable: false),
|
||||||
|
IsEnabled = table.Column<bool>(nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_PlaylistEntries", x => x.Id);
|
table.PrimaryKey("PK_PlaylistEntries", x => x.Id);
|
||||||
table.UniqueConstraint("AK_PlaylistEntries_TrackNumber", x => x.TrackNumber);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlaylistEntries_Name",
|
||||||
|
table: "PlaylistEntries",
|
||||||
|
column: "Name");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlaylistEntries_TrackNumber",
|
||||||
|
table: "PlaylistEntries",
|
||||||
|
column: "TrackNumber",
|
||||||
|
unique: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
"PlaylistEntries");
|
name: "PlaylistEntries");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
@@ -60,6 +60,9 @@ namespace Tv7Playlist
|
|||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InitializeDatabase(app);
|
||||||
|
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseCookiePolicy();
|
app.UseCookiePolicy();
|
||||||
@@ -72,6 +75,14 @@ namespace Tv7Playlist
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InitializeDatabase(IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
using (var scope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())
|
||||||
|
{
|
||||||
|
scope.ServiceProvider.GetRequiredService<PlaylistContext>().Database.Migrate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ConfigureParser(IServiceCollection services, IAppConfig appConfig)
|
private void ConfigureParser(IServiceCollection services, IAppConfig appConfig)
|
||||||
{
|
{
|
||||||
services.AddTransient<IPlaylistLoader, PlaylistLoader>();
|
services.AddTransient<IPlaylistLoader, PlaylistLoader>();
|
||||||
|
Reference in New Issue
Block a user