diff --git a/back/src/Kyoo.Postgresql/Migrations/20240414212454_AddNextRefresh.cs b/back/src/Kyoo.Postgresql/Migrations/20240414212454_AddNextRefresh.cs index 9bf62d1e..c1875fd6 100644 --- a/back/src/Kyoo.Postgresql/Migrations/20240414212454_AddNextRefresh.cs +++ b/back/src/Kyoo.Postgresql/Migrations/20240414212454_AddNextRefresh.cs @@ -54,11 +54,17 @@ public partial class AddNextRefresh : Migration // language=PostgreSQL migrationBuilder.Sql( """ - update episodes as e set external_id = jsonb_build_object( - 'ShowId', e.show_id, - 'SeasonNumber', e.season_number, - 'EpisodeNumber', e.episode_number, - 'Link', null + update episodes as e set external_id = ( + SELECT jsonb_build_object( + 'themoviedatabase', jsonb_build_object( + 'ShowId', s.external_id->'themoviedatabase'->'DataId', + 'Season', e.season_number, + 'Episode', e.episode_number, + 'Link', null + ) + ) + FROM shows AS s + WHERE s.id = e.show_id ); """ ); diff --git a/back/src/Kyoo.Postgresql/PostgresContext.cs b/back/src/Kyoo.Postgresql/PostgresContext.cs index 54dfe6a1..f907accd 100644 --- a/back/src/Kyoo.Postgresql/PostgresContext.cs +++ b/back/src/Kyoo.Postgresql/PostgresContext.cs @@ -82,6 +82,10 @@ public class PostgresContext(DbContextOptions options, IHttpContextAccessor acce typeof(Dictionary), new JsonTypeHandler>() ); + SqlMapper.AddTypeHandler( + typeof(Dictionary), + new JsonTypeHandler>() + ); SqlMapper.AddTypeHandler( typeof(Dictionary), new JsonTypeHandler>()