forked from DebaucheryLibrarian/traxxx
Improved SFW and tag media seed file to allow updates.
This commit is contained in:
@@ -45,26 +45,21 @@ exports.up = knex => Promise.resolve()
|
||||
table.text('comment');
|
||||
table.text('group');
|
||||
|
||||
table.boolean('is_sfw')
|
||||
.defaultTo(false);
|
||||
|
||||
table.unique('hash');
|
||||
table.unique('source');
|
||||
|
||||
table.datetime('created_at')
|
||||
.defaultTo(knex.fn.now());
|
||||
}))
|
||||
.then(() => knex.schema.createTable('media_sfw', (table) => {
|
||||
table.text('id', 21)
|
||||
.primary();
|
||||
|
||||
table.text('media_id', 21)
|
||||
.references('id')
|
||||
.inTable('media')
|
||||
.unique();
|
||||
}))
|
||||
.then(() => { // eslint-disable-line arrow-body-style
|
||||
// allow vim fold
|
||||
return knex.raw(`
|
||||
CREATE FUNCTION get_random_sfw_media_id() RETURNS varchar AS $$
|
||||
SELECT media_id FROM media_sfw
|
||||
SELECT id FROM media
|
||||
WHERE is_sfw = true
|
||||
ORDER BY random()
|
||||
LIMIT 1;
|
||||
$$ LANGUAGE sql STABLE;
|
||||
|
||||
Reference in New Issue
Block a user