features/cutover-to-ef #9

Merged
jtom38 merged 27 commits from features/cutover-to-ef into main 2023-06-25 21:15:58 -07:00
3 changed files with 30 additions and 13 deletions
Showing only changes of commit a343fa2d7f - Show all commits

View File

@ -1,3 +1,4 @@
using Newsbot.Collector.Domain.Entities;
using Newsbot.Collector.Domain.Models; using Newsbot.Collector.Domain.Models;
namespace Newsbot.Collector.Domain.Dto; namespace Newsbot.Collector.Domain.Dto;
@ -36,4 +37,24 @@ public class ArticleDto
AuthorImage = article.AuthorImage, AuthorImage = article.AuthorImage,
}; };
} }
public static ArticleDto Convert(ArticlesEntity article)
{
return new ArticleDto
{
ID = article.Id,
SourceID = article.SourceId,
Tags = article.Tags.Split(','),
Title = article.Title,
Url = article.Url,
PubDate = article.PubDate,
Video = article.Video,
VideoHeight = article.VideoHeight,
VideoWidth = article.VideoWidth,
Thumbnail = article.Thumbnail,
Description = article.Description,
AuthorName = article.AuthorName,
AuthorImage = article.AuthorImage,
};
}
} }

View File

@ -1,13 +1,14 @@
using Newsbot.Collector.Domain.Entities;
using Newsbot.Collector.Domain.Models; using Newsbot.Collector.Domain.Models;
namespace Newsbot.Collector.Domain.Interfaces; namespace Newsbot.Collector.Domain.Interfaces;
public interface IArticlesRepository : ITableRepository public interface IArticlesRepository : ITableRepository
{ {
List<ArticlesModel> List(int page, int count); List<ArticlesEntity> List(int page, int count);
List<ArticlesModel> ListBySourceId(Guid id, int page = 0, int count = 25); List<ArticlesModel> ListBySourceId(Guid id, int page = 0, int count = 25);
ArticlesModel GetById(Guid ID); ArticlesModel GetById(Guid ID);
ArticlesModel GetByUrl(string url); ArticlesModel GetByUrl(string url);
ArticlesModel New(ArticlesModel model); ArticlesEntity New(ArticlesEntity model);
void DeleteAllBySourceId(Guid sourceId); void DeleteAllBySourceId(Guid sourceId);
} }

View File

@ -21,14 +21,9 @@ docker-run: ## Runs the docker compose
docker-migrate: ## Runs the migrations stored in the Docker image docker-migrate: ## Runs the migrations stored in the Docker image
docker run -it --env-file .env ghcr.io/jtom38/newsbot.collector:master /app/goose --dir "/app/migrations" up docker run -it --env-file .env ghcr.io/jtom38/newsbot.collector:master /app/goose --dir "/app/migrations" up
migrate-dev: ## Apply sql migrations to dev db ef-build: ## Builds migration artifact
goose -dir "./Newsbot.Collector.Database/Migrations" postgres "host=localhost user=postgres password=postgres dbname=postgres sslmode=disable" up dotnet ef migrations bundle --project "Newsbot.Collector.Database"
migrate-dev-down: ## revert sql migrations to dev db ef-migrate: ## Runs migrations based on the newest artifact
goose -dir "./Newsbot.Collector.Database/Migrations" postgres "host=localhost user=postgres password=postgres dbname=postgres sslmode=disable" down dotnet ef migrations bundle --project "Newsbot.Collector.Database" --force
./efbundle --connection "Host=localhost;Username=postgres;Password=postgres;Database=postgres;sslmode=disable"
migrate-refresh: ## Rolls back all migrations
goose -dir "./Newsbot.Collector.Database/Migrations" postgres "host=localhost user=postgres password=postgres dbname=postgres sslmode=disable" reset
ef-bundle: ## Create a migration bundle
dotnet ef migrations bundle --project Newsbot.Collector.Database