Adding language highlight

This commit is contained in:
Zoe Roux 2021-06-23 19:48:05 +02:00
parent 8a3b9e1dec
commit 27a69b5a34
2 changed files with 24 additions and 6 deletions

View File

@ -6,6 +6,7 @@ namespace Kyoo.Postgresql.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
// language=PostgreSQL
migrationBuilder.Sql(@"
CREATE FUNCTION season_slug_update()
RETURNS TRIGGER
@ -21,11 +22,13 @@ namespace Kyoo.Postgresql.Migrations
END
$$;");
// language=PostgreSQL
migrationBuilder.Sql(@"
CREATE TRIGGER ""SeasonSlug"" BEFORE INSERT OR UPDATE OF ""SeasonNumber"", ""ShowID"" ON ""Seasons""
CREATE TRIGGER season_slug_trigger BEFORE INSERT OR UPDATE OF ""SeasonNumber"", ""ShowID"" ON ""Seasons""
FOR EACH ROW EXECUTE PROCEDURE season_slug_update();");
// language=PostgreSQL
migrationBuilder.Sql(@"
CREATE FUNCTION show_slug_update()
RETURNS TRIGGER
@ -37,17 +40,22 @@ namespace Kyoo.Postgresql.Migrations
END
$$;");
// language=PostgreSQL
migrationBuilder.Sql(@"
CREATE TRIGGER ""ShowSlug"" 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();");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(@"DROP FUNCTION ""season_slug_update"";");
migrationBuilder.Sql(@"DROP TRIGGER ""SeasonSlug"";");
migrationBuilder.Sql(@"DROP FUNCTION ""show_slug_update"";");
migrationBuilder.Sql(@"DROP TRIGGER ""ShowSlug"";");
// language=PostgreSQL
migrationBuilder.Sql(@"DROP FUNCTION season_slug_update;");
// language=PostgreSQL
migrationBuilder.Sql("DROP TRIGGER show_slug_trigger ON \"Shows\";");
// language=PostgreSQL
migrationBuilder.Sql(@"DROP FUNCTION show_slug_update;");
// language=PostgreSQL
migrationBuilder.Sql(@"DROP TRIGGER season_slug_trigger;");
}
}
}

View File

@ -6,12 +6,14 @@ namespace Kyoo.SqLite.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
// language=SQLite
migrationBuilder.Sql(@"
CREATE TRIGGER SeasonSlugInsert AFTER INSERT ON Seasons FOR EACH ROW
BEGIN
UPDATE Seasons SET Slug = (SELECT Slug from Shows WHERE ID = ShowID) || '-s' || SeasonNumber
WHERE ID == new.ID;
END");
// language=SQLite
migrationBuilder.Sql(@"
CREATE TRIGGER SeasonSlugUpdate AFTER UPDATE OF SeasonNumber, ShowID ON Seasons FOR EACH ROW
BEGIN
@ -19,12 +21,14 @@ namespace Kyoo.SqLite.Migrations
WHERE ID == new.ID;
END");
// language=SQLite
migrationBuilder.Sql(@"
CREATE TRIGGER EpisodeSlugInsert AFTER INSERT ON Episodes FOR EACH ROW
BEGIN
UPDATE Episodes SET Slug = (SELECT Slug from Shows WHERE ID = ShowID) || '-s' || SeasonNumber || 'e' || EpisodeNumber
WHERE ID == new.ID;
END");
// language=SQLite
migrationBuilder.Sql(@"
CREATE TRIGGER EpisodeSlugUpdate AFTER UPDATE OF EpisodeNumber, SeasonNumber, ShowID ON Episodes FOR EACH ROW
BEGIN
@ -33,6 +37,7 @@ namespace Kyoo.SqLite.Migrations
END");
// language=SQLite
migrationBuilder.Sql(@"
CREATE TRIGGER ShowSlugUpdate AFTER UPDATE OF Slug ON Shows FOR EACH ROW
BEGIN
@ -43,10 +48,15 @@ namespace Kyoo.SqLite.Migrations
protected override void Down(MigrationBuilder migrationBuilder)
{
// language=SQLite
migrationBuilder.Sql("DROP TRIGGER SeasonSlugInsert;");
// language=SQLite
migrationBuilder.Sql("DROP TRIGGER SeasonSlugUpdate;");
// language=SQLite
migrationBuilder.Sql("DROP TRIGGER EpisodeSlugInsert;");
// language=SQLite
migrationBuilder.Sql("DROP TRIGGER EpisodeSlugUpdate;");
// language=SQLite
migrationBuilder.Sql("DROP TRIGGER ShowSlugUpdate;");
}
}