Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

Commit

Permalink
#28 Added migration with database configuration for fts
Browse files Browse the repository at this point in the history
  • Loading branch information
Nypifok committed Dec 8, 2020
1 parent 2970683 commit b2357d2
Show file tree
Hide file tree
Showing 8 changed files with 657 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using ImageBase.WebApp.Data.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;


namespace ImageBase.WebApp.Data.ConfigurationDataBase.ConfigurationPostgreSQL
{
public class ImageFtSearchConfiguration
{
public ImageFtSearchConfiguration(EntityTypeBuilder<ImageFtSearch> entityBuilder)
{
entityBuilder.HasKey(ifts => ifts.Id);
entityBuilder.Property(ifts => ifts.Id).HasColumnName("id");
entityBuilder.HasOne(ifts => ifts.Image).WithOne(i => i.ImageFtSearch).HasForeignKey<ImageFtSearch>(ifts => ifts.ImageId).OnDelete(DeleteBehavior.Cascade);

entityBuilder.Property(ifts => ifts.ImageId).HasColumnName("image_id").IsRequired();
entityBuilder.Property(ifts => ifts.ImageVector).HasColumnName("image_vector").IsRequired();
entityBuilder.Property(ifts => ifts.Id).ValueGeneratedOnAdd();

entityBuilder.ToTable("images_ft_search");
}
}
}
2 changes: 1 addition & 1 deletion ImageBase.WebApp/Data/Models/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Image: BaseEntity<long>
public string Title { get; set; }
public string Description { get; set; }
public string KeyWords { get; set; }

public ImageFtSearch ImageFtSearch { get; set; }
public List<ImageCatalog> ImageCatalogs { get; set; }
}
}
15 changes: 15 additions & 0 deletions ImageBase.WebApp/Data/Models/ImageFtSearch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using NpgsqlTypes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ImageBase.WebApp.Data.Models
{
public class ImageFtSearch:BaseEntity<long>
{
public long ImageId { get; set; }
public NpgsqlTsVector ImageVector { get; set; }
public Image Image { get; set; }
}
}
5 changes: 5 additions & 0 deletions ImageBase.WebApp/ImageBase.WebApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<UserSecretsId>4b34e02f-e6d2-4333-96e0-8ea1851999bb</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Migrations\20201204093640_FTSIntegration.cs" />
<Compile Remove="Migrations\20201204093640_FTSIntegration.Designer.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.0" />
Expand Down
Loading

0 comments on commit b2357d2

Please sign in to comment.