mirror of https://github.com/ErsatzTV/ErsatzTV.git
14 changed files with 27374 additions and 5 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,33 @@ |
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||||
|
|
||||||
|
#nullable disable |
||||||
|
|
||||||
|
namespace ErsatzTV.Infrastructure.MySql.Migrations |
||||||
|
{ |
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Fix_DuplicateSmartCollectionName : Migration |
||||||
|
{ |
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.Sql( |
||||||
|
@"
|
||||||
|
WITH Numbered AS ( |
||||||
|
SELECT |
||||||
|
Id, |
||||||
|
ROW_NUMBER() OVER (PARTITION BY Name ORDER BY Id) as RowNum |
||||||
|
FROM SmartCollection |
||||||
|
) |
||||||
|
UPDATE SmartCollection sc |
||||||
|
JOIN Numbered n ON sc.Id = n.Id |
||||||
|
SET sc.Name = CONCAT(sc.Name, ' (', n.RowNum - 1, ')') |
||||||
|
WHERE n.RowNum > 1; |
||||||
|
");
|
||||||
|
} |
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,50 @@ |
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||||
|
|
||||||
|
#nullable disable |
||||||
|
|
||||||
|
namespace ErsatzTV.Infrastructure.MySql.Migrations |
||||||
|
{ |
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Add_SmartCollectionNameUnique : Migration |
||||||
|
{ |
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.AlterColumn<string>( |
||||||
|
name: "Name", |
||||||
|
table: "SmartCollection", |
||||||
|
type: "varchar(255)", |
||||||
|
nullable: true, |
||||||
|
oldClrType: typeof(string), |
||||||
|
oldType: "longtext", |
||||||
|
oldNullable: true) |
||||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4"); |
||||||
|
|
||||||
|
migrationBuilder.CreateIndex( |
||||||
|
name: "IX_SmartCollection_Name", |
||||||
|
table: "SmartCollection", |
||||||
|
column: "Name", |
||||||
|
unique: true); |
||||||
|
} |
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.DropIndex( |
||||||
|
name: "IX_SmartCollection_Name", |
||||||
|
table: "SmartCollection"); |
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<string>( |
||||||
|
name: "Name", |
||||||
|
table: "SmartCollection", |
||||||
|
type: "longtext", |
||||||
|
nullable: true, |
||||||
|
oldClrType: typeof(string), |
||||||
|
oldType: "varchar(255)", |
||||||
|
oldNullable: true) |
||||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,34 @@ |
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||||
|
|
||||||
|
#nullable disable |
||||||
|
|
||||||
|
namespace ErsatzTV.Infrastructure.Sqlite.Migrations |
||||||
|
{ |
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Fix_DuplicateSmartCollectionName : Migration |
||||||
|
{ |
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.Sql( |
||||||
|
@"
|
||||||
|
WITH Numbered AS ( |
||||||
|
SELECT |
||||||
|
Id, |
||||||
|
ROW_NUMBER() OVER (PARTITION BY Name ORDER BY Id) AS RowNum |
||||||
|
FROM SmartCollection |
||||||
|
) |
||||||
|
UPDATE SmartCollection |
||||||
|
SET Name = Name || ' (' || (Numbered.RowNum - 1) || ')' |
||||||
|
FROM Numbered |
||||||
|
WHERE SmartCollection.Id = Numbered.Id |
||||||
|
AND Numbered.RowNum > 1; |
||||||
|
");
|
||||||
|
} |
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,28 @@ |
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||||
|
|
||||||
|
#nullable disable |
||||||
|
|
||||||
|
namespace ErsatzTV.Infrastructure.Sqlite.Migrations |
||||||
|
{ |
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Add_SmartCollectionNameUnique : Migration |
||||||
|
{ |
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.CreateIndex( |
||||||
|
name: "IX_SmartCollection_Name", |
||||||
|
table: "SmartCollection", |
||||||
|
column: "Name", |
||||||
|
unique: true); |
||||||
|
} |
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.DropIndex( |
||||||
|
name: "IX_SmartCollection_Name", |
||||||
|
table: "SmartCollection"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue