Added dedicated movie photo table, renamed scene photo function.

This commit is contained in:
DebaucheryLibrarian
2022-03-27 23:42:03 +02:00
parent 295573c1ef
commit 15c9af8057
8 changed files with 61 additions and 36 deletions

View File

@@ -183,8 +183,6 @@ exports.up = async (knex) => Promise.resolve()
ORDER BY media.index ASC
$$ LANGUAGE SQL STABLE;
COMMENT ON FUNCTION search_movies IS E'@sortable';
GRANT ALL ON ALL TABLES IN SCHEMA public TO :visitor;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO :visitor;

View File

@@ -0,0 +1,31 @@
const config = require('config');
exports.up = async (knex) => Promise.resolve()
.then(() => knex.raw(`
ALTER FUNCTION movies_photos(movie movies) RENAME TO movies_scenes_photos;
`))
.then(() => knex.schema.createTable('movies_photos', (table) => {
table.integer('movie_id', 16)
.notNullable()
.references('id')
.inTable('movies')
.onDelete('cascade');
table.text('media_id', 21)
.notNullable()
.references('id')
.inTable('media');
table.unique(['movie_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;
`, {
visitor: knex.raw(config.database.query.user),
}));
exports.down = async (knex) => knex.raw(`
DROP TABLE IF EXISTS movies_photos CASCADE;
ALTER FUNCTION movies_scenes_photos(movie movies) RENAME TO movies_photos;
`);