From 9e2eaef9d13a61759ab366a7631c3f81f08e3b4f Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Mon, 28 Mar 2022 00:22:57 +0200 Subject: [PATCH] Added dedicated serie photos table, renamed serie scene photo function. Fixed covers and scene photos in banner and album. --- assets/components/releases/banner.vue | 32 +++++++++++++---------- assets/components/releases/release.vue | 4 +-- assets/js/releases/actions.js | 2 +- migrations/20220327230125_movie_photos.js | 18 +++++++++++++ 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/assets/components/releases/banner.vue b/assets/components/releases/banner.vue index 46c8a400..e11ad878 100644 --- a/assets/components/releases/banner.vue +++ b/assets/components/releases/banner.vue @@ -2,7 +2,7 @@
@@ -287,7 +287,7 @@ function pageTitle() { } function showAlbum() { - return this.release.photos?.length > 0 && this.$route.hash === '#album'; + return (this.release.photos?.length > 0 || this.release.scenesPhotos?.length > 0) && this.$route.hash === '#album'; } export default { diff --git a/assets/js/releases/actions.js b/assets/js/releases/actions.js index 1b293c99..5ecf64d5 100644 --- a/assets/js/releases/actions.js +++ b/assets/js/releases/actions.js @@ -227,7 +227,7 @@ function initReleasesActions(store, router) { slug name } - photos: moviesPhotos { + photos: ${type === 'series' ? 'seriesPhotosBySerieId' : 'moviesPhotos'} { ${mediaFragment} } scenesPhotos { diff --git a/migrations/20220327230125_movie_photos.js b/migrations/20220327230125_movie_photos.js index ee5b8638..41e09bc4 100644 --- a/migrations/20220327230125_movie_photos.js +++ b/migrations/20220327230125_movie_photos.js @@ -3,6 +3,7 @@ const config = require('config'); exports.up = async (knex) => Promise.resolve() .then(() => knex.raw(` ALTER FUNCTION movies_photos(movie movies) RENAME TO movies_scenes_photos; + ALTER FUNCTION series_photos(serie series) RENAME TO series_scenes_photos; `)) .then(() => knex.schema.createTable('movies_photos', (table) => { table.integer('movie_id', 16) @@ -18,6 +19,20 @@ exports.up = async (knex) => Promise.resolve() table.unique(['movie_id', 'media_id']); })) + .then(() => knex.schema.createTable('series_photos', (table) => { + table.integer('serie_id', 16) + .notNullable() + .references('id') + .inTable('series') + .onDelete('cascade'); + + table.text('media_id', 21) + .notNullable() + .references('id') + .inTable('media'); + + table.unique(['serie_id', 'media_id']); + })) .then(() => knex.raw(` GRANT ALL ON ALL TABLES IN SCHEMA public TO :visitor; GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO :visitor; @@ -27,5 +42,8 @@ exports.up = async (knex) => Promise.resolve() exports.down = async (knex) => knex.raw(` DROP TABLE IF EXISTS movies_photos CASCADE; + DROP TABLE IF EXISTS series_photos CASCADE; + ALTER FUNCTION movies_scenes_photos(movie movies) RENAME TO movies_photos; + ALTER FUNCTION series_scenes_photos(serie series) RENAME TO series_photos; `);