traxxx/migrations/20230104014437_release_show...

21 lines
704 B
JavaScript
Raw Normal View History

2023-01-14 22:44:32 +00:00
const config = require('config');
2023-01-14 22:44:32 +00:00
exports.up = async (knex) => knex.raw(`
2023-01-16 20:32:22 +00:00
CREATE VIEW releases_not_showcased AS (
2023-01-14 22:44:32 +00:00
SELECT releases.id AS release_id FROM releases
LEFT JOIN entities ON entities.id = releases.entity_id
LEFT JOIN entities AS studios ON studios.id = releases.studio_id
2023-01-16 20:32:22 +00:00
WHERE entities.showcased = false
OR studios.showcased = false
2023-01-14 22:44:32 +00:00
);
2023-01-16 20:32:22 +00:00
COMMENT ON VIEW releases_not_showcased IS E'@foreignKey (release_id) references releases (id)';
GRANT SELECT ON releases_not_showcased TO :visitor;
2023-01-14 22:44:32 +00:00
`, {
visitor: knex.raw(config.database.query.user),
});
exports.down = async (knex) => knex.raw(`
2023-01-16 20:32:22 +00:00
DROP VIEW IF EXISTS releases_not_showcased;
2023-01-14 22:44:32 +00:00
`);