-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add image tag * refactoring after split query
- Loading branch information
Showing
10 changed files
with
230 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
ImageHosting.Persistence/Entities/Configuration/ImageTagConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using ImageHosting.Persistence.ValueTypes; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace ImageHosting.Persistence.Entities.Configuration; | ||
|
||
public class ImageTagConfiguration : IEntityTypeConfiguration<ImageTag> | ||
{ | ||
public void Configure(EntityTypeBuilder<ImageTag> builder) | ||
{ | ||
builder.Property(it => it.TagName).HasMaxLength(32); | ||
builder.Property(it => it.ImageId).HasConversion<ImageId.ValueConverter>(); | ||
builder.HasKey(it => new { it.ImageId, it.TagName }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using ImageHosting.Persistence.Entities.Configuration; | ||
using ImageHosting.Persistence.ValueTypes; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace ImageHosting.Persistence.Entities; | ||
|
||
[EntityTypeConfiguration(typeof(ImageTagConfiguration))] | ||
public class ImageTag | ||
{ | ||
public required Image Image { get; set; } | ||
public ImageId ImageId { get; init; } | ||
public required string TagName { get; init; } | ||
} |
99 changes: 99 additions & 0 deletions
99
ImageHosting.Persistence/Migrations/20240309103014_AddImageTag.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
ImageHosting.Persistence/Migrations/20240309103014_AddImageTag.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace ImageHosting.Persistence.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class AddImageTag : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropColumn( | ||
name: "Categories", | ||
table: "Images"); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "ImageTag", | ||
columns: table => new | ||
{ | ||
ImageId = table.Column<Guid>(type: "uuid", nullable: false), | ||
TagName = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_ImageTag", x => new { x.ImageId, x.TagName }); | ||
table.ForeignKey( | ||
name: "FK_ImageTag_Images_ImageId", | ||
column: x => x.ImageId, | ||
principalTable: "Images", | ||
principalColumn: "Id", | ||
onDelete: ReferentialAction.Cascade); | ||
}); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "ImageTag"); | ||
|
||
migrationBuilder.AddColumn<List<string>>( | ||
name: "Categories", | ||
table: "Images", | ||
type: "varchar(200)[]", | ||
nullable: true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters