Skip to content

Commit

Permalink
sql to append mediae
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-zhur committed Sep 27, 2024
1 parent 84567cc commit 7cb00bc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions OneShelf.Videos/OneShelf.Videos.Database/VideosDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,25 @@ public VideosDatabase(DbContextOptions<VideosDatabase> options)
public required DbSet<AlbumConstraint> AlbumConstraints { get; set; }
public required DbSet<UploadedAlbum> UploadedAlbums { get; set; }

public async Task AppendMediae()
{
await Database.ExecuteSqlAsync(@$"
insert into mediae (staticchatid, staticmessageid)
select sm.staticchatid, sm.id
from StaticMessages sm
left join mediae m on m.staticmessageid = sm.id and m.staticchatid = sm.StaticChatId
where sm.SelectedType is not null and m.id is null
insert into mediae (livechatid, livemediaid)
select lm.livetopiclivechatid, lm.id
from livemediae lm
left join mediae m on m.livemediaid = lm.id and m.livechatid = lm.livetopiclivechatid
where m.id is null
");
}

public async Task CleanupTopics()
{
await Database.ExecuteSqlAsync(@$"
Expand Down

0 comments on commit 7cb00bc

Please sign in to comment.