2021-03-14 03:54:43 +00:00
|
|
|
const config = require('config');
|
|
|
|
|
2022-01-19 23:54:10 +00:00
|
|
|
exports.up = (knex) => Promise.resolve()
|
2020-05-14 02:26:05 +00:00
|
|
|
.then(() => knex.schema.createTable('countries', (table) => {
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('alpha2', 2)
|
2020-05-14 02:26:05 +00:00
|
|
|
.unique()
|
|
|
|
.primary();
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('alpha3', 3)
|
2020-05-14 02:26:05 +00:00
|
|
|
.unique();
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('name')
|
2020-05-14 02:26:05 +00:00
|
|
|
.notNullable();
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('alias');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
|
|
|
table.integer('code', 3);
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('nationality');
|
2020-05-18 23:10:32 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
table.integer('priority', 2)
|
|
|
|
.defaultTo(0);
|
|
|
|
}))
|
2021-03-07 03:05:25 +00:00
|
|
|
.then(() => knex.schema.createTable('entities_types', (table) => {
|
|
|
|
table.text('type')
|
|
|
|
.primary();
|
|
|
|
}))
|
|
|
|
.then(() => { // eslint-disable-line arrow-body-style
|
|
|
|
// allow vim fold
|
|
|
|
return knex('entities_types').insert([
|
|
|
|
{ type: 'network' },
|
|
|
|
{ type: 'channel' },
|
|
|
|
{ type: 'studio' },
|
|
|
|
{ type: 'info' },
|
|
|
|
]);
|
|
|
|
})
|
|
|
|
.then(() => knex.schema.createTable('entities', (table) => {
|
|
|
|
table.increments('id', 12);
|
|
|
|
|
|
|
|
table.integer('parent_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('entities')
|
|
|
|
.index();
|
|
|
|
|
|
|
|
table.text('name');
|
|
|
|
table.text('slug', 32);
|
|
|
|
|
|
|
|
table.text('type')
|
|
|
|
.notNullable()
|
|
|
|
.references('type')
|
|
|
|
.inTable('entities_types')
|
|
|
|
.defaultTo('channel');
|
|
|
|
|
|
|
|
table.unique(['slug', 'type']);
|
|
|
|
|
|
|
|
table.specificType('alias', 'text[]');
|
|
|
|
|
|
|
|
table.text('url');
|
|
|
|
table.text('description');
|
|
|
|
table.json('parameters');
|
|
|
|
|
|
|
|
table.integer('priority', 3)
|
|
|
|
.defaultTo(0);
|
|
|
|
|
|
|
|
table.boolean('independent')
|
|
|
|
.defaultTo(false);
|
|
|
|
|
|
|
|
table.boolean('visible')
|
|
|
|
.defaultTo(true);
|
|
|
|
|
|
|
|
table.boolean('has_logo')
|
|
|
|
.defaultTo(true);
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
2020-05-14 02:26:05 +00:00
|
|
|
.then(() => knex.schema.createTable('media', (table) => {
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('id', 21)
|
2020-05-14 02:26:05 +00:00
|
|
|
.primary();
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('path');
|
|
|
|
table.text('thumbnail');
|
|
|
|
table.text('lazy');
|
2020-05-14 02:26:05 +00:00
|
|
|
table.integer('index');
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('mime');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2021-02-22 01:33:39 +00:00
|
|
|
table.boolean('is_s3')
|
|
|
|
.defaultTo(false);
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('hash');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2021-01-01 03:28:10 +00:00
|
|
|
table.bigInteger('size', 12);
|
2020-05-14 02:26:05 +00:00
|
|
|
table.integer('quality', 6);
|
|
|
|
table.integer('width', 6);
|
|
|
|
table.integer('height', 6);
|
2021-02-04 02:06:19 +00:00
|
|
|
table.boolean('is_vr');
|
2020-05-14 02:26:05 +00:00
|
|
|
table.float('entropy');
|
2020-12-20 03:21:28 +00:00
|
|
|
table.float('sharpness');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2021-03-07 03:05:25 +00:00
|
|
|
table.text('source', 2100);
|
|
|
|
table.text('source_page', 2100);
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('scraper', 32);
|
2020-07-15 01:24:47 +00:00
|
|
|
table.text('credit', 100);
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2021-03-07 03:05:25 +00:00
|
|
|
table.integer('entity_id')
|
|
|
|
.references('id')
|
2021-03-07 04:11:27 +00:00
|
|
|
.inTable('entities')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2021-03-13 03:26:24 +00:00
|
|
|
table.date('date');
|
2021-08-09 08:31:12 +00:00
|
|
|
table.enum('date_precision', ['year', 'month', 'week', 'day', 'hour', 'minute', 'second'])
|
2021-03-13 03:26:24 +00:00
|
|
|
.defaultTo('year');
|
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
table.text('comment');
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('group');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-09-05 00:57:24 +00:00
|
|
|
table.boolean('is_sfw')
|
|
|
|
.defaultTo(false);
|
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
table.unique('hash');
|
|
|
|
table.unique('source');
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
2020-05-16 02:36:45 +00:00
|
|
|
.then(() => { // eslint-disable-line arrow-body-style
|
|
|
|
// allow vim fold
|
|
|
|
return knex.raw(`
|
|
|
|
CREATE FUNCTION get_random_sfw_media_id() RETURNS varchar AS $$
|
2020-09-05 00:57:24 +00:00
|
|
|
SELECT id FROM media
|
|
|
|
WHERE is_sfw = true
|
2020-05-16 02:36:45 +00:00
|
|
|
ORDER BY random()
|
|
|
|
LIMIT 1;
|
|
|
|
$$ LANGUAGE sql STABLE;
|
|
|
|
`);
|
|
|
|
})
|
2020-05-14 02:26:05 +00:00
|
|
|
.then(() => knex.schema.alterTable('media', (table) => {
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('sfw_media_id', 21)
|
2020-05-14 02:26:05 +00:00
|
|
|
.references('id')
|
|
|
|
.inTable('media')
|
|
|
|
.defaultTo(knex.raw('get_random_sfw_media_id()'));
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('tags_groups', (table) => {
|
|
|
|
table.increments('id', 12);
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('name', 32);
|
2020-05-14 02:26:05 +00:00
|
|
|
table.text('description');
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('slug', 32)
|
2020-05-14 02:26:05 +00:00
|
|
|
.unique();
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('tags', (table) => {
|
|
|
|
table.increments('id', 12);
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('name');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
|
|
|
table.text('description');
|
|
|
|
|
|
|
|
table.integer('priority', 2)
|
|
|
|
.defaultTo(0);
|
|
|
|
|
2020-06-29 23:52:17 +00:00
|
|
|
table.boolean('filter')
|
|
|
|
.defaultTo(false);
|
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
table.boolean('secondary')
|
|
|
|
.defaultTo(false);
|
|
|
|
|
|
|
|
table.integer('group_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('tags_groups');
|
|
|
|
|
|
|
|
table.integer('alias_for', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('tags');
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('slug', 32)
|
2020-05-14 02:26:05 +00:00
|
|
|
.unique();
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('tags_posters', (table) => {
|
|
|
|
table.integer('tag_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('tags');
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('media_id', 21)
|
2020-05-14 02:26:05 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
|
|
|
table.unique('tag_id');
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('tags_photos', (table) => {
|
|
|
|
table.integer('tag_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('tags');
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('media_id', 21)
|
2020-05-14 02:26:05 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
|
|
|
table.unique(['tag_id', 'media_id']);
|
|
|
|
}))
|
2020-06-03 23:03:02 +00:00
|
|
|
.then(() => knex.schema.createTable('entities_tags', (table) => {
|
|
|
|
table.integer('tag_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('tags');
|
|
|
|
|
|
|
|
table.integer('entity_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('entities');
|
|
|
|
|
|
|
|
table.boolean('inherit')
|
|
|
|
.defaultTo(false);
|
|
|
|
|
|
|
|
table.unique(['tag_id', 'entity_id']);
|
|
|
|
}))
|
2020-06-27 00:57:30 +00:00
|
|
|
.then(() => knex.schema.createTable('entities_social', (table) => {
|
2020-05-14 02:26:05 +00:00
|
|
|
table.increments('id', 16);
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('url');
|
|
|
|
table.text('platform');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-06-27 00:57:30 +00:00
|
|
|
table.integer('entity_id', 12)
|
2020-05-14 02:26:05 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-06-27 00:57:30 +00:00
|
|
|
.inTable('entities');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-06-27 00:57:30 +00:00
|
|
|
table.unique(['url', 'entity_id']);
|
2020-05-14 02:26:05 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('batches', (table) => {
|
|
|
|
table.increments('id', 12);
|
|
|
|
table.text('comment');
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('actors', (table) => {
|
|
|
|
table.increments('id', 12);
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('name')
|
2020-05-14 02:26:05 +00:00
|
|
|
.notNullable();
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('slug', 32)
|
2020-05-18 02:28:38 +00:00
|
|
|
.notNullable();
|
|
|
|
|
2020-06-17 02:07:24 +00:00
|
|
|
table.integer('entity_id', 12)
|
2020-05-14 02:26:05 +00:00
|
|
|
.references('id')
|
2020-06-17 02:07:24 +00:00
|
|
|
.inTable('entities');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-07-18 03:12:32 +00:00
|
|
|
table.text('entry_id');
|
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
table.integer('alias_for', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('actors');
|
|
|
|
|
2020-12-30 01:23:43 +00:00
|
|
|
table.text('real_name');
|
|
|
|
|
2020-05-15 02:40:59 +00:00
|
|
|
table.date('date_of_birth');
|
|
|
|
table.date('date_of_death');
|
2020-11-29 02:59:47 +00:00
|
|
|
table.integer('age', 3);
|
2020-05-15 02:40:59 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('gender', 18);
|
2020-05-14 02:26:05 +00:00
|
|
|
table.text('description');
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('birth_city');
|
|
|
|
table.text('birth_state');
|
|
|
|
table.text('birth_country_alpha2', 2)
|
2020-05-14 02:26:05 +00:00
|
|
|
.references('alpha2')
|
|
|
|
.inTable('countries');
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('residence_city');
|
|
|
|
table.text('residence_state');
|
|
|
|
table.text('residence_country_alpha2', 2)
|
2020-05-14 02:26:05 +00:00
|
|
|
.references('alpha2')
|
|
|
|
.inTable('countries');
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('ethnicity');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('cup', 4);
|
2020-05-15 02:40:59 +00:00
|
|
|
table.integer('bust', 3);
|
2020-05-14 02:26:05 +00:00
|
|
|
table.integer('waist', 3);
|
|
|
|
table.integer('hip', 3);
|
|
|
|
table.boolean('natural_boobs');
|
|
|
|
|
2020-07-15 01:24:47 +00:00
|
|
|
table.integer('penis_length', 3);
|
|
|
|
table.integer('penis_girth', 3);
|
2020-11-15 03:33:24 +00:00
|
|
|
table.boolean('circumcised');
|
2020-07-15 01:24:47 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
table.integer('height', 3);
|
|
|
|
table.integer('weight', 3);
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('eyes');
|
|
|
|
table.text('hair_color');
|
|
|
|
table.text('hair_length');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
|
|
|
table.boolean('has_tattoos');
|
|
|
|
table.boolean('has_piercings');
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('piercings');
|
|
|
|
table.text('tattoos');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('avatar_media_id', 21)
|
2020-05-17 01:00:44 +00:00
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
table.integer('batch_id', 12)
|
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('batches')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
|
|
|
table.datetime('updated_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('actors_profiles', (table) => {
|
|
|
|
table.increments('id', 12);
|
|
|
|
|
|
|
|
table.integer('actor_id', 12)
|
2020-05-16 02:36:45 +00:00
|
|
|
.notNullable()
|
2020-05-14 02:26:05 +00:00
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('actors')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-06-17 02:07:24 +00:00
|
|
|
table.integer('entity_id', 12)
|
2020-05-14 02:26:05 +00:00
|
|
|
.references('id')
|
2020-06-17 02:07:24 +00:00
|
|
|
.inTable('entities');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-06-17 02:07:24 +00:00
|
|
|
table.unique(['actor_id', 'entity_id']);
|
2020-05-18 23:10:32 +00:00
|
|
|
table.integer('priority', 4)
|
|
|
|
.defaultTo(1);
|
2020-05-15 02:40:59 +00:00
|
|
|
|
2020-08-31 00:43:41 +00:00
|
|
|
table.text('url');
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('real_name');
|
|
|
|
table.text('gender', 18);
|
2020-05-18 02:28:38 +00:00
|
|
|
|
2020-05-15 02:40:59 +00:00
|
|
|
table.date('date_of_birth');
|
|
|
|
table.date('date_of_death');
|
2020-11-29 02:59:47 +00:00
|
|
|
table.integer('age', 3);
|
2020-05-14 02:26:05 +00:00
|
|
|
|
|
|
|
table.text('description');
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('description_hash');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('birth_city');
|
|
|
|
table.text('birth_state');
|
|
|
|
table.text('birth_country_alpha2', 2)
|
2020-05-14 02:26:05 +00:00
|
|
|
.references('alpha2')
|
|
|
|
.inTable('countries');
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('residence_city');
|
|
|
|
table.text('residence_state');
|
|
|
|
table.text('residence_country_alpha2', 2)
|
2020-05-14 02:26:05 +00:00
|
|
|
.references('alpha2')
|
|
|
|
.inTable('countries');
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('ethnicity');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('cup', 4);
|
2020-05-15 02:40:59 +00:00
|
|
|
table.integer('bust', 3);
|
2020-05-14 02:26:05 +00:00
|
|
|
table.integer('waist', 3);
|
|
|
|
table.integer('hip', 3);
|
|
|
|
table.boolean('natural_boobs');
|
|
|
|
|
2020-07-15 01:24:47 +00:00
|
|
|
table.integer('penis_length', 3);
|
|
|
|
table.integer('penis_girth', 3);
|
2020-11-15 03:33:24 +00:00
|
|
|
table.boolean('circumcised');
|
2020-07-15 01:24:47 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
table.integer('height', 3);
|
|
|
|
table.integer('weight', 3);
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('eyes');
|
|
|
|
table.text('hair_color');
|
|
|
|
table.text('hair_length');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
|
|
|
table.boolean('has_tattoos');
|
|
|
|
table.boolean('has_piercings');
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('piercings');
|
|
|
|
table.text('tattoos');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('avatar_media_id', 21)
|
2020-05-16 02:36:45 +00:00
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
table.datetime('scraped_at');
|
|
|
|
table.boolean('scrape_success');
|
|
|
|
|
|
|
|
table.datetime('updated_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('body', (table) => {
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('slug', 20)
|
2020-05-14 02:26:05 +00:00
|
|
|
.primary();
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('name');
|
2020-05-14 02:26:05 +00:00
|
|
|
}))
|
2020-05-16 02:36:45 +00:00
|
|
|
.then(() => { // eslint-disable-line arrow-body-style
|
|
|
|
// allow vim fold
|
|
|
|
return knex('body').insert([
|
|
|
|
// head
|
|
|
|
{ slug: 'head', name: 'head' },
|
|
|
|
{ slug: 'face', name: 'face' },
|
|
|
|
{ slug: 'scalp', name: 'scalp' },
|
|
|
|
{ slug: 'forehead', name: 'forehead' },
|
|
|
|
{ slug: 'temple', name: 'temple' },
|
|
|
|
{ slug: 'cheek', name: 'cheek' },
|
|
|
|
{ slug: 'jaw', name: 'jaw' },
|
|
|
|
{ slug: 'chin', name: 'chin' },
|
|
|
|
{ slug: 'neck', name: 'neck' },
|
|
|
|
{ slug: 'throat', name: 'throat' },
|
|
|
|
// eyes
|
|
|
|
{ slug: 'eyelid', name: 'eyelid' },
|
|
|
|
{ slug: 'eyeball', name: 'eyeball' },
|
|
|
|
{ slug: 'eyebrow', name: 'eyebrow' },
|
|
|
|
// mouth
|
|
|
|
{ slug: 'tongue', name: 'tongue' },
|
|
|
|
{ slug: 'lip', name: 'lip' },
|
|
|
|
{ slug: 'upper-lip', name: 'upper lip' },
|
|
|
|
{ slug: 'lower-lip', name: 'lower lip' },
|
|
|
|
{ slug: 'inner-lip', name: 'inner lip' },
|
|
|
|
{ slug: 'inner-lower-lip', name: 'inner lower lip' },
|
|
|
|
{ slug: 'inner-upper-lip', name: 'inner upper lip' },
|
|
|
|
{ slug: 'philtrum', name: 'philtrum' },
|
|
|
|
{ slug: 'above-lip', name: 'above lip' },
|
|
|
|
{ slug: 'below-lip', name: 'below lip' },
|
|
|
|
// nose
|
|
|
|
{ slug: 'nose', name: 'nose' },
|
|
|
|
{ slug: 'third-eye', name: 'third eye' },
|
|
|
|
{ slug: 'bridge', name: 'bridge' },
|
|
|
|
{ slug: 'nostril', name: 'nostril' },
|
|
|
|
{ slug: 'septum', name: 'septum' },
|
|
|
|
{ slug: 'septril', name: 'septril' },
|
|
|
|
// ear
|
|
|
|
{ slug: 'ear', name: 'ear' },
|
|
|
|
{ slug: 'earlobe', name: 'earlobe' },
|
|
|
|
{ slug: 'helix', name: 'helix' },
|
|
|
|
{ slug: 'tragus', name: 'tragus' },
|
|
|
|
{ slug: 'conch', name: 'conch' },
|
|
|
|
{ slug: 'rook', name: 'rook' },
|
|
|
|
{ slug: 'behind-ear', name: 'behind ear' },
|
|
|
|
// arms
|
|
|
|
{ slug: 'arm', name: 'arm' },
|
|
|
|
{ slug: 'upper-arm', name: 'upper arm' },
|
|
|
|
{ slug: 'forearm', name: 'forearm' },
|
|
|
|
{ slug: 'elbow', name: 'elbow' },
|
|
|
|
{ slug: 'inner-elbow', name: 'inner elbow' },
|
|
|
|
{ slug: 'outer-elbow', name: 'outer elbow' },
|
|
|
|
// hands
|
|
|
|
{ slug: 'hand', name: 'hand' },
|
|
|
|
{ slug: 'fingers', name: 'fingers' },
|
|
|
|
{ slug: 'knuckles', name: 'knuckles' },
|
|
|
|
{ slug: 'thumb', name: 'thumb' },
|
|
|
|
{ slug: 'index-finger', name: 'index finger' },
|
|
|
|
{ slug: 'middle-finger', name: 'middle finger' },
|
|
|
|
{ slug: 'ring-finger', name: 'ring finger' },
|
|
|
|
{ slug: 'pinky', name: 'pinky' },
|
|
|
|
{ slug: 'back-of-hand', name: 'back of hand' },
|
|
|
|
{ slug: 'inner-wrist', name: 'inner wrist' },
|
|
|
|
{ slug: 'outer-wrist', name: 'outer wrist' },
|
|
|
|
// torso
|
|
|
|
{ slug: 'shoulder', name: 'shoulder' },
|
|
|
|
{ slug: 'collarbone', name: 'collarbone' },
|
|
|
|
{ slug: 'chest', name: 'chest' },
|
|
|
|
{ slug: 'rib-cage', name: 'rib cage' },
|
|
|
|
{ slug: 'breastbone', name: 'breastbone' },
|
|
|
|
{ slug: 'underboob', name: 'underboob' },
|
|
|
|
{ slug: 'sideboob', name: 'sideboob' },
|
|
|
|
{ slug: 'boob', name: 'boob' },
|
|
|
|
{ slug: 'nipple', name: 'nipple' },
|
|
|
|
{ slug: 'abdomen', name: 'abdomen' },
|
|
|
|
{ slug: 'navel', name: 'navel' },
|
|
|
|
{ slug: 'pelvis', name: 'pelvis' },
|
|
|
|
// back
|
|
|
|
{ slug: 'back', name: 'back' },
|
|
|
|
{ slug: 'upper-back', name: 'upper back' },
|
|
|
|
{ slug: 'middle-back', name: 'lower back' },
|
|
|
|
{ slug: 'lower-back', name: 'lower back' },
|
|
|
|
{ slug: 'spine', name: 'spine' },
|
|
|
|
// bottom
|
|
|
|
{ slug: 'butt', name: 'butt' },
|
|
|
|
{ slug: 'hip', name: 'hip' },
|
|
|
|
{ slug: 'anus', name: 'anus' },
|
|
|
|
// genitals
|
|
|
|
{ slug: 'pubic-mound', name: 'pubic mound' },
|
|
|
|
{ slug: 'vagina', name: 'vagina' },
|
|
|
|
{ slug: 'outer-labia', name: 'outer labia' },
|
|
|
|
{ slug: 'inner-labia', name: 'inner labia' },
|
|
|
|
{ slug: 'clitoris', name: 'clitoris' },
|
|
|
|
{ slug: 'penis', name: 'penis' },
|
|
|
|
{ slug: 'glans', name: 'glans' },
|
|
|
|
{ slug: 'foreskin', name: 'foreskin' },
|
|
|
|
{ slug: 'shaft', name: 'shaft' },
|
|
|
|
{ slug: 'scrotum', name: 'scrotum' },
|
|
|
|
// legs
|
|
|
|
{ slug: 'leg', name: 'leg' },
|
|
|
|
{ slug: 'groin', name: 'groin' },
|
|
|
|
{ slug: 'upper-leg', name: 'upper leg' },
|
|
|
|
{ slug: 'thigh', name: 'thigh' },
|
|
|
|
{ slug: 'lower-leg', name: 'lower leg' },
|
|
|
|
{ slug: 'shin', name: 'shin' },
|
|
|
|
{ slug: 'calf', name: 'calf' },
|
|
|
|
{ slug: 'knee', name: 'knee' },
|
|
|
|
{ slug: 'inner-knee', name: 'inner knee' },
|
|
|
|
// feet
|
|
|
|
{ slug: 'inner-ankle', name: 'inner ankle' },
|
|
|
|
{ slug: 'outer-ankle', name: 'outer ankle' },
|
|
|
|
{ slug: 'foot', name: 'foot' },
|
|
|
|
{ slug: 'toes', name: 'toes' },
|
|
|
|
{ slug: 'big-toe', name: 'big toe' },
|
|
|
|
{ slug: 'index-toe', name: 'index toe' },
|
|
|
|
{ slug: 'middle-toe', name: 'middle toe' },
|
|
|
|
{ slug: 'fourth-toe', name: 'fourth toe' },
|
|
|
|
{ slug: 'little-toe', name: 'little toe' },
|
|
|
|
]);
|
|
|
|
})
|
2020-05-14 02:26:05 +00:00
|
|
|
.then(() => knex.schema.createTable('actors_tattoos', (table) => {
|
|
|
|
table.increments('id');
|
|
|
|
|
|
|
|
table.integer('actor_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('actors')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('body_slug', 20)
|
2020-05-14 02:26:05 +00:00
|
|
|
.references('slug')
|
|
|
|
.inTable('body');
|
|
|
|
|
|
|
|
table.enum('side', ['left', 'right', 'center', 'both']);
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('description');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('actors_piercings', (table) => {
|
|
|
|
table.increments('id');
|
|
|
|
|
|
|
|
table.integer('actor_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('actors')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('body_slug', 20)
|
2020-05-14 02:26:05 +00:00
|
|
|
.references('slug')
|
|
|
|
.inTable('body');
|
|
|
|
|
|
|
|
table.enum('side', ['left', 'right', 'center', 'both']);
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('description');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('actors_avatars', (table) => {
|
|
|
|
table.integer('profile_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('actors_profiles')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('media_id', 21)
|
2020-05-14 02:26:05 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
|
|
|
table.unique('profile_id');
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('actors_photos', (table) => {
|
|
|
|
table.integer('actor_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('actors')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('media_id', 21)
|
2020-05-14 02:26:05 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
|
|
|
table.unique(['actor_id', 'media_id']);
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('actors_social', (table) => {
|
|
|
|
table.increments('id', 16);
|
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('url');
|
|
|
|
table.text('platform');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
|
|
|
table.integer('actor_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('actors');
|
|
|
|
|
|
|
|
table.unique(['url', 'actor_id']);
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
2020-07-25 01:44:19 +00:00
|
|
|
.then(() => knex.schema.createTable('releases', (table) => {
|
|
|
|
table.increments('id', 16);
|
|
|
|
|
|
|
|
table.integer('entity_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('entities')
|
|
|
|
.notNullable();
|
|
|
|
|
|
|
|
table.integer('studio_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('entities');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('shoot_id');
|
|
|
|
table.text('entry_id');
|
2020-08-20 02:57:38 +00:00
|
|
|
|
2020-07-25 01:44:19 +00:00
|
|
|
table.unique(['entity_id', 'entry_id']);
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('url', 1000);
|
|
|
|
table.text('title');
|
|
|
|
table.text('slug');
|
2020-05-22 02:32:16 +00:00
|
|
|
|
2020-07-16 01:47:07 +00:00
|
|
|
table.timestamp('date');
|
2020-05-22 02:32:16 +00:00
|
|
|
table.index('date');
|
|
|
|
|
2020-07-16 01:47:07 +00:00
|
|
|
table.date('production_date');
|
|
|
|
|
2020-08-20 02:57:38 +00:00
|
|
|
table.text('production_location');
|
|
|
|
table.text('production_city');
|
|
|
|
table.text('production_state');
|
|
|
|
table.text('production_country_alpha2', 2)
|
|
|
|
.references('alpha2')
|
|
|
|
.inTable('countries');
|
|
|
|
|
2021-08-09 08:31:12 +00:00
|
|
|
table.enum('date_precision', ['year', 'month', 'week', 'day', 'hour', 'minute', 'second'])
|
2020-07-03 02:12:56 +00:00
|
|
|
.defaultTo('day');
|
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
table.text('description');
|
|
|
|
|
|
|
|
table.integer('duration')
|
|
|
|
.unsigned();
|
|
|
|
|
|
|
|
table.boolean('deep');
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('deep_url', 1000);
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-07-08 00:53:46 +00:00
|
|
|
table.text('comment');
|
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
table.integer('created_batch_id', 12)
|
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('batches')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
|
|
|
table.integer('updated_batch_id', 12)
|
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('batches')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
2021-06-02 01:27:32 +00:00
|
|
|
.notNullable()
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
|
|
|
|
table.datetime('updated_at')
|
|
|
|
.notNullable()
|
2020-05-14 02:26:05 +00:00
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('releases_actors', (table) => {
|
|
|
|
table.integer('release_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-10-19 00:02:21 +00:00
|
|
|
.inTable('releases')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
|
|
|
table.integer('actor_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('actors')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2021-02-16 23:40:20 +00:00
|
|
|
table.integer('alias_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('actors')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
table.unique(['release_id', 'actor_id']);
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('releases_directors', (table) => {
|
|
|
|
table.integer('release_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-10-19 00:02:21 +00:00
|
|
|
.inTable('releases')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2021-03-06 23:01:02 +00:00
|
|
|
table.integer('director_id', 12)
|
2020-05-14 02:26:05 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2021-03-06 23:01:02 +00:00
|
|
|
.inTable('actors')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
|
|
|
table.integer('alias_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('actors')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
|
|
|
table.unique(['release_id', 'director_id']);
|
2021-03-06 23:01:02 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
2020-05-14 02:26:05 +00:00
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('releases_posters', (table) => {
|
|
|
|
table.integer('release_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-10-19 00:02:21 +00:00
|
|
|
.inTable('releases')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('media_id', 21)
|
2020-05-14 02:26:05 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
|
|
|
table.unique('release_id');
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('releases_covers', (table) => {
|
|
|
|
table.integer('release_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-10-19 00:02:21 +00:00
|
|
|
.inTable('releases')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('media_id', 21)
|
2020-05-14 02:26:05 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
|
|
|
table.unique(['release_id', 'media_id']);
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('releases_trailers', (table) => {
|
|
|
|
table.integer('release_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-10-19 00:02:21 +00:00
|
|
|
.inTable('releases')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('media_id', 21)
|
2020-05-14 02:26:05 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
|
|
|
table.unique('release_id');
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('releases_teasers', (table) => {
|
|
|
|
table.integer('release_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-10-19 00:02:21 +00:00
|
|
|
.inTable('releases')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('media_id', 21)
|
2020-05-14 02:26:05 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
|
|
|
table.unique('release_id');
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('releases_photos', (table) => {
|
|
|
|
table.integer('release_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-10-19 00:02:21 +00:00
|
|
|
.inTable('releases')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-24 01:54:29 +00:00
|
|
|
table.text('media_id', 21)
|
2020-05-14 02:26:05 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
|
|
|
table.unique(['release_id', 'media_id']);
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('releases_tags', (table) => {
|
|
|
|
table.integer('tag_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('tags');
|
|
|
|
|
|
|
|
table.integer('release_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-10-19 00:02:21 +00:00
|
|
|
.inTable('releases')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2021-10-09 22:04:21 +00:00
|
|
|
table.text('original_tag');
|
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
table.unique(['tag_id', 'release_id']);
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('releases_search', (table) => {
|
|
|
|
table.integer('release_id', 16)
|
|
|
|
.references('id')
|
2020-10-19 00:02:21 +00:00
|
|
|
.inTable('releases')
|
|
|
|
.onDelete('cascade');
|
2020-05-14 02:26:05 +00:00
|
|
|
}))
|
2020-08-08 16:10:59 +00:00
|
|
|
.then(() => knex.schema.createTable('movies', (table) => {
|
|
|
|
table.increments('id', 16);
|
|
|
|
|
|
|
|
table.integer('entity_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('entities')
|
|
|
|
.notNullable();
|
|
|
|
|
|
|
|
table.integer('studio_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('entities');
|
|
|
|
|
|
|
|
table.text('entry_id');
|
|
|
|
table.unique(['entity_id', 'entry_id']);
|
|
|
|
|
|
|
|
table.text('url', 1000);
|
|
|
|
table.text('title');
|
|
|
|
table.text('slug');
|
|
|
|
|
|
|
|
table.timestamp('date');
|
|
|
|
table.index('date');
|
|
|
|
|
2021-08-09 08:31:12 +00:00
|
|
|
table.enum('date_precision', ['year', 'month', 'week', 'day', 'hour', 'minute', 'second'])
|
2020-08-08 16:10:59 +00:00
|
|
|
.defaultTo('day');
|
|
|
|
|
|
|
|
table.text('description');
|
|
|
|
|
|
|
|
table.boolean('deep');
|
|
|
|
table.text('deep_url', 1000);
|
|
|
|
|
|
|
|
table.text('comment');
|
|
|
|
|
|
|
|
table.integer('created_batch_id', 12)
|
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('batches')
|
|
|
|
.onDelete('cascade');
|
2020-08-08 16:10:59 +00:00
|
|
|
|
|
|
|
table.integer('updated_batch_id', 12)
|
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('batches')
|
|
|
|
.onDelete('cascade');
|
2020-08-08 16:10:59 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('movies_scenes', (table) => {
|
|
|
|
table.integer('movie_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-11-19 01:01:13 +00:00
|
|
|
.inTable('movies')
|
|
|
|
.onDelete('cascade');
|
2020-08-08 16:10:59 +00:00
|
|
|
|
|
|
|
table.integer('scene_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-11-19 01:01:13 +00:00
|
|
|
.inTable('releases')
|
|
|
|
.onDelete('cascade');
|
2020-08-08 16:10:59 +00:00
|
|
|
|
|
|
|
table.unique(['movie_id', 'scene_id']);
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('movies_covers', (table) => {
|
2020-08-20 02:57:38 +00:00
|
|
|
table.integer('movie_id', 16)
|
2020-08-08 16:10:59 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('movies')
|
|
|
|
.onDelete('cascade');
|
2020-08-08 16:10:59 +00:00
|
|
|
|
|
|
|
table.text('media_id', 21)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
2020-08-20 02:57:38 +00:00
|
|
|
table.unique(['movie_id', 'media_id']);
|
2020-08-08 16:10:59 +00:00
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('movies_trailers', (table) => {
|
2020-08-20 02:57:38 +00:00
|
|
|
table.integer('movie_id', 16)
|
2020-08-08 16:10:59 +00:00
|
|
|
.unique()
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('movies')
|
|
|
|
.onDelete('cascade');
|
2020-08-08 16:10:59 +00:00
|
|
|
|
|
|
|
table.text('media_id', 21)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
}))
|
2020-11-19 01:01:13 +00:00
|
|
|
.then(() => knex.schema.createTable('movies_posters', (table) => {
|
|
|
|
table.integer('movie_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('movies')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
|
|
|
table.text('media_id', 21)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2021-06-04 01:10:41 +00:00
|
|
|
.inTable('media')
|
|
|
|
.onDelete('cascade');
|
2020-11-19 01:01:13 +00:00
|
|
|
|
2021-02-23 00:30:38 +00:00
|
|
|
table.unique('movie_id');
|
2020-11-19 01:01:13 +00:00
|
|
|
}))
|
2021-08-22 20:25:20 +00:00
|
|
|
.then(() => knex.schema.createTable('movies_search', (table) => {
|
|
|
|
table.integer('movie_id', 16)
|
|
|
|
.references('id')
|
|
|
|
.inTable('movies')
|
|
|
|
.onDelete('cascade');
|
|
|
|
}))
|
2021-02-26 23:37:22 +00:00
|
|
|
.then(() => knex.schema.createTable('chapters', (table) => {
|
2020-08-20 02:57:38 +00:00
|
|
|
table.increments('id', 16);
|
|
|
|
|
|
|
|
table.integer('release_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases')
|
2020-10-24 22:52:40 +00:00
|
|
|
.notNullable()
|
|
|
|
.onDelete('cascade');
|
2020-08-20 02:57:38 +00:00
|
|
|
|
2021-02-26 23:37:22 +00:00
|
|
|
table.integer('index');
|
|
|
|
table.unique(['release_id', 'index']);
|
2020-08-20 02:57:38 +00:00
|
|
|
|
2021-02-26 23:37:22 +00:00
|
|
|
table.integer('time')
|
|
|
|
.unsigned();
|
2020-08-20 02:57:38 +00:00
|
|
|
|
|
|
|
table.integer('duration')
|
|
|
|
.unsigned();
|
|
|
|
|
2021-02-26 23:37:22 +00:00
|
|
|
table.text('title');
|
|
|
|
table.text('description');
|
|
|
|
|
2020-08-20 02:57:38 +00:00
|
|
|
table.integer('created_batch_id', 12)
|
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('batches')
|
|
|
|
.onDelete('cascade');
|
2020-08-20 02:57:38 +00:00
|
|
|
|
|
|
|
table.integer('updated_batch_id', 12)
|
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('batches')
|
|
|
|
.onDelete('cascade');
|
2020-08-20 02:57:38 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
2021-02-26 23:37:22 +00:00
|
|
|
.then(() => knex.schema.createTable('chapters_posters', (table) => {
|
|
|
|
table.integer('chapter_id', 16)
|
2020-08-20 02:57:38 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2021-02-26 23:37:22 +00:00
|
|
|
.inTable('chapters')
|
2020-10-24 22:52:40 +00:00
|
|
|
.onDelete('cascade');
|
2020-08-20 02:57:38 +00:00
|
|
|
|
|
|
|
table.text('media_id', 21)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
2021-02-26 23:37:22 +00:00
|
|
|
table.unique('chapter_id');
|
2020-08-20 02:57:38 +00:00
|
|
|
}))
|
2021-02-26 23:37:22 +00:00
|
|
|
.then(() => knex.schema.createTable('chapters_photos', (table) => {
|
|
|
|
table.integer('chapter_id', 16)
|
2020-08-20 02:57:38 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2021-02-26 23:37:22 +00:00
|
|
|
.inTable('chapters')
|
2020-10-24 22:52:40 +00:00
|
|
|
.onDelete('cascade');
|
2020-08-20 02:57:38 +00:00
|
|
|
|
|
|
|
table.text('media_id', 21)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
2021-02-26 23:37:22 +00:00
|
|
|
table.unique(['chapter_id', 'media_id']);
|
2020-08-20 02:57:38 +00:00
|
|
|
}))
|
2021-02-26 23:37:22 +00:00
|
|
|
.then(() => knex.schema.createTable('chapters_tags', (table) => {
|
2020-08-20 02:57:38 +00:00
|
|
|
table.integer('tag_id', 12)
|
|
|
|
.references('id')
|
2020-10-24 22:52:40 +00:00
|
|
|
.inTable('tags')
|
|
|
|
.onDelete('cascade');
|
2020-08-20 02:57:38 +00:00
|
|
|
|
2021-02-26 23:37:22 +00:00
|
|
|
table.integer('chapter_id', 16)
|
2020-08-20 02:57:38 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2021-02-26 23:37:22 +00:00
|
|
|
.inTable('chapters')
|
|
|
|
.onDelete('cascade');
|
2020-08-20 02:57:38 +00:00
|
|
|
|
2021-10-16 22:28:13 +00:00
|
|
|
table.text('original_tag');
|
|
|
|
|
2021-02-26 23:37:22 +00:00
|
|
|
table.unique(['tag_id', 'chapter_id']);
|
2020-08-20 02:57:38 +00:00
|
|
|
}))
|
2021-03-13 03:26:24 +00:00
|
|
|
.then(() => knex.schema.createTable('users_roles', (table) => {
|
|
|
|
table.string('role')
|
|
|
|
.primary();
|
|
|
|
|
|
|
|
table.json('abilities');
|
|
|
|
}))
|
|
|
|
.then(() => knex('users_roles').insert([
|
|
|
|
{
|
|
|
|
role: 'admin',
|
|
|
|
abilities: JSON.stringify([ // serialization necessary to avoid array being interpreted as a PG array
|
|
|
|
{ subject: 'scene', action: 'create' },
|
|
|
|
{ subject: 'scene', action: 'update' },
|
|
|
|
{ subject: 'scene', action: 'delete' },
|
|
|
|
{ subject: 'actor', action: 'create' },
|
|
|
|
{ subject: 'actor', action: 'update' },
|
|
|
|
{ subject: 'actor', action: 'delete' },
|
|
|
|
]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
role: 'editor',
|
|
|
|
abilities: JSON.stringify([ // serialization necessary to avoid array being interpreted as a PG array
|
|
|
|
{ subject: 'scene', action: 'update' },
|
|
|
|
{ subject: 'actor', action: 'update' },
|
|
|
|
]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
role: 'user',
|
|
|
|
},
|
|
|
|
]))
|
|
|
|
.then(() => knex.schema.createTable('users', (table) => {
|
|
|
|
table.increments('id');
|
|
|
|
|
|
|
|
table.text('username')
|
|
|
|
.unique()
|
|
|
|
.notNullable();
|
|
|
|
|
|
|
|
table.text('email')
|
|
|
|
.unique()
|
|
|
|
.notNullable();
|
|
|
|
|
|
|
|
table.text('password')
|
|
|
|
.notNullable();
|
|
|
|
|
|
|
|
table.string('role')
|
|
|
|
.references('role')
|
|
|
|
.inTable('users_roles')
|
|
|
|
.defaultTo('user')
|
|
|
|
.notNullable();
|
|
|
|
|
|
|
|
table.json('abilities');
|
|
|
|
|
|
|
|
table.boolean('email_verified')
|
|
|
|
.notNullable()
|
|
|
|
.defaultTo(false);
|
|
|
|
|
|
|
|
table.boolean('identity_verified')
|
|
|
|
.notNullable()
|
|
|
|
.defaultTo(false);
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.notNullable()
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
2021-03-14 03:54:43 +00:00
|
|
|
.then(() => knex.schema.createTable('stashes', (table) => {
|
|
|
|
table.increments('id');
|
|
|
|
|
|
|
|
table.integer('user_id')
|
|
|
|
.references('id')
|
2021-03-17 04:11:17 +00:00
|
|
|
.inTable('users')
|
|
|
|
.onDelete('cascade');
|
2021-03-14 03:54:43 +00:00
|
|
|
|
|
|
|
table.string('name')
|
|
|
|
.notNullable();
|
|
|
|
|
|
|
|
table.string('slug')
|
|
|
|
.notNullable();
|
|
|
|
|
|
|
|
table.boolean('public')
|
|
|
|
.notNullable()
|
|
|
|
.defaultTo(false);
|
|
|
|
|
2021-03-21 02:23:58 +00:00
|
|
|
table.boolean('primary')
|
2021-03-20 22:03:13 +00:00
|
|
|
.notNullable()
|
2021-03-21 02:23:58 +00:00
|
|
|
.defaultTo(false);
|
2021-03-20 22:03:13 +00:00
|
|
|
|
2021-03-14 03:54:43 +00:00
|
|
|
table.datetime('created_at')
|
|
|
|
.notNullable()
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('stashes_scenes', (table) => {
|
|
|
|
table.integer('stash_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2021-03-17 04:11:17 +00:00
|
|
|
.inTable('stashes')
|
|
|
|
.onDelete('cascade');
|
2021-03-14 03:54:43 +00:00
|
|
|
|
|
|
|
table.integer('scene_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2021-03-17 04:11:17 +00:00
|
|
|
.inTable('releases')
|
|
|
|
.onDelete('cascade');
|
2021-03-14 03:54:43 +00:00
|
|
|
|
2021-03-15 02:30:47 +00:00
|
|
|
table.unique(['stash_id', 'scene_id']);
|
|
|
|
|
2021-03-14 03:54:43 +00:00
|
|
|
table.string('comment');
|
2021-03-19 01:36:31 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.notNullable()
|
|
|
|
.defaultTo(knex.fn.now());
|
2021-03-14 03:54:43 +00:00
|
|
|
}))
|
2021-03-17 04:11:17 +00:00
|
|
|
.then(() => knex.schema.createTable('stashes_movies', (table) => {
|
|
|
|
table.integer('stash_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('stashes')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
|
|
|
table.integer('movie_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('movies')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
|
|
|
table.unique(['stash_id', 'movie_id']);
|
|
|
|
|
|
|
|
table.string('comment');
|
2021-03-19 01:36:31 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.notNullable()
|
|
|
|
.defaultTo(knex.fn.now());
|
2021-03-17 04:11:17 +00:00
|
|
|
}))
|
2021-03-14 03:54:43 +00:00
|
|
|
.then(() => knex.schema.createTable('stashes_actors', (table) => {
|
|
|
|
table.integer('stash_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2021-03-17 04:11:17 +00:00
|
|
|
.inTable('stashes')
|
|
|
|
.onDelete('cascade');
|
2021-03-14 03:54:43 +00:00
|
|
|
|
|
|
|
table.integer('actor_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
2021-03-17 04:11:17 +00:00
|
|
|
.inTable('actors')
|
|
|
|
.onDelete('cascade');
|
2021-03-14 03:54:43 +00:00
|
|
|
|
2021-03-15 02:30:47 +00:00
|
|
|
table.unique(['stash_id', 'actor_id']);
|
|
|
|
|
2021-03-14 03:54:43 +00:00
|
|
|
table.string('comment');
|
2021-03-19 01:36:31 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.notNullable()
|
|
|
|
.defaultTo(knex.fn.now());
|
2021-03-14 03:54:43 +00:00
|
|
|
}))
|
2021-04-04 19:52:19 +00:00
|
|
|
.then(() => knex.schema.createTable('alerts', (table) => {
|
|
|
|
table.increments('id');
|
|
|
|
|
|
|
|
table.integer('user_id')
|
2021-04-04 20:52:54 +00:00
|
|
|
.notNullable()
|
2021-04-04 19:52:19 +00:00
|
|
|
.references('id')
|
|
|
|
.inTable('users')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
|
|
|
table.boolean('notify')
|
|
|
|
.defaultTo(false);
|
|
|
|
|
|
|
|
table.boolean('email')
|
|
|
|
.defaultTo(false);
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.notNullable()
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('alerts_scenes', (table) => {
|
|
|
|
table.increments('id');
|
|
|
|
|
|
|
|
table.integer('alert_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('alerts')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
|
|
|
table.integer('scene_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
|
|
|
table.unique(['alert_id', 'scene_id']);
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('alerts_actors', (table) => {
|
|
|
|
table.increments('id');
|
|
|
|
|
|
|
|
table.integer('alert_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('alerts')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
|
|
|
table.integer('actor_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('actors')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
|
|
|
table.unique(['alert_id', 'actor_id']);
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('alerts_tags', (table) => {
|
|
|
|
table.increments('id');
|
|
|
|
|
|
|
|
table.integer('alert_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('alerts')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
|
|
|
table.integer('tag_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('tags')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
|
|
|
table.unique(['alert_id', 'tag_id']);
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('alerts_entities', (table) => {
|
|
|
|
table.increments('id');
|
|
|
|
|
|
|
|
table.integer('alert_id')
|
|
|
|
.notNullable()
|
2021-04-04 20:52:54 +00:00
|
|
|
.unique()
|
2021-04-04 19:52:19 +00:00
|
|
|
.references('id')
|
|
|
|
.inTable('alerts')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
|
|
|
table.integer('entity_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('entities')
|
|
|
|
.onDelete('cascade');
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('alerts_stashes', (table) => {
|
|
|
|
table.increments('id');
|
|
|
|
|
|
|
|
table.integer('alert_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('alerts')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
|
|
|
table.integer('stash_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('stashes')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
2021-04-04 20:52:54 +00:00
|
|
|
table.unique(['alert_id', 'stash_id']);
|
2021-04-04 19:52:19 +00:00
|
|
|
}))
|
2021-04-16 23:10:45 +00:00
|
|
|
.then(() => knex.schema.createTable('notifications', (table) => {
|
|
|
|
table.increments('id');
|
|
|
|
|
|
|
|
table.integer('user_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('users')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
|
|
|
table.integer('scene_id')
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases')
|
|
|
|
.onDelete('cascade');
|
|
|
|
|
|
|
|
table.integer('alert_id')
|
|
|
|
.references('id')
|
|
|
|
.inTable('alerts')
|
|
|
|
.onDelete('set null');
|
|
|
|
|
|
|
|
table.boolean('seen')
|
|
|
|
.notNullable()
|
|
|
|
.defaultTo(false);
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.notNullable()
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
2021-07-05 22:01:44 +00:00
|
|
|
.then(() => knex.schema.createTable('affiliates', (table) => {
|
|
|
|
table.string('id')
|
|
|
|
.primary()
|
|
|
|
.unique()
|
|
|
|
.notNullable();
|
|
|
|
|
|
|
|
table.integer('entity_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('entities');
|
|
|
|
|
|
|
|
table.text('url');
|
2021-07-11 23:41:18 +00:00
|
|
|
table.text('parameters');
|
2021-07-05 22:01:44 +00:00
|
|
|
|
|
|
|
table.unique(['entity_id', 'url']);
|
2021-07-11 23:41:18 +00:00
|
|
|
table.unique(['entity_id', 'parameters']);
|
2021-07-05 22:01:44 +00:00
|
|
|
|
|
|
|
table.text('comment');
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.notNullable()
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
2021-06-27 22:05:24 +00:00
|
|
|
.then(() => knex.schema.createTable('banners', (table) => {
|
|
|
|
table.string('id')
|
|
|
|
.primary()
|
|
|
|
.unique()
|
|
|
|
.notNullable();
|
|
|
|
|
2021-07-04 22:06:18 +00:00
|
|
|
table.string('type')
|
|
|
|
.defaultTo('jpg');
|
|
|
|
|
2021-06-27 22:05:24 +00:00
|
|
|
table.integer('width')
|
|
|
|
.notNullable();
|
|
|
|
|
|
|
|
table.integer('height')
|
|
|
|
.notNullable();
|
|
|
|
|
|
|
|
table.integer('entity_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('entities');
|
|
|
|
|
|
|
|
table.text('comment');
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.notNullable()
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('banners_tags', (table) => {
|
|
|
|
table.increments('id');
|
|
|
|
|
|
|
|
table.string('banner_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('banners');
|
|
|
|
|
|
|
|
table.integer('tag_id')
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('tags');
|
|
|
|
|
|
|
|
table.unique(['banner_id', 'tag_id']);
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.notNullable()
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('campaigns', (table) => {
|
|
|
|
table.increments('id');
|
|
|
|
|
|
|
|
table.integer('entity_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('entities');
|
|
|
|
|
2021-07-05 22:01:44 +00:00
|
|
|
table.text('affiliate_id')
|
|
|
|
.references('id')
|
|
|
|
.inTable('affiliates');
|
|
|
|
|
|
|
|
table.text('url');
|
|
|
|
|
2021-06-27 22:05:24 +00:00
|
|
|
table.string('banner_id')
|
|
|
|
.references('id')
|
|
|
|
.inTable('banners');
|
|
|
|
|
2021-06-28 00:50:06 +00:00
|
|
|
table.text('comment');
|
|
|
|
|
2021-06-27 22:05:24 +00:00
|
|
|
table.datetime('created_at')
|
|
|
|
.notNullable()
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
2021-06-19 16:09:58 +00:00
|
|
|
// SEARCH AND SORT
|
2020-05-16 02:36:45 +00:00
|
|
|
.then(() => { // eslint-disable-line arrow-body-style
|
|
|
|
// allow vim fold
|
|
|
|
return knex.raw(`
|
2021-03-14 03:54:43 +00:00
|
|
|
ALTER TABLE releases_search ADD COLUMN document tsvector;
|
2021-08-22 20:25:20 +00:00
|
|
|
ALTER TABLE movies_search ADD COLUMN document tsvector;
|
2021-06-19 16:09:58 +00:00
|
|
|
|
|
|
|
/* allow scenes without dates to be mixed inbetween scenes with dates */
|
|
|
|
ALTER TABLE releases
|
|
|
|
ADD COLUMN effective_date timestamptz
|
|
|
|
GENERATED ALWAYS AS (COALESCE(date, created_at)) STORED;
|
2020-06-30 02:33:47 +00:00
|
|
|
`);
|
|
|
|
})
|
|
|
|
// INDEXES
|
|
|
|
.then(() => { // eslint-disable-line arrow-body-style
|
|
|
|
// allow vim fold
|
|
|
|
return knex.raw(`
|
2020-07-18 03:12:32 +00:00
|
|
|
CREATE UNIQUE INDEX unique_actor_slugs_network ON actors (slug, entity_id, entry_id);
|
2021-02-18 03:44:04 +00:00
|
|
|
CREATE UNIQUE INDEX unique_actor_slugs ON actors (slug) WHERE entity_id IS NULL;
|
2020-05-16 02:36:45 +00:00
|
|
|
|
2021-07-05 22:01:44 +00:00
|
|
|
CREATE UNIQUE INDEX unique_entity_campaigns_banner_url ON campaigns (entity_id, url, banner_id) WHERE affiliate_id IS NULL;
|
|
|
|
CREATE UNIQUE INDEX unique_entity_campaigns_url ON campaigns (entity_id, url) WHERE banner_id IS NULL AND affiliate_id IS NULL;
|
|
|
|
CREATE UNIQUE INDEX unique_entity_campaigns_banner_affiliate ON campaigns (entity_id, affiliate_id, banner_id) WHERE url IS NULL;
|
|
|
|
CREATE UNIQUE INDEX unique_entity_campaigns_affiliate ON campaigns (entity_id, affiliate_id) WHERE banner_id IS NULL AND url IS NULL;
|
2021-06-27 22:05:24 +00:00
|
|
|
|
2020-05-16 02:36:45 +00:00
|
|
|
CREATE UNIQUE INDEX releases_search_unique ON releases_search (release_id);
|
2021-08-22 20:25:20 +00:00
|
|
|
CREATE UNIQUE INDEX movies_search_unique ON movies_search (movie_id);
|
2020-05-16 02:36:45 +00:00
|
|
|
CREATE INDEX releases_search_index ON releases_search USING GIN (document);
|
2021-08-22 20:25:20 +00:00
|
|
|
CREATE INDEX movies_search_index ON movies_search USING GIN (document);
|
2020-06-30 02:33:47 +00:00
|
|
|
`);
|
|
|
|
})
|
|
|
|
// FUNCTIONS
|
|
|
|
.then(() => { // eslint-disable-line arrow-body-style
|
|
|
|
// allow vim fold
|
|
|
|
return knex.raw(`
|
2021-08-22 20:25:20 +00:00
|
|
|
CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
2021-08-22 01:14:02 +00:00
|
|
|
|
2021-03-14 03:54:43 +00:00
|
|
|
CREATE FUNCTION current_user_id() RETURNS INTEGER AS $$
|
2021-03-19 23:12:12 +00:00
|
|
|
/* if the user ID is undefined, the adapter will pass it as a string, which cannot be cast as NULL by ::integer */
|
|
|
|
SELECT NULLIF(current_setting('user.id', true), '')::integer;
|
2021-03-14 03:54:43 +00:00
|
|
|
$$ LANGUAGE SQL STABLE;
|
|
|
|
|
2021-02-26 00:33:33 +00:00
|
|
|
/* We need both the release entries and their search ranking, and PostGraphile does not seem to allow virtual foreign keys on function results.
|
2021-02-26 16:22:54 +00:00
|
|
|
* Using a table as a proxy for the search results allows us to get both a reference to the releases table, and the ranking.
|
|
|
|
* A composite type does not seem to be compatible with PostGraphile's @sortable, and a view does not allow for many native constraints */
|
|
|
|
CREATE TABLE releases_search_results (release_id integer, rank real, FOREIGN KEY (release_id) REFERENCES releases (id));
|
2021-08-22 20:25:20 +00:00
|
|
|
CREATE TABLE movies_search_results (movie_id integer, rank real, FOREIGN KEY (movie_id) REFERENCES movies (id));
|
2021-02-26 00:33:33 +00:00
|
|
|
|
2021-02-26 00:52:28 +00:00
|
|
|
CREATE FUNCTION search_releases(query text) RETURNS SETOF releases_search_results AS $$
|
2021-02-26 00:33:33 +00:00
|
|
|
SELECT releases.id, ranks.rank FROM (
|
2021-02-25 01:52:45 +00:00
|
|
|
SELECT
|
|
|
|
releases_search.release_id,
|
2021-04-15 14:56:44 +00:00
|
|
|
ts_rank(releases_search.document, to_tsquery('english', array_to_string(array(SELECT * FROM regexp_matches(query, '[A-Za-zÀ-ÖØ-öø-ÿ0-9]+', 'g')), '|'))) AS rank
|
2021-02-25 01:52:45 +00:00
|
|
|
FROM releases_search
|
|
|
|
) ranks
|
|
|
|
LEFT JOIN releases ON releases.id = ranks.release_id
|
2021-02-26 00:52:28 +00:00
|
|
|
WHERE ranks.rank > 0
|
2021-02-25 01:52:45 +00:00
|
|
|
ORDER BY ranks.rank DESC;
|
|
|
|
$$ LANGUAGE SQL STABLE;
|
|
|
|
|
2021-08-22 20:25:20 +00:00
|
|
|
CREATE FUNCTION search_movies(query text) RETURNS SETOF movies_search_results AS $$
|
|
|
|
SELECT movies.id, ranks.rank FROM (
|
|
|
|
SELECT
|
|
|
|
movies_search.movie_id,
|
|
|
|
ts_rank(movies_search.document, to_tsquery('english', array_to_string(array(SELECT * FROM regexp_matches(query, '[A-Za-zÀ-ÖØ-öø-ÿ0-9]+', 'g')), '|'))) AS rank
|
|
|
|
FROM movies_search
|
|
|
|
) ranks
|
|
|
|
LEFT JOIN movies ON movies.id = ranks.movie_id
|
|
|
|
WHERE ranks.rank > 0
|
|
|
|
ORDER BY ranks.rank DESC;
|
2021-08-21 22:40:22 +00:00
|
|
|
$$ LANGUAGE SQL STABLE;
|
|
|
|
|
2020-06-27 00:57:30 +00:00
|
|
|
CREATE FUNCTION search_entities(search text) RETURNS SETOF entities AS $$
|
|
|
|
SELECT * FROM entities
|
2020-05-16 02:36:45 +00:00
|
|
|
WHERE
|
2021-02-22 01:33:39 +00:00
|
|
|
name ILIKE ('%' || TRIM(search) || '%') OR
|
|
|
|
slug ILIKE ('%' || TRIM(search) || '%') OR
|
|
|
|
array_to_string(alias, '') ILIKE ('%' || TRIM(search) || '%') OR
|
|
|
|
replace(array_to_string(alias, ''), ' ', '') ILIKE ('%' || TRIM(search) || '%') OR
|
2020-05-16 02:36:45 +00:00
|
|
|
url ILIKE ('%' || search || '%')
|
2021-09-17 02:28:48 +00:00
|
|
|
ORDER BY similarity(entities.name, search) DESC, name ASC
|
2020-05-16 02:36:45 +00:00
|
|
|
$$ LANGUAGE SQL STABLE;
|
|
|
|
|
2021-08-22 20:25:20 +00:00
|
|
|
CREATE FUNCTION search_actors(query text, min_length smallint DEFAULT 2) RETURNS SETOF actors AS $$
|
2020-05-17 23:22:56 +00:00
|
|
|
SELECT * FROM actors
|
2021-08-22 20:25:20 +00:00
|
|
|
WHERE query IS NULL
|
|
|
|
OR length(query) >= min_length
|
2021-04-04 19:52:19 +00:00
|
|
|
AND CASE
|
2021-08-22 20:25:20 +00:00
|
|
|
WHEN length(query) > 1 THEN name ILIKE ('%' || TRIM(query) || '%')
|
|
|
|
WHEN length(query) = 1 THEN name ILIKE (TRIM(query) || '%')
|
|
|
|
ELSE true
|
2021-04-04 19:52:19 +00:00
|
|
|
END
|
|
|
|
$$ LANGUAGE SQL STABLE;
|
|
|
|
|
2021-08-22 01:14:02 +00:00
|
|
|
CREATE FUNCTION search_tags(query text, min_length smallint DEFAULT 2) RETURNS SETOF tags AS $$
|
|
|
|
SELECT aliases.* FROM tags
|
|
|
|
LEFT JOIN tags AS aliases ON aliases.id = tags.alias_for OR (tags.alias_for IS NULL AND aliases.id = tags.id)
|
|
|
|
WHERE length(query) >= min_length
|
|
|
|
AND tags.name ILIKE ('%' || TRIM(query) || '%')
|
|
|
|
GROUP BY aliases.id
|
|
|
|
ORDER BY similarity(aliases.slug, query) DESC, slug ASC
|
|
|
|
$$ LANGUAGE SQL STABLE;
|
|
|
|
|
2020-06-30 02:33:47 +00:00
|
|
|
CREATE FUNCTION actors_tags(actor actors, selectable_tags text[]) RETURNS SETOF tags AS $$
|
|
|
|
SELECT tags.*
|
|
|
|
FROM releases_actors
|
|
|
|
LEFT JOIN
|
|
|
|
releases_tags ON releases_tags.release_id = releases_actors.release_id
|
|
|
|
LEFT JOIN
|
|
|
|
tags ON tags.id = releases_tags.tag_id
|
|
|
|
WHERE
|
|
|
|
releases_actors.actor_id = actor.id
|
|
|
|
AND
|
|
|
|
CASE WHEN array_length(selectable_tags, 1) IS NOT NULL
|
|
|
|
THEN tags.slug = ANY(selectable_tags)
|
|
|
|
ELSE true
|
|
|
|
END
|
|
|
|
GROUP BY tags.id
|
|
|
|
ORDER BY tags.name;
|
|
|
|
$$ LANGUAGE SQL STABLE;
|
|
|
|
|
2020-07-20 02:20:33 +00:00
|
|
|
CREATE FUNCTION actors_channels(actor actors) RETURNS SETOF entities AS $$
|
|
|
|
SELECT entities.*
|
|
|
|
FROM releases_actors
|
|
|
|
LEFT JOIN releases ON releases.id = releases_actors.release_id
|
|
|
|
LEFT JOIN entities ON entities.id = releases.entity_id
|
|
|
|
WHERE releases_actors.actor_id = actor.id
|
|
|
|
GROUP BY entities.id;
|
|
|
|
$$ LANGUAGE SQL STABLE;
|
|
|
|
|
2020-09-12 01:09:05 +00:00
|
|
|
CREATE FUNCTION actors_actors(actor actors) RETURNS SETOF actors AS $$
|
|
|
|
SELECT actors.*
|
|
|
|
FROM releases_actors
|
|
|
|
LEFT JOIN releases_actors AS associated_actors ON associated_actors.release_id = releases_actors.release_id
|
|
|
|
LEFT JOIN actors ON actors.id = associated_actors.actor_id
|
|
|
|
WHERE releases_actors.actor_id = actor.id
|
|
|
|
AND NOT actors.id = actor.id
|
|
|
|
GROUP BY actors.id
|
|
|
|
ORDER BY actors.name;
|
|
|
|
$$ LANGUAGE SQL STABLE;
|
|
|
|
|
2020-09-11 00:29:14 +00:00
|
|
|
/* GraphQL/Postgraphile 'every' applies to the data, will only include scenes for which every assigned tag is selected,
|
|
|
|
instead of what we want; scenes with every selected tag, but possibly also some others */
|
2020-07-19 02:25:07 +00:00
|
|
|
CREATE FUNCTION actors_scenes(actor actors, selected_tags text[], mode text DEFAULT 'all') RETURNS SETOF releases AS $$
|
2020-07-19 01:52:36 +00:00
|
|
|
SELECT releases.*
|
|
|
|
FROM releases
|
|
|
|
LEFT JOIN
|
|
|
|
releases_actors ON releases_actors.release_id = releases.id
|
|
|
|
LEFT JOIN
|
|
|
|
releases_tags ON releases_tags.release_id = releases.id
|
|
|
|
LEFT JOIN
|
|
|
|
tags ON tags.id = releases_tags.tag_id
|
2020-07-20 02:20:33 +00:00
|
|
|
WHERE releases_actors.actor_id = actor.id
|
2020-07-19 02:25:07 +00:00
|
|
|
AND CASE
|
2020-09-11 00:29:14 +00:00
|
|
|
/* match at least one of the selected tags */
|
|
|
|
WHEN mode = 'any'
|
|
|
|
AND array_length(selected_tags, 1) > 0
|
2020-07-19 02:25:07 +00:00
|
|
|
THEN tags.slug = ANY(selected_tags)
|
|
|
|
ELSE true
|
|
|
|
END
|
2020-07-19 01:52:36 +00:00
|
|
|
GROUP BY releases.id
|
|
|
|
HAVING CASE
|
2020-09-11 00:29:14 +00:00
|
|
|
/* match all of the selected tags */
|
|
|
|
WHEN mode = 'all'
|
|
|
|
AND array_length(selected_tags, 1) > 0
|
|
|
|
THEN COUNT(
|
|
|
|
CASE WHEN tags.slug = ANY(selected_tags)
|
|
|
|
THEN true
|
|
|
|
END
|
|
|
|
) = array_length(selected_tags, 1)
|
2020-07-19 01:52:36 +00:00
|
|
|
ELSE true
|
|
|
|
END;
|
|
|
|
$$ LANGUAGE SQL STABLE;
|
|
|
|
|
2020-09-09 02:22:43 +00:00
|
|
|
CREATE FUNCTION tags_scenes(tag tags, selected_tags text[], mode text DEFAULT 'all') RETURNS SETOF releases AS $$
|
|
|
|
SELECT releases.*
|
|
|
|
FROM releases
|
|
|
|
LEFT JOIN
|
|
|
|
releases_actors ON releases_actors.release_id = releases.id
|
|
|
|
LEFT JOIN
|
|
|
|
releases_tags ON releases_tags.release_id = releases.id
|
|
|
|
LEFT JOIN
|
|
|
|
tags ON tags.id = releases_tags.tag_id
|
|
|
|
WHERE releases_tags.tag_id = tag.id
|
|
|
|
GROUP BY releases.id;
|
|
|
|
$$ LANGUAGE SQL STABLE;
|
|
|
|
|
2020-08-10 19:39:55 +00:00
|
|
|
CREATE FUNCTION movies_actors(movie movies) RETURNS SETOF actors AS $$
|
|
|
|
SELECT actors.*
|
|
|
|
FROM movies_scenes
|
|
|
|
LEFT JOIN
|
|
|
|
releases ON releases.id = movies_scenes.scene_id
|
|
|
|
LEFT JOIN
|
|
|
|
releases_actors ON releases_actors.release_id = releases.id
|
|
|
|
LEFT JOIN
|
|
|
|
actors ON actors.id = releases_actors.actor_id
|
|
|
|
WHERE movies_scenes.movie_id = movie.id
|
|
|
|
AND actors.id IS NOT NULL
|
|
|
|
GROUP BY actors.id
|
|
|
|
ORDER BY actors.name, actors.gender
|
|
|
|
$$ LANGUAGE SQL STABLE;
|
|
|
|
|
|
|
|
CREATE FUNCTION movies_tags(movie movies) RETURNS SETOF tags AS $$
|
|
|
|
SELECT tags.*
|
|
|
|
FROM movies_scenes
|
|
|
|
LEFT JOIN
|
|
|
|
releases ON releases.id = movies_scenes.scene_id
|
|
|
|
LEFT JOIN
|
|
|
|
releases_tags ON releases_tags.release_id = releases.id
|
|
|
|
LEFT JOIN
|
|
|
|
tags ON tags.id = releases_tags.tag_id
|
|
|
|
WHERE movies_scenes.movie_id = movie.id
|
|
|
|
AND tags.id IS NOT NULL
|
|
|
|
GROUP BY tags.id
|
|
|
|
ORDER BY tags.priority DESC
|
|
|
|
$$ LANGUAGE SQL STABLE;
|
|
|
|
|
2020-09-08 00:20:15 +00:00
|
|
|
CREATE FUNCTION movies_photos(movie movies) RETURNS SETOF media AS $$
|
|
|
|
SELECT media.*
|
|
|
|
FROM movies_scenes
|
|
|
|
LEFT JOIN
|
|
|
|
releases ON releases.id = movies_scenes.scene_id
|
2020-11-19 01:01:13 +00:00
|
|
|
INNER JOIN
|
2020-09-08 00:20:15 +00:00
|
|
|
releases_photos ON releases_photos.release_id = releases.id
|
|
|
|
LEFT JOIN
|
|
|
|
media ON media.id = releases_photos.media_id
|
|
|
|
WHERE movies_scenes.movie_id = movie.id
|
|
|
|
GROUP BY media.id
|
|
|
|
ORDER BY media.index ASC
|
|
|
|
$$ LANGUAGE SQL STABLE;
|
|
|
|
|
2020-05-16 02:36:45 +00:00
|
|
|
CREATE FUNCTION releases_is_new(release releases) RETURNS boolean AS $$
|
2020-06-30 00:08:48 +00:00
|
|
|
SELECT EXISTS(SELECT true WHERE (SELECT id FROM batches ORDER BY created_at DESC LIMIT 1) = release.created_batch_id);
|
2020-05-16 02:36:45 +00:00
|
|
|
$$ LANGUAGE sql STABLE;
|
2021-06-28 00:50:06 +00:00
|
|
|
|
2021-06-28 03:13:41 +00:00
|
|
|
CREATE FUNCTION banners_ratio(banner banners) RETURNS numeric AS $$
|
2021-06-28 00:50:06 +00:00
|
|
|
SELECT ROUND(banner.width::decimal / banner.height::decimal, 2);
|
|
|
|
$$ LANGUAGE SQL STABLE;
|
2021-07-11 23:41:18 +00:00
|
|
|
|
|
|
|
CREATE FUNCTION get_random_campaign() RETURNS SETOF campaigns AS $$
|
|
|
|
SELECT * FROM campaigns
|
|
|
|
ORDER BY random()
|
|
|
|
LIMIT 1;
|
|
|
|
$$ LANGUAGE sql STABLE;
|
2020-06-30 02:33:47 +00:00
|
|
|
`);
|
|
|
|
})
|
2021-03-14 03:54:43 +00:00
|
|
|
// POLICIES
|
|
|
|
.then(() => { // eslint-disable-line arrow-body-style
|
|
|
|
// allow vim fold
|
|
|
|
return knex.raw(`
|
|
|
|
GRANT ALL ON ALL TABLES IN SCHEMA public TO :visitor;
|
|
|
|
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO :visitor;
|
|
|
|
|
2021-03-15 02:30:47 +00:00
|
|
|
REVOKE ALL ON users FROM :visitor;
|
|
|
|
GRANT SELECT (id, username, role, identity_verified, created_at) ON users TO :visitor;
|
|
|
|
|
2021-03-14 03:54:43 +00:00
|
|
|
ALTER TABLE stashes ENABLE ROW LEVEL SECURITY;
|
|
|
|
ALTER TABLE stashes_scenes ENABLE ROW LEVEL SECURITY;
|
2021-03-17 04:11:17 +00:00
|
|
|
ALTER TABLE stashes_movies ENABLE ROW LEVEL SECURITY;
|
2021-03-14 03:54:43 +00:00
|
|
|
ALTER TABLE stashes_actors ENABLE ROW LEVEL SECURITY;
|
|
|
|
|
2021-03-15 02:30:47 +00:00
|
|
|
CREATE POLICY stashes_policy_select ON stashes FOR SELECT USING (stashes.public OR stashes.user_id = current_user_id());
|
|
|
|
CREATE POLICY stashes_policy_update ON stashes FOR UPDATE USING (stashes.public OR stashes.user_id = current_user_id());
|
|
|
|
CREATE POLICY stashes_policy_delete ON stashes FOR DELETE USING (stashes.public OR stashes.user_id = current_user_id());
|
|
|
|
CREATE POLICY stashes_policy_insert ON stashes FOR INSERT WITH CHECK (true);
|
2021-03-14 03:54:43 +00:00
|
|
|
|
|
|
|
CREATE POLICY stashes_policy ON stashes_scenes
|
|
|
|
USING (EXISTS (
|
|
|
|
SELECT *
|
|
|
|
FROM stashes
|
|
|
|
WHERE stashes.id = stashes_scenes.stash_id
|
2021-03-15 02:30:47 +00:00
|
|
|
AND (stashes.user_id = current_user_id() OR stashes.public)
|
2021-03-14 03:54:43 +00:00
|
|
|
));
|
|
|
|
|
2021-03-17 04:11:17 +00:00
|
|
|
CREATE POLICY stashes_policy ON stashes_movies
|
|
|
|
USING (EXISTS (
|
|
|
|
SELECT *
|
|
|
|
FROM stashes
|
|
|
|
WHERE stashes.id = stashes_movies.stash_id
|
|
|
|
AND (stashes.user_id = current_user_id() OR stashes.public)
|
|
|
|
));
|
|
|
|
|
2021-03-14 03:54:43 +00:00
|
|
|
CREATE POLICY stashes_policy ON stashes_actors
|
|
|
|
USING (EXISTS (
|
|
|
|
SELECT *
|
|
|
|
FROM stashes
|
|
|
|
WHERE stashes.id = stashes_actors.stash_id
|
2021-03-15 02:30:47 +00:00
|
|
|
AND (stashes.user_id = current_user_id() OR stashes.public)
|
2021-03-14 03:54:43 +00:00
|
|
|
));
|
2021-04-04 20:52:54 +00:00
|
|
|
|
|
|
|
ALTER TABLE alerts ENABLE ROW LEVEL SECURITY;
|
|
|
|
ALTER TABLE alerts_tags ENABLE ROW LEVEL SECURITY;
|
|
|
|
ALTER TABLE alerts_scenes ENABLE ROW LEVEL SECURITY;
|
|
|
|
ALTER TABLE alerts_actors ENABLE ROW LEVEL SECURITY;
|
|
|
|
ALTER TABLE alerts_entities ENABLE ROW LEVEL SECURITY;
|
|
|
|
ALTER TABLE alerts_stashes ENABLE ROW LEVEL SECURITY;
|
|
|
|
|
|
|
|
CREATE POLICY alerts_policy_select ON alerts FOR SELECT USING (alerts.user_id = current_user_id());
|
|
|
|
CREATE POLICY alerts_policy_update ON alerts FOR UPDATE USING (alerts.user_id = current_user_id());
|
|
|
|
CREATE POLICY alerts_policy_delete ON alerts FOR DELETE USING (alerts.user_id = current_user_id());
|
|
|
|
CREATE POLICY alerts_policy_insert ON alerts FOR INSERT WITH CHECK (true);
|
|
|
|
|
|
|
|
CREATE POLICY alerts_policy ON alerts_scenes
|
|
|
|
USING (EXISTS (
|
|
|
|
SELECT *
|
|
|
|
FROM alerts
|
|
|
|
WHERE alerts.id = alerts_scenes.alert_id
|
|
|
|
AND alerts.user_id = current_user_id()
|
|
|
|
));
|
|
|
|
|
|
|
|
CREATE POLICY alerts_policy ON alerts_actors
|
|
|
|
USING (EXISTS (
|
|
|
|
SELECT *
|
|
|
|
FROM alerts
|
|
|
|
WHERE alerts.id = alerts_actors.alert_id
|
|
|
|
AND alerts.user_id = current_user_id()
|
|
|
|
));
|
|
|
|
|
|
|
|
CREATE POLICY alerts_policy ON alerts_entities
|
|
|
|
USING (EXISTS (
|
|
|
|
SELECT *
|
|
|
|
FROM alerts
|
|
|
|
WHERE alerts.id = alerts_entities.alert_id
|
|
|
|
AND alerts.user_id = current_user_id()
|
|
|
|
));
|
|
|
|
|
|
|
|
CREATE POLICY alerts_policy ON alerts_tags
|
|
|
|
USING (EXISTS (
|
|
|
|
SELECT *
|
|
|
|
FROM alerts
|
|
|
|
WHERE alerts.id = alerts_tags.alert_id
|
|
|
|
AND alerts.user_id = current_user_id()
|
|
|
|
));
|
|
|
|
|
|
|
|
CREATE POLICY alerts_policy ON alerts_stashes
|
|
|
|
USING (EXISTS (
|
|
|
|
SELECT *
|
|
|
|
FROM alerts
|
|
|
|
WHERE alerts.id = alerts_stashes.alert_id
|
|
|
|
AND alerts.user_id = current_user_id()
|
|
|
|
));
|
2021-04-22 17:44:23 +00:00
|
|
|
|
|
|
|
ALTER TABLE notifications ENABLE ROW LEVEL SECURITY;
|
|
|
|
|
|
|
|
CREATE POLICY notifications_policy_select ON notifications FOR SELECT USING (notifications.user_id = current_user_id());
|
|
|
|
CREATE POLICY notifications_policy_update ON notifications FOR UPDATE USING (notifications.user_id = current_user_id());
|
|
|
|
CREATE POLICY notifications_policy_delete ON notifications FOR DELETE USING (notifications.user_id = current_user_id());
|
|
|
|
CREATE POLICY notifications_policy_insert ON notifications FOR INSERT WITH CHECK (true);
|
2021-05-15 00:51:52 +00:00
|
|
|
|
|
|
|
ALTER TABLE releases_photos ENABLE ROW LEVEL SECURITY;
|
|
|
|
CREATE POLICY releases_photos_select ON releases_photos FOR SELECT USING (current_user_id() IS NOT NULL);
|
|
|
|
|
|
|
|
ALTER TABLE releases_trailers ENABLE ROW LEVEL SECURITY;
|
|
|
|
CREATE POLICY releases_trailers_select ON releases_trailers FOR SELECT USING (current_user_id() IS NOT NULL);
|
2021-03-14 03:54:43 +00:00
|
|
|
`, {
|
|
|
|
visitor: knex.raw(config.database.query.user),
|
|
|
|
});
|
|
|
|
})
|
2020-06-30 02:33:47 +00:00
|
|
|
// VIEWS AND COMMENTS
|
|
|
|
.then(() => { // eslint-disable-line arrow-body-style
|
|
|
|
// allow vim fold
|
|
|
|
return knex.raw(`
|
2021-03-15 02:30:47 +00:00
|
|
|
COMMENT ON COLUMN users.password IS E'@omit';
|
|
|
|
COMMENT ON COLUMN users.email IS E'@omit';
|
|
|
|
COMMENT ON COLUMN users.email_verified IS E'@omit';
|
|
|
|
COMMENT ON COLUMN users.abilities IS E'@omit';
|
2021-03-13 03:26:24 +00:00
|
|
|
|
2020-05-16 02:36:45 +00:00
|
|
|
COMMENT ON COLUMN actors.height IS E'@omit read,update,create,delete,all,many';
|
|
|
|
COMMENT ON COLUMN actors.weight IS E'@omit read,update,create,delete,all,many';
|
2020-11-15 03:33:24 +00:00
|
|
|
COMMENT ON COLUMN actors.penis_length IS E'@omit read,update,create,delete,all,many';
|
|
|
|
COMMENT ON COLUMN actors.penis_girth IS E'@omit read,update,create,delete,all,many';
|
2020-07-19 01:52:36 +00:00
|
|
|
|
2020-07-20 02:20:33 +00:00
|
|
|
COMMENT ON FUNCTION actors_tags IS E'@sortable';
|
|
|
|
COMMENT ON FUNCTION actors_channels IS E'@sortable';
|
2020-09-12 01:09:05 +00:00
|
|
|
COMMENT ON FUNCTION actors_actors IS E'@sortable';
|
2020-07-19 01:52:36 +00:00
|
|
|
COMMENT ON FUNCTION actors_scenes IS E'@sortable';
|
2020-09-09 02:22:43 +00:00
|
|
|
COMMENT ON FUNCTION tags_scenes IS E'@sortable';
|
2021-08-21 22:40:22 +00:00
|
|
|
|
2021-02-26 00:52:28 +00:00
|
|
|
COMMENT ON FUNCTION search_releases IS E'@sortable';
|
2021-09-17 02:28:48 +00:00
|
|
|
COMMENT ON FUNCTION search_entities IS E'@sortable';
|
2021-04-04 19:52:19 +00:00
|
|
|
COMMENT ON FUNCTION search_actors IS E'@sortable';
|
2021-08-21 22:40:22 +00:00
|
|
|
COMMENT ON FUNCTION search_movies IS E'@sortable';
|
2021-04-04 19:52:19 +00:00
|
|
|
COMMENT ON FUNCTION search_tags IS E'@sortable';
|
2020-05-16 02:36:45 +00:00
|
|
|
`);
|
|
|
|
});
|
|
|
|
|
|
|
|
exports.down = (knex) => { // eslint-disable-line arrow-body-style
|
|
|
|
// allow vim fold
|
|
|
|
return knex.raw(`
|
|
|
|
DROP TABLE IF EXISTS releases_actors CASCADE;
|
|
|
|
DROP TABLE IF EXISTS releases_movies CASCADE;
|
|
|
|
DROP TABLE IF EXISTS releases_directors CASCADE;
|
|
|
|
DROP TABLE IF EXISTS releases_posters CASCADE;
|
|
|
|
DROP TABLE IF EXISTS releases_photos CASCADE;
|
|
|
|
DROP TABLE IF EXISTS releases_covers CASCADE;
|
|
|
|
DROP TABLE IF EXISTS releases_trailers CASCADE;
|
|
|
|
DROP TABLE IF EXISTS releases_teasers CASCADE;
|
|
|
|
DROP TABLE IF EXISTS releases_tags CASCADE;
|
|
|
|
DROP TABLE IF EXISTS releases_search CASCADE;
|
2021-08-22 20:25:20 +00:00
|
|
|
DROP TABLE IF EXISTS movies_search CASCADE;
|
2020-05-16 02:36:45 +00:00
|
|
|
|
2020-08-08 16:10:59 +00:00
|
|
|
DROP TABLE IF EXISTS movies_scenes CASCADE;
|
2020-11-19 01:01:13 +00:00
|
|
|
DROP TABLE IF EXISTS movies_covers CASCADE;
|
|
|
|
DROP TABLE IF EXISTS movies_posters CASCADE;
|
2020-08-01 13:11:07 +00:00
|
|
|
DROP TABLE IF EXISTS movies_trailers CASCADE;
|
|
|
|
|
2020-08-20 17:52:02 +00:00
|
|
|
DROP TABLE IF EXISTS clips_tags CASCADE;
|
|
|
|
DROP TABLE IF EXISTS clips_posters CASCADE;
|
|
|
|
DROP TABLE IF EXISTS clips_photos CASCADE;
|
2020-08-20 02:57:38 +00:00
|
|
|
|
2021-02-26 23:37:22 +00:00
|
|
|
DROP TABLE IF EXISTS chapters_tags CASCADE;
|
|
|
|
DROP TABLE IF EXISTS chapters_posters CASCADE;
|
|
|
|
DROP TABLE IF EXISTS chapters_photos CASCADE;
|
|
|
|
|
2021-06-27 22:05:24 +00:00
|
|
|
DROP TABLE IF EXISTS banners_tags CASCADE;
|
|
|
|
DROP TABLE IF EXISTS banners CASCADE;
|
|
|
|
DROP TABLE IF EXISTS campaigns CASCADE;
|
2021-07-05 22:01:44 +00:00
|
|
|
DROP TABLE IF EXISTS affiliates CASCADE;
|
|
|
|
|
2020-05-16 02:36:45 +00:00
|
|
|
DROP TABLE IF EXISTS batches CASCADE;
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS actors_avatars CASCADE;
|
|
|
|
DROP TABLE IF EXISTS actors_photos CASCADE;
|
|
|
|
DROP TABLE IF EXISTS actors_social CASCADE;
|
|
|
|
DROP TABLE IF EXISTS actors_profiles CASCADE;
|
|
|
|
DROP TABLE IF EXISTS actors_tattoos CASCADE;
|
|
|
|
DROP TABLE IF EXISTS actors_piercings CASCADE;
|
|
|
|
DROP TABLE IF EXISTS body CASCADE;
|
|
|
|
|
2020-06-03 23:03:02 +00:00
|
|
|
DROP TABLE IF EXISTS entities_tags CASCADE;
|
2020-06-27 00:57:30 +00:00
|
|
|
DROP TABLE IF EXISTS entities_social CASCADE;
|
2021-06-27 22:05:24 +00:00
|
|
|
|
2020-05-16 02:36:45 +00:00
|
|
|
DROP TABLE IF EXISTS sites_tags CASCADE;
|
|
|
|
DROP TABLE IF EXISTS sites_social CASCADE;
|
|
|
|
DROP TABLE IF EXISTS networks_social CASCADE;
|
|
|
|
DROP TABLE IF EXISTS tags_posters CASCADE;
|
|
|
|
DROP TABLE IF EXISTS tags_photos CASCADE;
|
2020-07-25 01:44:19 +00:00
|
|
|
DROP TABLE IF EXISTS movies CASCADE;
|
2020-08-20 17:52:02 +00:00
|
|
|
DROP TABLE IF EXISTS clips CASCADE;
|
2021-02-26 23:37:22 +00:00
|
|
|
DROP TABLE IF EXISTS chapters CASCADE;
|
2020-05-16 02:36:45 +00:00
|
|
|
DROP TABLE IF EXISTS releases CASCADE;
|
|
|
|
DROP TABLE IF EXISTS actors CASCADE;
|
|
|
|
DROP TABLE IF EXISTS tags CASCADE;
|
|
|
|
DROP TABLE IF EXISTS tags_groups CASCADE;
|
|
|
|
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;
|
|
|
|
|
2020-06-03 23:03:02 +00:00
|
|
|
DROP TABLE IF EXISTS entities_types CASCADE;
|
|
|
|
DROP TABLE IF EXISTS entities CASCADE;
|
|
|
|
|
2021-04-16 23:10:45 +00:00
|
|
|
DROP TABLE IF EXISTS notifications CASCADE;
|
|
|
|
|
2021-03-14 03:54:43 +00:00
|
|
|
DROP TABLE IF EXISTS stashes_scenes CASCADE;
|
2021-03-17 04:11:17 +00:00
|
|
|
DROP TABLE IF EXISTS stashes_movies CASCADE;
|
2021-03-14 03:54:43 +00:00
|
|
|
DROP TABLE IF EXISTS stashes_actors CASCADE;
|
|
|
|
DROP TABLE IF EXISTS stashes CASCADE;
|
|
|
|
|
2021-04-04 19:52:19 +00:00
|
|
|
DROP TABLE IF EXISTS alerts_scenes CASCADE;
|
|
|
|
DROP TABLE IF EXISTS alerts_actors CASCADE;
|
|
|
|
DROP TABLE IF EXISTS alerts_tags CASCADE;
|
|
|
|
DROP TABLE IF EXISTS alerts_entities CASCADE;
|
|
|
|
DROP TABLE IF EXISTS alerts_stashes CASCADE;
|
|
|
|
DROP TABLE IF EXISTS alerts CASCADE;
|
|
|
|
|
2021-03-13 03:26:24 +00:00
|
|
|
DROP TABLE IF EXISTS users CASCADE;
|
|
|
|
DROP TABLE IF EXISTS users_roles CASCADE;
|
|
|
|
|
2021-02-26 00:33:33 +00:00
|
|
|
DROP FUNCTION IF EXISTS search_releases;
|
2020-05-16 02:36:45 +00:00
|
|
|
DROP FUNCTION IF EXISTS search_sites;
|
2020-06-27 00:57:30 +00:00
|
|
|
DROP FUNCTION IF EXISTS search_entities;
|
2020-05-17 23:22:56 +00:00
|
|
|
DROP FUNCTION IF EXISTS search_actors;
|
2021-08-22 01:14:02 +00:00
|
|
|
DROP FUNCTION IF EXISTS search_movies;
|
2021-04-04 19:52:19 +00:00
|
|
|
DROP FUNCTION IF EXISTS search_tags;
|
2020-05-16 02:36:45 +00:00
|
|
|
DROP FUNCTION IF EXISTS get_random_sfw_media_id;
|
|
|
|
|
2020-06-30 02:33:47 +00:00
|
|
|
DROP FUNCTION IF EXISTS releases_is_new;
|
|
|
|
DROP FUNCTION IF EXISTS actors_tags;
|
2020-07-20 02:20:33 +00:00
|
|
|
DROP FUNCTION IF EXISTS actors_channels;
|
2020-09-12 01:09:05 +00:00
|
|
|
DROP FUNCTION IF EXISTS actors_actors;
|
2020-07-19 01:52:36 +00:00
|
|
|
DROP FUNCTION IF EXISTS actors_scenes;
|
2020-06-30 02:33:47 +00:00
|
|
|
|
2020-08-10 19:39:55 +00:00
|
|
|
DROP FUNCTION IF EXISTS movies_actors;
|
|
|
|
DROP FUNCTION IF EXISTS movies_tags;
|
2020-09-08 00:20:15 +00:00
|
|
|
DROP FUNCTION IF EXISTS movies_photos;
|
2020-08-10 19:39:55 +00:00
|
|
|
|
2021-03-14 03:54:43 +00:00
|
|
|
DROP POLICY IF EXISTS stashes_policy ON stashes;
|
|
|
|
DROP POLICY IF EXISTS stashes_policy ON stashes_scenes;
|
|
|
|
DROP POLICY IF EXISTS stashes_policy ON stashes_actors;
|
|
|
|
|
|
|
|
DROP FUNCTION IF EXISTS current_user_id;
|
2021-07-11 23:41:18 +00:00
|
|
|
DROP FUNCTION IF EXISTS get_random_campaign;
|
2021-03-14 03:54:43 +00:00
|
|
|
|
2021-02-26 16:22:54 +00:00
|
|
|
DROP TABLE IF EXISTS releases_search_results;
|
2021-08-22 20:25:20 +00:00
|
|
|
DROP TABLE IF EXISTS movies_search_results;
|
2020-05-16 02:36:45 +00:00
|
|
|
`);
|
|
|
|
};
|