mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Using snake case for postgresql
This commit is contained in:
parent
27a69b5a34
commit
dc16223e3e
@ -18,6 +18,7 @@
|
|||||||
<!-- </PropertyGroup>-->
|
<!-- </PropertyGroup>-->
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="EFCore.NamingConventions" Version="5.0.2" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.7">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.7">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
@ -1,782 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Kyoo.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
namespace Kyoo.Postgresql.Migrations
|
|
||||||
{
|
|
||||||
public partial class Initial : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AlterDatabase()
|
|
||||||
.Annotation("Npgsql:Enum:item_type", "show,movie,collection")
|
|
||||||
.Annotation("Npgsql:Enum:status", "finished,airing,planned,unknown")
|
|
||||||
.Annotation("Npgsql:Enum:stream_type", "unknown,video,audio,subtitle,attachment");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Collections",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Slug = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Poster = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Overview = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Collections", x => x.ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Genres",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Slug = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Genres", x => x.ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Libraries",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Slug = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Paths = table.Column<string[]>(type: "text[]", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Libraries", x => x.ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "People",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Slug = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Poster = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_People", x => x.ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Providers",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Slug = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Logo = table.Column<string>(type: "text", nullable: true),
|
|
||||||
LogoExtension = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Providers", x => x.ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Studios",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Slug = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Studios", x => x.ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Users",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Slug = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Username = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Email = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Password = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Permissions = table.Column<string[]>(type: "text[]", nullable: true),
|
|
||||||
ExtraData = table.Column<Dictionary<string, string>>(type: "jsonb", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Users", x => x.ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Link<Library, Collection>",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
FirstID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SecondID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Link<Library, Collection>", x => new { x.FirstID, x.SecondID });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Link<Library, Collection>_Collections_SecondID",
|
|
||||||
column: x => x.SecondID,
|
|
||||||
principalTable: "Collections",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Link<Library, Collection>_Libraries_FirstID",
|
|
||||||
column: x => x.FirstID,
|
|
||||||
principalTable: "Libraries",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Link<Library, Provider>",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
FirstID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SecondID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Link<Library, Provider>", x => new { x.FirstID, x.SecondID });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Link<Library, Provider>_Libraries_FirstID",
|
|
||||||
column: x => x.FirstID,
|
|
||||||
principalTable: "Libraries",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Link<Library, Provider>_Providers_SecondID",
|
|
||||||
column: x => x.SecondID,
|
|
||||||
principalTable: "Providers",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "MetadataID<People>",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
FirstID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SecondID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
DataID = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Link = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_MetadataID<People>", x => new { x.FirstID, x.SecondID });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_MetadataID<People>_People_FirstID",
|
|
||||||
column: x => x.FirstID,
|
|
||||||
principalTable: "People",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_MetadataID<People>_Providers_SecondID",
|
|
||||||
column: x => x.SecondID,
|
|
||||||
principalTable: "Providers",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Shows",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Slug = table.Column<string>(type: "text", nullable: false),
|
|
||||||
Title = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Aliases = table.Column<string[]>(type: "text[]", nullable: true),
|
|
||||||
Path = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Overview = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Status = table.Column<Status>(type: "status", nullable: true),
|
|
||||||
TrailerUrl = table.Column<string>(type: "text", nullable: true),
|
|
||||||
StartAir = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
|
|
||||||
EndAir = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
|
|
||||||
Poster = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Logo = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Backdrop = table.Column<string>(type: "text", nullable: true),
|
|
||||||
IsMovie = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
StudioID = table.Column<int>(type: "integer", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Shows", x => x.ID);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Shows_Studios_StudioID",
|
|
||||||
column: x => x.StudioID,
|
|
||||||
principalTable: "Studios",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Link<Collection, Show>",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
FirstID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SecondID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Link<Collection, Show>", x => new { x.FirstID, x.SecondID });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Link<Collection, Show>_Collections_FirstID",
|
|
||||||
column: x => x.FirstID,
|
|
||||||
principalTable: "Collections",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Link<Collection, Show>_Shows_SecondID",
|
|
||||||
column: x => x.SecondID,
|
|
||||||
principalTable: "Shows",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Link<Library, Show>",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
FirstID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SecondID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Link<Library, Show>", x => new { x.FirstID, x.SecondID });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Link<Library, Show>_Libraries_FirstID",
|
|
||||||
column: x => x.FirstID,
|
|
||||||
principalTable: "Libraries",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Link<Library, Show>_Shows_SecondID",
|
|
||||||
column: x => x.SecondID,
|
|
||||||
principalTable: "Shows",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Link<Show, Genre>",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
FirstID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SecondID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Link<Show, Genre>", x => new { x.FirstID, x.SecondID });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Link<Show, Genre>_Genres_SecondID",
|
|
||||||
column: x => x.SecondID,
|
|
||||||
principalTable: "Genres",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Link<Show, Genre>_Shows_FirstID",
|
|
||||||
column: x => x.FirstID,
|
|
||||||
principalTable: "Shows",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Link<User, Show>",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
FirstID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SecondID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Link<User, Show>", x => new { x.FirstID, x.SecondID });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Link<User, Show>_Shows_SecondID",
|
|
||||||
column: x => x.SecondID,
|
|
||||||
principalTable: "Shows",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Link<User, Show>_Users_FirstID",
|
|
||||||
column: x => x.FirstID,
|
|
||||||
principalTable: "Users",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "MetadataID<Show>",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
FirstID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SecondID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
DataID = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Link = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_MetadataID<Show>", x => new { x.FirstID, x.SecondID });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_MetadataID<Show>_Providers_SecondID",
|
|
||||||
column: x => x.SecondID,
|
|
||||||
principalTable: "Providers",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_MetadataID<Show>_Shows_FirstID",
|
|
||||||
column: x => x.FirstID,
|
|
||||||
principalTable: "Shows",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "PeopleRoles",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
ForPeople = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
PeopleID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
ShowID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
Type = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Role = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_PeopleRoles", x => x.ID);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_PeopleRoles_People_PeopleID",
|
|
||||||
column: x => x.PeopleID,
|
|
||||||
principalTable: "People",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_PeopleRoles_Shows_ShowID",
|
|
||||||
column: x => x.ShowID,
|
|
||||||
principalTable: "Shows",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Seasons",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Slug = table.Column<string>(type: "text", nullable: true),
|
|
||||||
ShowID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SeasonNumber = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
Title = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Overview = table.Column<string>(type: "text", nullable: true),
|
|
||||||
StartDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
|
|
||||||
EndDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
|
|
||||||
Poster = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Seasons", x => x.ID);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Seasons_Shows_ShowID",
|
|
||||||
column: x => x.ShowID,
|
|
||||||
principalTable: "Shows",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Episodes",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Slug = table.Column<string>(type: "text", nullable: true),
|
|
||||||
ShowID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SeasonID = table.Column<int>(type: "integer", nullable: true),
|
|
||||||
SeasonNumber = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
EpisodeNumber = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
AbsoluteNumber = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
Path = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Thumb = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Title = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Overview = table.Column<string>(type: "text", nullable: true),
|
|
||||||
ReleaseDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Episodes", x => x.ID);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Episodes_Seasons_SeasonID",
|
|
||||||
column: x => x.SeasonID,
|
|
||||||
principalTable: "Seasons",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Episodes_Shows_ShowID",
|
|
||||||
column: x => x.ShowID,
|
|
||||||
principalTable: "Shows",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "MetadataID<Season>",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
FirstID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SecondID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
DataID = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Link = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_MetadataID<Season>", x => new { x.FirstID, x.SecondID });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_MetadataID<Season>_Providers_SecondID",
|
|
||||||
column: x => x.SecondID,
|
|
||||||
principalTable: "Providers",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_MetadataID<Season>_Seasons_FirstID",
|
|
||||||
column: x => x.FirstID,
|
|
||||||
principalTable: "Seasons",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "MetadataID<Episode>",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
FirstID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SecondID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
DataID = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Link = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_MetadataID<Episode>", x => new { x.FirstID, x.SecondID });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_MetadataID<Episode>_Episodes_FirstID",
|
|
||||||
column: x => x.FirstID,
|
|
||||||
principalTable: "Episodes",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_MetadataID<Episode>_Providers_SecondID",
|
|
||||||
column: x => x.SecondID,
|
|
||||||
principalTable: "Providers",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Tracks",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Slug = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Title = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Language = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Codec = table.Column<string>(type: "text", nullable: true),
|
|
||||||
IsDefault = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
IsForced = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
IsExternal = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
Path = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Type = table.Column<StreamType>(type: "stream_type", nullable: false),
|
|
||||||
EpisodeID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
TrackIndex = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Tracks", x => x.ID);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Tracks_Episodes_EpisodeID",
|
|
||||||
column: x => x.EpisodeID,
|
|
||||||
principalTable: "Episodes",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "WatchedEpisodes",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
FirstID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
SecondID = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
WatchedPercentage = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_WatchedEpisodes", x => new { x.FirstID, x.SecondID });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_WatchedEpisodes_Episodes_SecondID",
|
|
||||||
column: x => x.SecondID,
|
|
||||||
principalTable: "Episodes",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_WatchedEpisodes_Users_FirstID",
|
|
||||||
column: x => x.FirstID,
|
|
||||||
principalTable: "Users",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Collections_Slug",
|
|
||||||
table: "Collections",
|
|
||||||
column: "Slug",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Episodes_SeasonID",
|
|
||||||
table: "Episodes",
|
|
||||||
column: "SeasonID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Episodes_ShowID_SeasonNumber_EpisodeNumber_AbsoluteNumber",
|
|
||||||
table: "Episodes",
|
|
||||||
columns: new[] { "ShowID", "SeasonNumber", "EpisodeNumber", "AbsoluteNumber" },
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Episodes_Slug",
|
|
||||||
table: "Episodes",
|
|
||||||
column: "Slug",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Genres_Slug",
|
|
||||||
table: "Genres",
|
|
||||||
column: "Slug",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Libraries_Slug",
|
|
||||||
table: "Libraries",
|
|
||||||
column: "Slug",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Link<Collection, Show>_SecondID",
|
|
||||||
table: "Link<Collection, Show>",
|
|
||||||
column: "SecondID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Link<Library, Collection>_SecondID",
|
|
||||||
table: "Link<Library, Collection>",
|
|
||||||
column: "SecondID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Link<Library, Provider>_SecondID",
|
|
||||||
table: "Link<Library, Provider>",
|
|
||||||
column: "SecondID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Link<Library, Show>_SecondID",
|
|
||||||
table: "Link<Library, Show>",
|
|
||||||
column: "SecondID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Link<Show, Genre>_SecondID",
|
|
||||||
table: "Link<Show, Genre>",
|
|
||||||
column: "SecondID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Link<User, Show>_SecondID",
|
|
||||||
table: "Link<User, Show>",
|
|
||||||
column: "SecondID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_MetadataID<Episode>_SecondID",
|
|
||||||
table: "MetadataID<Episode>",
|
|
||||||
column: "SecondID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_MetadataID<People>_SecondID",
|
|
||||||
table: "MetadataID<People>",
|
|
||||||
column: "SecondID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_MetadataID<Season>_SecondID",
|
|
||||||
table: "MetadataID<Season>",
|
|
||||||
column: "SecondID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_MetadataID<Show>_SecondID",
|
|
||||||
table: "MetadataID<Show>",
|
|
||||||
column: "SecondID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_People_Slug",
|
|
||||||
table: "People",
|
|
||||||
column: "Slug",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_PeopleRoles_PeopleID",
|
|
||||||
table: "PeopleRoles",
|
|
||||||
column: "PeopleID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_PeopleRoles_ShowID",
|
|
||||||
table: "PeopleRoles",
|
|
||||||
column: "ShowID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Providers_Slug",
|
|
||||||
table: "Providers",
|
|
||||||
column: "Slug",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Seasons_ShowID_SeasonNumber",
|
|
||||||
table: "Seasons",
|
|
||||||
columns: new[] { "ShowID", "SeasonNumber" },
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Seasons_Slug",
|
|
||||||
table: "Seasons",
|
|
||||||
column: "Slug",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Shows_Slug",
|
|
||||||
table: "Shows",
|
|
||||||
column: "Slug",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Shows_StudioID",
|
|
||||||
table: "Shows",
|
|
||||||
column: "StudioID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Studios_Slug",
|
|
||||||
table: "Studios",
|
|
||||||
column: "Slug",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Tracks_EpisodeID_Type_Language_TrackIndex_IsForced",
|
|
||||||
table: "Tracks",
|
|
||||||
columns: new[] { "EpisodeID", "Type", "Language", "TrackIndex", "IsForced" },
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Tracks_Slug",
|
|
||||||
table: "Tracks",
|
|
||||||
column: "Slug",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Users_Slug",
|
|
||||||
table: "Users",
|
|
||||||
column: "Slug",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_WatchedEpisodes_SecondID",
|
|
||||||
table: "WatchedEpisodes",
|
|
||||||
column: "SecondID");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Link<Collection, Show>");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Link<Library, Collection>");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Link<Library, Provider>");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Link<Library, Show>");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Link<Show, Genre>");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Link<User, Show>");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "MetadataID<Episode>");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "MetadataID<People>");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "MetadataID<Season>");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "MetadataID<Show>");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "PeopleRoles");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Tracks");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "WatchedEpisodes");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Collections");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Libraries");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Genres");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Providers");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "People");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Episodes");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Users");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Seasons");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Shows");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Studios");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
782
Kyoo.Postgresql/Migrations/20210623174924_Initial.cs
Normal file
782
Kyoo.Postgresql/Migrations/20210623174924_Initial.cs
Normal file
@ -0,0 +1,782 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Kyoo.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
namespace Kyoo.Postgresql.Migrations
|
||||||
|
{
|
||||||
|
public partial class Initial : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterDatabase()
|
||||||
|
.Annotation("Npgsql:Enum:item_type", "show,movie,collection")
|
||||||
|
.Annotation("Npgsql:Enum:status", "finished,airing,planned,unknown")
|
||||||
|
.Annotation("Npgsql:Enum:stream_type", "unknown,video,audio,subtitle,attachment");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "collections",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
slug = table.Column<string>(type: "text", nullable: false),
|
||||||
|
name = table.Column<string>(type: "text", nullable: true),
|
||||||
|
poster = table.Column<string>(type: "text", nullable: true),
|
||||||
|
overview = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_collections", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "genres",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
slug = table.Column<string>(type: "text", nullable: false),
|
||||||
|
name = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_genres", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "libraries",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
slug = table.Column<string>(type: "text", nullable: false),
|
||||||
|
name = table.Column<string>(type: "text", nullable: true),
|
||||||
|
paths = table.Column<string[]>(type: "text[]", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_libraries", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "people",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
slug = table.Column<string>(type: "text", nullable: false),
|
||||||
|
name = table.Column<string>(type: "text", nullable: true),
|
||||||
|
poster = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_people", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "providers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
slug = table.Column<string>(type: "text", nullable: false),
|
||||||
|
name = table.Column<string>(type: "text", nullable: true),
|
||||||
|
logo = table.Column<string>(type: "text", nullable: true),
|
||||||
|
logo_extension = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_providers", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "studios",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
slug = table.Column<string>(type: "text", nullable: false),
|
||||||
|
name = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_studios", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "users",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
slug = table.Column<string>(type: "text", nullable: false),
|
||||||
|
username = table.Column<string>(type: "text", nullable: true),
|
||||||
|
email = table.Column<string>(type: "text", nullable: true),
|
||||||
|
password = table.Column<string>(type: "text", nullable: true),
|
||||||
|
permissions = table.Column<string[]>(type: "text[]", nullable: true),
|
||||||
|
extra_data = table.Column<Dictionary<string, string>>(type: "jsonb", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_users", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "link_library_collection",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
first_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
second_id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_link_library_collection", x => new { x.first_id, x.second_id });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_link_library_collection_collections_second_id",
|
||||||
|
column: x => x.second_id,
|
||||||
|
principalTable: "collections",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_link_library_collection_libraries_first_id",
|
||||||
|
column: x => x.first_id,
|
||||||
|
principalTable: "libraries",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "link_library_provider",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
first_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
second_id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_link_library_provider", x => new { x.first_id, x.second_id });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_link_library_provider_libraries_first_id",
|
||||||
|
column: x => x.first_id,
|
||||||
|
principalTable: "libraries",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_link_library_provider_providers_second_id",
|
||||||
|
column: x => x.second_id,
|
||||||
|
principalTable: "providers",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "metadata_id_people",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
first_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
second_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
data_id = table.Column<string>(type: "text", nullable: true),
|
||||||
|
link = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_metadata_id_people", x => new { x.first_id, x.second_id });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_metadata_id_people_people_first_id",
|
||||||
|
column: x => x.first_id,
|
||||||
|
principalTable: "people",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_metadata_id_people_providers_second_id",
|
||||||
|
column: x => x.second_id,
|
||||||
|
principalTable: "providers",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "shows",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
slug = table.Column<string>(type: "text", nullable: false),
|
||||||
|
title = table.Column<string>(type: "text", nullable: true),
|
||||||
|
aliases = table.Column<string[]>(type: "text[]", nullable: true),
|
||||||
|
path = table.Column<string>(type: "text", nullable: true),
|
||||||
|
overview = table.Column<string>(type: "text", nullable: true),
|
||||||
|
status = table.Column<Status>(type: "status", nullable: true),
|
||||||
|
trailer_url = table.Column<string>(type: "text", nullable: true),
|
||||||
|
start_air = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
|
||||||
|
end_air = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
|
||||||
|
poster = table.Column<string>(type: "text", nullable: true),
|
||||||
|
logo = table.Column<string>(type: "text", nullable: true),
|
||||||
|
backdrop = table.Column<string>(type: "text", nullable: true),
|
||||||
|
is_movie = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
studio_id = table.Column<int>(type: "integer", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_shows", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_shows_studios_studio_id",
|
||||||
|
column: x => x.studio_id,
|
||||||
|
principalTable: "studios",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "link_collection_show",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
first_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
second_id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_link_collection_show", x => new { x.first_id, x.second_id });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_link_collection_show_collections_first_id",
|
||||||
|
column: x => x.first_id,
|
||||||
|
principalTable: "collections",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_link_collection_show_shows_second_id",
|
||||||
|
column: x => x.second_id,
|
||||||
|
principalTable: "shows",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "link_library_show",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
first_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
second_id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_link_library_show", x => new { x.first_id, x.second_id });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_link_library_show_libraries_first_id",
|
||||||
|
column: x => x.first_id,
|
||||||
|
principalTable: "libraries",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_link_library_show_shows_second_id",
|
||||||
|
column: x => x.second_id,
|
||||||
|
principalTable: "shows",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "link_show_genre",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
first_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
second_id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_link_show_genre", x => new { x.first_id, x.second_id });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_link_show_genre_genres_second_id",
|
||||||
|
column: x => x.second_id,
|
||||||
|
principalTable: "genres",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_link_show_genre_shows_first_id",
|
||||||
|
column: x => x.first_id,
|
||||||
|
principalTable: "shows",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "link_user_show",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
first_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
second_id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_link_user_show", x => new { x.first_id, x.second_id });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_link_user_show_shows_second_id",
|
||||||
|
column: x => x.second_id,
|
||||||
|
principalTable: "shows",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_link_user_show_users_first_id",
|
||||||
|
column: x => x.first_id,
|
||||||
|
principalTable: "users",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "metadata_id_show",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
first_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
second_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
data_id = table.Column<string>(type: "text", nullable: true),
|
||||||
|
link = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_metadata_id_show", x => new { x.first_id, x.second_id });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_metadata_id_show_providers_second_id",
|
||||||
|
column: x => x.second_id,
|
||||||
|
principalTable: "providers",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_metadata_id_show_shows_first_id",
|
||||||
|
column: x => x.first_id,
|
||||||
|
principalTable: "shows",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "people_roles",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
for_people = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
people_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
show_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
type = table.Column<string>(type: "text", nullable: true),
|
||||||
|
role = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_people_roles", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_people_roles_people_people_id",
|
||||||
|
column: x => x.people_id,
|
||||||
|
principalTable: "people",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_people_roles_shows_show_id",
|
||||||
|
column: x => x.show_id,
|
||||||
|
principalTable: "shows",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "seasons",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
slug = table.Column<string>(type: "text", nullable: true),
|
||||||
|
show_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
season_number = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
title = table.Column<string>(type: "text", nullable: true),
|
||||||
|
overview = table.Column<string>(type: "text", nullable: true),
|
||||||
|
start_date = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
|
||||||
|
end_date = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
|
||||||
|
poster = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_seasons", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_seasons_shows_show_id",
|
||||||
|
column: x => x.show_id,
|
||||||
|
principalTable: "shows",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "episodes",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
slug = table.Column<string>(type: "text", nullable: true),
|
||||||
|
show_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
season_id = table.Column<int>(type: "integer", nullable: true),
|
||||||
|
season_number = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
episode_number = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
absolute_number = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
path = table.Column<string>(type: "text", nullable: true),
|
||||||
|
thumb = table.Column<string>(type: "text", nullable: true),
|
||||||
|
title = table.Column<string>(type: "text", nullable: true),
|
||||||
|
overview = table.Column<string>(type: "text", nullable: true),
|
||||||
|
release_date = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_episodes", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_episodes_seasons_season_id",
|
||||||
|
column: x => x.season_id,
|
||||||
|
principalTable: "seasons",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_episodes_shows_show_id",
|
||||||
|
column: x => x.show_id,
|
||||||
|
principalTable: "shows",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "metadata_id_season",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
first_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
second_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
data_id = table.Column<string>(type: "text", nullable: true),
|
||||||
|
link = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_metadata_id_season", x => new { x.first_id, x.second_id });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_metadata_id_season_providers_second_id",
|
||||||
|
column: x => x.second_id,
|
||||||
|
principalTable: "providers",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_metadata_id_season_seasons_first_id",
|
||||||
|
column: x => x.first_id,
|
||||||
|
principalTable: "seasons",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "metadata_id_episode",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
first_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
second_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
data_id = table.Column<string>(type: "text", nullable: true),
|
||||||
|
link = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_metadata_id_episode", x => new { x.first_id, x.second_id });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_metadata_id_episode_episodes_first_id",
|
||||||
|
column: x => x.first_id,
|
||||||
|
principalTable: "episodes",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_metadata_id_episode_providers_second_id",
|
||||||
|
column: x => x.second_id,
|
||||||
|
principalTable: "providers",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "tracks",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
slug = table.Column<string>(type: "text", nullable: true),
|
||||||
|
title = table.Column<string>(type: "text", nullable: true),
|
||||||
|
language = table.Column<string>(type: "text", nullable: true),
|
||||||
|
codec = table.Column<string>(type: "text", nullable: true),
|
||||||
|
is_default = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
is_forced = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
is_external = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
path = table.Column<string>(type: "text", nullable: true),
|
||||||
|
type = table.Column<StreamType>(type: "stream_type", nullable: false),
|
||||||
|
episode_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
track_index = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_tracks", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_tracks_episodes_episode_id",
|
||||||
|
column: x => x.episode_id,
|
||||||
|
principalTable: "episodes",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "watched_episodes",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
first_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
second_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
watched_percentage = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_watched_episodes", x => new { x.first_id, x.second_id });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_watched_episodes_episodes_second_id",
|
||||||
|
column: x => x.second_id,
|
||||||
|
principalTable: "episodes",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_watched_episodes_users_first_id",
|
||||||
|
column: x => x.first_id,
|
||||||
|
principalTable: "users",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_collections_slug",
|
||||||
|
table: "collections",
|
||||||
|
column: "slug",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_episodes_season_id",
|
||||||
|
table: "episodes",
|
||||||
|
column: "season_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_episodes_show_id_season_number_episode_number_absolute_numb",
|
||||||
|
table: "episodes",
|
||||||
|
columns: new[] { "show_id", "season_number", "episode_number", "absolute_number" },
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_episodes_slug",
|
||||||
|
table: "episodes",
|
||||||
|
column: "slug",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_genres_slug",
|
||||||
|
table: "genres",
|
||||||
|
column: "slug",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_libraries_slug",
|
||||||
|
table: "libraries",
|
||||||
|
column: "slug",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_link_collection_show_second_id",
|
||||||
|
table: "link_collection_show",
|
||||||
|
column: "second_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_link_library_collection_second_id",
|
||||||
|
table: "link_library_collection",
|
||||||
|
column: "second_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_link_library_provider_second_id",
|
||||||
|
table: "link_library_provider",
|
||||||
|
column: "second_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_link_library_show_second_id",
|
||||||
|
table: "link_library_show",
|
||||||
|
column: "second_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_link_show_genre_second_id",
|
||||||
|
table: "link_show_genre",
|
||||||
|
column: "second_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_link_user_show_second_id",
|
||||||
|
table: "link_user_show",
|
||||||
|
column: "second_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_metadata_id_episode_second_id",
|
||||||
|
table: "metadata_id_episode",
|
||||||
|
column: "second_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_metadata_id_people_second_id",
|
||||||
|
table: "metadata_id_people",
|
||||||
|
column: "second_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_metadata_id_season_second_id",
|
||||||
|
table: "metadata_id_season",
|
||||||
|
column: "second_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_metadata_id_show_second_id",
|
||||||
|
table: "metadata_id_show",
|
||||||
|
column: "second_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_people_slug",
|
||||||
|
table: "people",
|
||||||
|
column: "slug",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_people_roles_people_id",
|
||||||
|
table: "people_roles",
|
||||||
|
column: "people_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_people_roles_show_id",
|
||||||
|
table: "people_roles",
|
||||||
|
column: "show_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_providers_slug",
|
||||||
|
table: "providers",
|
||||||
|
column: "slug",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_seasons_show_id_season_number",
|
||||||
|
table: "seasons",
|
||||||
|
columns: new[] { "show_id", "season_number" },
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_seasons_slug",
|
||||||
|
table: "seasons",
|
||||||
|
column: "slug",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_shows_slug",
|
||||||
|
table: "shows",
|
||||||
|
column: "slug",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_shows_studio_id",
|
||||||
|
table: "shows",
|
||||||
|
column: "studio_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_studios_slug",
|
||||||
|
table: "studios",
|
||||||
|
column: "slug",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_tracks_episode_id_type_language_track_index_is_forced",
|
||||||
|
table: "tracks",
|
||||||
|
columns: new[] { "episode_id", "type", "language", "track_index", "is_forced" },
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_tracks_slug",
|
||||||
|
table: "tracks",
|
||||||
|
column: "slug",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_users_slug",
|
||||||
|
table: "users",
|
||||||
|
column: "slug",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_watched_episodes_second_id",
|
||||||
|
table: "watched_episodes",
|
||||||
|
column: "second_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "link_collection_show");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "link_library_collection");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "link_library_provider");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "link_library_show");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "link_show_genre");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "link_user_show");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "metadata_id_episode");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "metadata_id_people");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "metadata_id_season");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "metadata_id_show");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "people_roles");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "tracks");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "watched_episodes");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "collections");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "libraries");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "genres");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "providers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "people");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "episodes");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "users");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "seasons");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "shows");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "studios");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -13,10 +13,10 @@ namespace Kyoo.Postgresql.Migrations
|
|||||||
LANGUAGE PLPGSQL
|
LANGUAGE PLPGSQL
|
||||||
AS $$
|
AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
NEW.""Slug"" := CONCAT(
|
NEW.slug := CONCAT(
|
||||||
(SELECT ""Slug"" FROM ""Shows"" WHERE ""ID"" = NEW.""ShowID""),
|
(SELECT slug FROM shows WHERE id = NEW.show_id),
|
||||||
'-s',
|
'-s',
|
||||||
NEW.""SeasonNumber""
|
NEW.season_number
|
||||||
);
|
);
|
||||||
RETURN NEW;
|
RETURN NEW;
|
||||||
END
|
END
|
||||||
@ -24,7 +24,7 @@ namespace Kyoo.Postgresql.Migrations
|
|||||||
|
|
||||||
// language=PostgreSQL
|
// language=PostgreSQL
|
||||||
migrationBuilder.Sql(@"
|
migrationBuilder.Sql(@"
|
||||||
CREATE TRIGGER season_slug_trigger BEFORE INSERT OR UPDATE OF ""SeasonNumber"", ""ShowID"" ON ""Seasons""
|
CREATE TRIGGER season_slug_trigger BEFORE INSERT OR UPDATE OF season_number, show_id ON seasons
|
||||||
FOR EACH ROW EXECUTE PROCEDURE season_slug_update();");
|
FOR EACH ROW EXECUTE PROCEDURE season_slug_update();");
|
||||||
|
|
||||||
|
|
||||||
@ -35,14 +35,14 @@ namespace Kyoo.Postgresql.Migrations
|
|||||||
LANGUAGE PLPGSQL
|
LANGUAGE PLPGSQL
|
||||||
AS $$
|
AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
UPDATE ""Seasons"" SET ""Slug"" = CONCAT(new.""Slug"", '-s', ""SeasonNumber"") WHERE ""ShowID"" = NEW.""ID"";
|
UPDATE seasons SET slug = CONCAT(NEW.slug, '-s', season_number) WHERE show_id = NEW.id;
|
||||||
RETURN NEW;
|
RETURN NEW;
|
||||||
END
|
END
|
||||||
$$;");
|
$$;");
|
||||||
|
|
||||||
// language=PostgreSQL
|
// language=PostgreSQL
|
||||||
migrationBuilder.Sql(@"
|
migrationBuilder.Sql(@"
|
||||||
CREATE TRIGGER show_slug_trigger AFTER UPDATE OF ""Slug"" ON ""Shows""
|
CREATE TRIGGER show_slug_trigger AFTER UPDATE OF slug ON shows
|
||||||
FOR EACH ROW EXECUTE PROCEDURE show_slug_update();");
|
FOR EACH ROW EXECUTE PROCEDURE show_slug_update();");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,11 +51,11 @@ namespace Kyoo.Postgresql.Migrations
|
|||||||
// language=PostgreSQL
|
// language=PostgreSQL
|
||||||
migrationBuilder.Sql(@"DROP FUNCTION season_slug_update;");
|
migrationBuilder.Sql(@"DROP FUNCTION season_slug_update;");
|
||||||
// language=PostgreSQL
|
// language=PostgreSQL
|
||||||
migrationBuilder.Sql("DROP TRIGGER show_slug_trigger ON \"Shows\";");
|
migrationBuilder.Sql("DROP TRIGGER show_slug_trigger ON shows;");
|
||||||
// language=PostgreSQL
|
// language=PostgreSQL
|
||||||
migrationBuilder.Sql(@"DROP FUNCTION show_slug_update;");
|
migrationBuilder.Sql(@"DROP FUNCTION show_slug_update;");
|
||||||
// language=PostgreSQL
|
// language=PostgreSQL
|
||||||
migrationBuilder.Sql(@"DROP TRIGGER season_slug_trigger;");
|
migrationBuilder.Sql(@"DROP TRIGGER season_slug_trigger ON seasons;");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
@ -77,6 +77,7 @@ namespace Kyoo.Postgresql
|
|||||||
optionsBuilder.EnableDetailedErrors().EnableSensitiveDataLogging();
|
optionsBuilder.EnableDetailedErrors().EnableSensitiveDataLogging();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
optionsBuilder.UseSnakeCaseNamingConvention();
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user