Added dark and SFW modes.
This commit is contained in:
@@ -36,7 +36,9 @@ exports.up = knex => Promise.resolve()
|
||||
table.string('scraper', 32);
|
||||
table.string('copyright', 100);
|
||||
table.string('source', 1000);
|
||||
|
||||
table.text('comment');
|
||||
table.string('group');
|
||||
|
||||
table.unique('hash');
|
||||
table.unique('source');
|
||||
@@ -44,6 +46,28 @@ exports.up = knex => Promise.resolve()
|
||||
table.datetime('created_at')
|
||||
.defaultTo(knex.fn.now());
|
||||
}))
|
||||
.then(() => knex.schema.createTable('media_sfw', (table) => {
|
||||
table.increments('id', 12);
|
||||
|
||||
table.integer('media_id', 16)
|
||||
.references('id')
|
||||
.inTable('media');
|
||||
|
||||
table.unique('media_id');
|
||||
}))
|
||||
.then(() => knex.raw(`
|
||||
CREATE FUNCTION get_random_sfw_media_id() RETURNS int AS $$
|
||||
SELECT media_id FROM media_sfw
|
||||
ORDER BY random()
|
||||
LIMIT 1;
|
||||
$$ LANGUAGE sql STABLE;
|
||||
`))
|
||||
.then(() => knex.schema.alterTable('media', (table) => {
|
||||
table.integer('sfw_media_id', 16)
|
||||
.references('id')
|
||||
.inTable('media')
|
||||
.defaultTo(knex.raw('get_random_sfw_media_id()'));
|
||||
}))
|
||||
.then(() => knex.schema.createTable('tags_groups', (table) => {
|
||||
table.increments('id', 12);
|
||||
|
||||
@@ -562,9 +586,6 @@ exports.up = knex => Promise.resolve()
|
||||
`));
|
||||
|
||||
exports.down = knex => knex.raw(`
|
||||
DROP FUNCTION IF EXISTS releases_by_tag_slugs;
|
||||
DROP FUNCTION IF EXISTS search_sites;
|
||||
|
||||
DROP VIEW IF EXISTS movie_actors;
|
||||
DROP VIEW IF EXISTS movie_tags;
|
||||
|
||||
@@ -595,10 +616,15 @@ exports.down = knex => knex.raw(`
|
||||
DROP TABLE IF EXISTS social CASCADE;
|
||||
DROP TABLE IF EXISTS sites CASCADE;
|
||||
DROP TABLE IF EXISTS studios CASCADE;
|
||||
DROP TABLE IF EXISTS media_sfw CASCADE;
|
||||
DROP TABLE IF EXISTS media CASCADE;
|
||||
DROP TABLE IF EXISTS countries CASCADE;
|
||||
DROP TABLE IF EXISTS networks CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS releases_by_tag_slugs;
|
||||
DROP FUNCTION IF EXISTS search_sites;
|
||||
DROP FUNCTION IF EXISTS get_random_sfw_media_id;
|
||||
|
||||
DROP TEXT SEARCH CONFIGURATION IF EXISTS traxxx;
|
||||
DROP TEXT SEARCH DICTIONARY IF EXISTS traxxx_dict;
|
||||
`);
|
||||
|
||||
Reference in New Issue
Block a user