Huge API rewrite

This commit is contained in:
2018-02-24 01:10:12 -05:00
parent a37fe30b6f
commit 038d363b00
16 changed files with 472 additions and 77 deletions

View File

@ -1,25 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace YTManager.Migrations
{
public partial class added_refreshed : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "Refreshed",
table: "Channels",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Refreshed",
table: "Channels");
}
}
}

View File

@ -11,8 +11,8 @@ using YTManager;
namespace YTManager.Migrations
{
[DbContext(typeof(MediaDB))]
[Migration("20180220053952_added_refreshed")]
partial class added_refreshed
[Migration("20180224051602_initial")]
partial class initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace YTManager.Migrations
{
public partial class initiailmigration : Migration
public partial class initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
@ -17,6 +17,7 @@ namespace YTManager.Migrations
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
AddedtoDB = table.Column<DateTime>(nullable: false),
Description = table.Column<string>(nullable: false),
Refreshed = table.Column<DateTime>(nullable: false),
ThumbnailURL = table.Column<string>(nullable: false),
Title = table.Column<string>(nullable: false),
YoutubeID = table.Column<string>(nullable: false)

View File

@ -11,8 +11,8 @@ using YTManager;
namespace YTManager.Migrations
{
[DbContext(typeof(MediaDB))]
[Migration("20180220032847_initiailmigration")]
partial class initiailmigration
[Migration("20180224055707_fix_channel_relationship")]
partial class fix_channel_relationship
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@ -31,6 +31,8 @@ namespace YTManager.Migrations
b.Property<string>("Description")
.IsRequired();
b.Property<DateTime>("Refreshed");
b.Property<string>("ThumbnailURL")
.IsRequired();
@ -53,8 +55,12 @@ namespace YTManager.Migrations
b.Property<string>("Name")
.IsRequired();
b.Property<long?>("VideoPrimaryKey");
b.HasKey("PrimaryKey");
b.HasIndex("VideoPrimaryKey");
b.ToTable("Tags");
});
@ -67,7 +73,7 @@ namespace YTManager.Migrations
b.Property<DateTime>("AddedtoDB");
b.Property<long?>("ChannelPrimaryKey");
b.Property<long>("ChannelPrimaryKey");
b.Property<string>("Description")
.IsRequired();
@ -88,11 +94,19 @@ namespace YTManager.Migrations
b.ToTable("Videos");
});
modelBuilder.Entity("YTManager.Models.Tag", b =>
{
b.HasOne("YTManager.Models.Video")
.WithMany("Tags")
.HasForeignKey("VideoPrimaryKey");
});
modelBuilder.Entity("YTManager.Models.Video", b =>
{
b.HasOne("YTManager.Models.Channel")
b.HasOne("YTManager.Models.Channel", "Channel")
.WithMany("Videos")
.HasForeignKey("ChannelPrimaryKey");
.HasForeignKey("ChannelPrimaryKey")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}

View File

@ -0,0 +1,82 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
namespace YTManager.Migrations
{
public partial class fix_channel_relationship : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Videos_Channels_ChannelPrimaryKey",
table: "Videos");
migrationBuilder.AlterColumn<long>(
name: "ChannelPrimaryKey",
table: "Videos",
nullable: false,
oldClrType: typeof(long),
oldNullable: true);
migrationBuilder.AddColumn<long>(
name: "VideoPrimaryKey",
table: "Tags",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_Tags_VideoPrimaryKey",
table: "Tags",
column: "VideoPrimaryKey");
migrationBuilder.AddForeignKey(
name: "FK_Tags_Videos_VideoPrimaryKey",
table: "Tags",
column: "VideoPrimaryKey",
principalTable: "Videos",
principalColumn: "PrimaryKey",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Videos_Channels_ChannelPrimaryKey",
table: "Videos",
column: "ChannelPrimaryKey",
principalTable: "Channels",
principalColumn: "PrimaryKey",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Tags_Videos_VideoPrimaryKey",
table: "Tags");
migrationBuilder.DropForeignKey(
name: "FK_Videos_Channels_ChannelPrimaryKey",
table: "Videos");
migrationBuilder.DropIndex(
name: "IX_Tags_VideoPrimaryKey",
table: "Tags");
migrationBuilder.DropColumn(
name: "VideoPrimaryKey",
table: "Tags");
migrationBuilder.AlterColumn<long>(
name: "ChannelPrimaryKey",
table: "Videos",
nullable: true,
oldClrType: typeof(long));
migrationBuilder.AddForeignKey(
name: "FK_Videos_Channels_ChannelPrimaryKey",
table: "Videos",
column: "ChannelPrimaryKey",
principalTable: "Channels",
principalColumn: "PrimaryKey",
onDelete: ReferentialAction.Restrict);
}
}
}

View File

@ -54,8 +54,12 @@ namespace YTManager.Migrations
b.Property<string>("Name")
.IsRequired();
b.Property<long?>("VideoPrimaryKey");
b.HasKey("PrimaryKey");
b.HasIndex("VideoPrimaryKey");
b.ToTable("Tags");
});
@ -68,7 +72,7 @@ namespace YTManager.Migrations
b.Property<DateTime>("AddedtoDB");
b.Property<long?>("ChannelPrimaryKey");
b.Property<long>("ChannelPrimaryKey");
b.Property<string>("Description")
.IsRequired();
@ -89,11 +93,19 @@ namespace YTManager.Migrations
b.ToTable("Videos");
});
modelBuilder.Entity("YTManager.Models.Tag", b =>
{
b.HasOne("YTManager.Models.Video")
.WithMany("Tags")
.HasForeignKey("VideoPrimaryKey");
});
modelBuilder.Entity("YTManager.Models.Video", b =>
{
b.HasOne("YTManager.Models.Channel")
b.HasOne("YTManager.Models.Channel", "Channel")
.WithMany("Videos")
.HasForeignKey("ChannelPrimaryKey");
.HasForeignKey("ChannelPrimaryKey")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}