2019-03-25 02:57:33 +00:00
|
|
|
exports.up = knex => Promise.resolve()
|
2019-11-17 02:56:45 +00:00
|
|
|
.then(() => knex.schema.createTable('countries', (table) => {
|
|
|
|
table.string('alpha2', 2)
|
|
|
|
.unique()
|
|
|
|
.primary();
|
|
|
|
|
2019-11-30 04:55:32 +00:00
|
|
|
table.string('alpha3', 3)
|
|
|
|
.unique();
|
|
|
|
|
2019-11-17 02:56:45 +00:00
|
|
|
table.string('name')
|
|
|
|
.notNullable();
|
|
|
|
|
2019-11-30 04:55:32 +00:00
|
|
|
table.string('alias');
|
|
|
|
|
2019-11-17 02:56:45 +00:00
|
|
|
table.integer('code', 3);
|
2019-11-30 04:55:32 +00:00
|
|
|
table.string('nationality');
|
|
|
|
table.integer('priority', 2)
|
|
|
|
.defaultTo(0);
|
2019-11-17 02:56:45 +00:00
|
|
|
}))
|
2019-12-19 01:35:07 +00:00
|
|
|
.then(() => knex.schema.createTable('media', (table) => {
|
|
|
|
table.increments('id', 16);
|
2019-11-12 00:22:20 +00:00
|
|
|
|
2019-12-19 01:35:07 +00:00
|
|
|
table.string('path');
|
|
|
|
table.string('thumbnail');
|
|
|
|
table.integer('index');
|
|
|
|
table.string('mime');
|
2019-11-19 03:36:15 +00:00
|
|
|
|
2020-02-18 15:00:36 +00:00
|
|
|
table.string('hash');
|
2020-02-24 03:01:58 +00:00
|
|
|
|
|
|
|
table.integer('size', 12);
|
|
|
|
table.integer('quality', 6);
|
|
|
|
table.integer('width', 6);
|
|
|
|
table.integer('height', 6);
|
2020-02-18 15:00:36 +00:00
|
|
|
table.float('entropy');
|
2019-04-04 02:00:28 +00:00
|
|
|
|
2020-02-24 02:12:58 +00:00
|
|
|
table.string('scraper', 32);
|
|
|
|
table.string('copyright', 100);
|
2019-12-19 01:35:07 +00:00
|
|
|
table.string('source', 1000);
|
2020-02-26 23:38:11 +00:00
|
|
|
table.text('comment');
|
2019-07-06 03:29:12 +00:00
|
|
|
|
2019-12-19 01:35:07 +00:00
|
|
|
table.unique('hash');
|
|
|
|
table.unique('source');
|
2019-11-12 00:22:20 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
2019-04-04 02:00:28 +00:00
|
|
|
}))
|
2019-04-07 00:15:57 +00:00
|
|
|
.then(() => knex.schema.createTable('tags_groups', (table) => {
|
2019-09-08 01:53:09 +00:00
|
|
|
table.increments('id', 12);
|
2019-04-07 00:15:57 +00:00
|
|
|
|
2019-11-11 04:18:28 +00:00
|
|
|
table.string('name', 32);
|
|
|
|
table.text('description');
|
|
|
|
|
2019-09-08 01:53:09 +00:00
|
|
|
table.string('slug', 32)
|
|
|
|
.unique();
|
2019-11-12 00:22:20 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
2019-04-07 00:15:57 +00:00
|
|
|
}))
|
2019-03-25 02:57:33 +00:00
|
|
|
.then(() => knex.schema.createTable('tags', (table) => {
|
2019-09-08 01:53:09 +00:00
|
|
|
table.increments('id', 12);
|
2019-10-27 23:58:54 +00:00
|
|
|
table.string('name');
|
2019-05-06 00:01:57 +00:00
|
|
|
|
2019-11-11 04:18:28 +00:00
|
|
|
table.text('description');
|
|
|
|
|
2019-11-12 00:22:20 +00:00
|
|
|
table.integer('priority', 2)
|
|
|
|
.defaultTo(0);
|
|
|
|
|
2020-02-29 21:47:48 +00:00
|
|
|
table.boolean('secondary')
|
|
|
|
.defaultTo(false);
|
|
|
|
|
2019-09-08 01:53:09 +00:00
|
|
|
table.integer('group_id', 12)
|
|
|
|
.references('id')
|
2019-04-07 00:15:57 +00:00
|
|
|
.inTable('tags_groups');
|
|
|
|
|
2019-09-08 01:53:09 +00:00
|
|
|
table.integer('alias_for', 12)
|
|
|
|
.references('id')
|
2019-03-25 02:57:33 +00:00
|
|
|
.inTable('tags');
|
2019-09-08 01:53:09 +00:00
|
|
|
|
|
|
|
table.string('slug', 32)
|
|
|
|
.unique();
|
2019-11-12 00:22:20 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
2019-03-25 02:57:33 +00:00
|
|
|
}))
|
2019-12-19 01:35:07 +00:00
|
|
|
.then(() => knex.schema.createTable('tags_posters', (table) => {
|
|
|
|
table.integer('tag_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('tags');
|
|
|
|
|
|
|
|
table.integer('media_id', 16)
|
|
|
|
.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');
|
|
|
|
|
|
|
|
table.integer('media_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
|
|
|
table.unique(['tag_id', 'media_id']);
|
|
|
|
}))
|
2019-03-25 02:57:33 +00:00
|
|
|
.then(() => knex.schema.createTable('networks', (table) => {
|
2019-09-08 01:53:09 +00:00
|
|
|
table.increments('id', 12);
|
2019-03-25 02:57:33 +00:00
|
|
|
|
|
|
|
table.string('name');
|
|
|
|
table.string('url');
|
2019-05-06 00:01:57 +00:00
|
|
|
table.text('description');
|
2020-02-09 18:41:39 +00:00
|
|
|
table.json('parameters');
|
2019-09-08 01:53:09 +00:00
|
|
|
|
2020-02-20 01:35:23 +00:00
|
|
|
table.integer('parent_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('networks');
|
|
|
|
|
2019-09-08 01:53:09 +00:00
|
|
|
table.string('slug', 32)
|
|
|
|
.unique();
|
2019-11-12 00:22:20 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
2019-03-25 02:57:33 +00:00
|
|
|
}))
|
2019-12-19 01:35:07 +00:00
|
|
|
.then(() => knex.schema.createTable('networks_social', (table) => {
|
|
|
|
table.increments('id', 16);
|
|
|
|
|
|
|
|
table.string('url');
|
|
|
|
table.string('platform');
|
|
|
|
|
|
|
|
table.integer('network_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('networks');
|
|
|
|
|
|
|
|
table.unique(['url', 'network_id']);
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
2019-03-25 02:57:33 +00:00
|
|
|
.then(() => knex.schema.createTable('sites', (table) => {
|
2019-09-08 01:53:09 +00:00
|
|
|
table.increments('id', 12);
|
2019-03-25 02:57:33 +00:00
|
|
|
|
2019-09-08 01:53:09 +00:00
|
|
|
table.integer('network_id', 12)
|
2019-03-25 02:57:33 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('networks');
|
|
|
|
|
|
|
|
table.string('name');
|
2020-03-11 23:15:25 +00:00
|
|
|
table.string('slug', 32)
|
|
|
|
.unique();
|
|
|
|
|
|
|
|
table.string('alias');
|
|
|
|
|
2019-03-25 02:57:33 +00:00
|
|
|
table.string('url');
|
2019-05-06 00:01:57 +00:00
|
|
|
table.text('description');
|
2020-02-09 18:41:39 +00:00
|
|
|
table.json('parameters');
|
2019-09-08 01:53:09 +00:00
|
|
|
|
2020-02-03 01:57:53 +00:00
|
|
|
table.integer('priority', 3)
|
|
|
|
.defaultTo(0);
|
2020-02-07 02:40:11 +00:00
|
|
|
table.boolean('show')
|
|
|
|
.defaultTo(true);
|
|
|
|
table.boolean('scrape')
|
2020-02-03 01:57:53 +00:00
|
|
|
.defaultTo(true);
|
|
|
|
|
2019-11-12 00:22:20 +00:00
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
2019-03-25 02:57:33 +00:00
|
|
|
}))
|
2019-12-19 01:35:07 +00:00
|
|
|
.then(() => knex.schema.createTable('sites_tags', (table) => {
|
|
|
|
table.integer('tag_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('tags');
|
|
|
|
|
|
|
|
table.integer('site_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('sites');
|
|
|
|
|
2020-01-13 22:45:09 +00:00
|
|
|
table.boolean('inherit')
|
|
|
|
.defaultTo(false);
|
|
|
|
|
2019-12-19 01:35:07 +00:00
|
|
|
table.unique(['tag_id', 'site_id']);
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('sites_social', (table) => {
|
|
|
|
table.increments('id', 16);
|
|
|
|
|
|
|
|
table.string('url');
|
|
|
|
table.string('platform');
|
|
|
|
|
|
|
|
table.integer('site_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('sites');
|
|
|
|
|
|
|
|
table.unique(['url', 'site_id']);
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
2019-10-30 03:45:42 +00:00
|
|
|
.then(() => knex.schema.createTable('studios', (table) => {
|
|
|
|
table.increments('id', 12);
|
|
|
|
|
|
|
|
table.integer('network_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('networks');
|
|
|
|
|
|
|
|
table.string('name');
|
|
|
|
table.string('url');
|
|
|
|
table.text('description');
|
|
|
|
|
|
|
|
table.string('slug', 32)
|
|
|
|
.unique();
|
2019-11-12 00:22:20 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
2019-10-30 03:45:42 +00:00
|
|
|
}))
|
2019-12-19 01:35:07 +00:00
|
|
|
.then(() => knex.schema.createTable('actors', (table) => {
|
|
|
|
table.increments('id', 12);
|
|
|
|
|
|
|
|
table.string('name')
|
|
|
|
.unique()
|
|
|
|
.notNullable();
|
|
|
|
|
|
|
|
table.date('birthdate');
|
|
|
|
table.string('gender', 18);
|
|
|
|
table.text('description');
|
|
|
|
|
|
|
|
table.string('birth_city');
|
|
|
|
table.string('birth_state');
|
|
|
|
table.string('birth_country_alpha2', 2)
|
|
|
|
.references('alpha2')
|
|
|
|
.inTable('countries');
|
|
|
|
|
|
|
|
table.string('residence_city');
|
|
|
|
table.string('residence_state');
|
|
|
|
table.string('residence_country_alpha2', 2)
|
|
|
|
.references('alpha2')
|
|
|
|
.inTable('countries');
|
|
|
|
|
|
|
|
table.string('ethnicity');
|
|
|
|
|
|
|
|
table.string('bust', 10);
|
|
|
|
table.integer('waist', 3);
|
|
|
|
table.integer('hip', 3);
|
|
|
|
table.boolean('natural_boobs');
|
|
|
|
|
|
|
|
table.integer('height', 3);
|
|
|
|
table.integer('weight', 3);
|
|
|
|
table.string('eyes');
|
|
|
|
table.string('hair');
|
|
|
|
|
|
|
|
table.boolean('has_tattoos');
|
|
|
|
table.boolean('has_piercings');
|
|
|
|
table.string('piercings');
|
|
|
|
table.string('tattoos');
|
|
|
|
|
|
|
|
table.integer('alias_for', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('actors');
|
|
|
|
|
|
|
|
table.string('slug', 32)
|
|
|
|
.unique();
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
|
|
|
|
table.datetime('scraped_at');
|
|
|
|
table.boolean('scrape_success');
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('actors_avatars', (table) => {
|
|
|
|
table.integer('actor_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('actors');
|
|
|
|
|
|
|
|
table.integer('media_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
|
|
|
table.unique('actor_id');
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('actors_photos', (table) => {
|
|
|
|
table.integer('actor_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('actors');
|
|
|
|
|
|
|
|
table.integer('media_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
|
|
|
table.unique(['actor_id', 'media_id']);
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('actors_social', (table) => {
|
|
|
|
table.increments('id', 16);
|
|
|
|
|
|
|
|
table.string('url');
|
|
|
|
table.string('platform');
|
|
|
|
|
2020-02-28 02:56:58 +00:00
|
|
|
table.integer('actor_id', 12)
|
2019-12-19 01:35:07 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('actors');
|
|
|
|
|
|
|
|
table.unique(['url', 'actor_id']);
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('directors', (table) => {
|
|
|
|
table.increments('id', 12);
|
|
|
|
|
|
|
|
table.string('name');
|
|
|
|
table.integer('alias_for', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('directors');
|
|
|
|
|
|
|
|
table.string('slug', 32)
|
|
|
|
.unique();
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
2020-03-02 02:41:41 +00:00
|
|
|
.then(() => knex.schema.createTable('batches', (table) => {
|
|
|
|
table.increments('id', 12);
|
|
|
|
table.text('comment');
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
2019-03-25 02:57:33 +00:00
|
|
|
.then(() => knex.schema.createTable('releases', (table) => {
|
2019-09-08 01:53:09 +00:00
|
|
|
table.increments('id', 16);
|
2019-03-25 02:57:33 +00:00
|
|
|
|
2019-09-08 01:53:09 +00:00
|
|
|
table.integer('site_id', 12)
|
2019-03-25 02:57:33 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('sites');
|
|
|
|
|
2019-10-30 03:45:42 +00:00
|
|
|
table.integer('studio_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('studios');
|
|
|
|
|
2020-02-10 00:27:13 +00:00
|
|
|
table.string('type', 10)
|
|
|
|
.defaultTo('scene');
|
2019-12-11 04:15:23 +00:00
|
|
|
|
2019-03-25 02:57:33 +00:00
|
|
|
table.string('shoot_id');
|
2019-04-06 21:24:26 +00:00
|
|
|
table.string('entry_id');
|
|
|
|
table.unique(['site_id', 'entry_id']);
|
2019-04-01 00:45:15 +00:00
|
|
|
|
2019-11-12 00:22:20 +00:00
|
|
|
table.string('url', 1000);
|
2019-03-25 02:57:33 +00:00
|
|
|
table.string('title');
|
2020-02-04 02:12:09 +00:00
|
|
|
table.string('slug');
|
2019-03-25 02:57:33 +00:00
|
|
|
table.date('date');
|
|
|
|
table.text('description');
|
|
|
|
|
|
|
|
table.integer('duration')
|
|
|
|
.unsigned();
|
|
|
|
|
2019-09-26 01:27:01 +00:00
|
|
|
table.boolean('deep');
|
2020-02-11 03:58:18 +00:00
|
|
|
table.string('deep_url', 1000);
|
2019-09-26 01:27:01 +00:00
|
|
|
|
2020-03-02 02:41:41 +00:00
|
|
|
table.integer('created_batch_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('batches');
|
|
|
|
|
|
|
|
table.integer('updated_batch_id', 12)
|
|
|
|
.references('id')
|
|
|
|
.inTable('batches');
|
|
|
|
|
2019-05-06 00:01:57 +00:00
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
2019-03-25 02:57:33 +00:00
|
|
|
}))
|
2019-12-19 01:35:07 +00:00
|
|
|
.then(() => knex.schema.createTable('releases_actors', (table) => {
|
2019-09-08 01:53:09 +00:00
|
|
|
table.integer('release_id', 16)
|
2019-03-25 02:57:33 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases');
|
|
|
|
|
2020-02-28 02:56:58 +00:00
|
|
|
table.integer('actor_id', 12)
|
2019-03-25 02:57:33 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('actors');
|
2019-11-19 03:36:15 +00:00
|
|
|
|
|
|
|
table.unique(['release_id', 'actor_id']);
|
2020-03-09 04:06:37 +00:00
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('releases_movies', (table) => {
|
|
|
|
table.integer('movie_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases');
|
|
|
|
|
|
|
|
table.integer('scene_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases');
|
|
|
|
|
|
|
|
table.unique(['movie_id', 'scene_id']);
|
|
|
|
|
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
2019-03-25 02:57:33 +00:00
|
|
|
}))
|
2019-12-19 01:35:07 +00:00
|
|
|
.then(() => knex.schema.createTable('releases_directors', (table) => {
|
2019-09-08 01:53:09 +00:00
|
|
|
table.integer('release_id', 16)
|
2019-07-06 03:29:12 +00:00
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases');
|
|
|
|
|
|
|
|
table.integer('director_id', 8)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('directors');
|
2019-11-19 03:36:15 +00:00
|
|
|
|
|
|
|
table.unique(['release_id', 'director_id']);
|
2019-07-06 03:29:12 +00:00
|
|
|
}))
|
2019-12-19 01:35:07 +00:00
|
|
|
.then(() => knex.schema.createTable('releases_posters', (table) => {
|
|
|
|
table.integer('release_id', 16)
|
2019-03-25 02:57:33 +00:00
|
|
|
.notNullable()
|
2019-09-08 01:53:09 +00:00
|
|
|
.references('id')
|
2019-12-19 01:35:07 +00:00
|
|
|
.inTable('releases');
|
2019-03-25 02:57:33 +00:00
|
|
|
|
2019-12-19 01:35:07 +00:00
|
|
|
table.integer('media_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
2019-11-19 03:36:15 +00:00
|
|
|
|
2019-12-19 01:35:07 +00:00
|
|
|
table.unique('release_id');
|
2019-12-15 04:42:51 +00:00
|
|
|
}))
|
2019-12-31 02:12:52 +00:00
|
|
|
.then(() => knex.schema.createTable('releases_covers', (table) => {
|
|
|
|
table.integer('release_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases');
|
|
|
|
|
|
|
|
table.integer('media_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
|
|
|
table.unique(['release_id', 'media_id']);
|
|
|
|
}))
|
2019-12-19 03:42:50 +00:00
|
|
|
.then(() => knex.schema.createTable('releases_trailers', (table) => {
|
|
|
|
table.integer('release_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases');
|
|
|
|
|
|
|
|
table.integer('media_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
|
|
|
table.unique('release_id');
|
|
|
|
}))
|
2020-02-02 04:14:58 +00:00
|
|
|
.then(() => knex.schema.createTable('releases_teasers', (table) => {
|
|
|
|
table.integer('release_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases');
|
|
|
|
|
|
|
|
table.integer('media_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
|
|
|
|
|
|
|
table.unique('release_id');
|
|
|
|
}))
|
2019-12-19 01:35:07 +00:00
|
|
|
.then(() => knex.schema.createTable('releases_photos', (table) => {
|
|
|
|
table.integer('release_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases');
|
2019-12-15 04:42:51 +00:00
|
|
|
|
2019-12-19 01:35:07 +00:00
|
|
|
table.integer('media_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('media');
|
2019-12-16 01:39:13 +00:00
|
|
|
|
2019-12-19 01:35:07 +00:00
|
|
|
table.unique(['release_id', 'media_id']);
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('releases_tags', (table) => {
|
|
|
|
table.integer('tag_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('tags');
|
2019-12-16 01:39:13 +00:00
|
|
|
|
2019-12-19 01:35:07 +00:00
|
|
|
table.integer('release_id', 16)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases');
|
2019-12-16 04:30:25 +00:00
|
|
|
|
2019-12-19 01:35:07 +00:00
|
|
|
table.unique(['tag_id', 'release_id']);
|
|
|
|
}))
|
2020-02-26 21:33:15 +00:00
|
|
|
.then(() => knex.schema.createTable('releases_search', (table) => {
|
|
|
|
table.integer('release_id', 16)
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases');
|
|
|
|
}))
|
2019-12-19 01:35:07 +00:00
|
|
|
.then(() => knex.raw(`
|
2020-02-26 21:33:15 +00:00
|
|
|
ALTER TABLE releases_search
|
|
|
|
ADD COLUMN document tsvector;
|
|
|
|
|
2020-02-29 21:47:48 +00:00
|
|
|
CREATE TEXT SEARCH DICTIONARY traxxx_dict (
|
2020-02-29 04:00:50 +00:00
|
|
|
TEMPLATE = pg_catalog.simple,
|
|
|
|
stopwords = traxxx
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TEXT SEARCH CONFIGURATION traxxx (
|
|
|
|
COPY = english
|
|
|
|
);
|
|
|
|
|
2020-02-29 21:47:48 +00:00
|
|
|
ALTER TEXT SEARCH CONFIGURATION traxxx
|
2020-03-02 03:19:52 +00:00
|
|
|
ALTER MAPPING FOR word, numword, hword, numhword, hword_part, hword_numpart, asciiword, asciihword, hword_asciipart WITH traxxx_dict, simple, english_stem;
|
2020-02-29 21:47:48 +00:00
|
|
|
|
2020-02-26 21:33:15 +00:00
|
|
|
CREATE UNIQUE INDEX releases_search_unique ON releases_search (release_id);
|
|
|
|
CREATE INDEX releases_search_index ON releases_search USING GIN (document);
|
|
|
|
|
2020-02-29 21:47:48 +00:00
|
|
|
CREATE FUNCTION search_releases(query text) RETURNS SETOF releases_search AS $$
|
|
|
|
SELECT * FROM releases_search AS search
|
2020-02-29 22:57:45 +00:00
|
|
|
WHERE search.document @@ plainto_tsquery('traxxx', regexp_replace(query, '\\.|-|(XXX\\.[\\d+|hd|sd].*$)', ' ', 'ig'))
|
|
|
|
ORDER BY ts_rank(search.document, plainto_tsquery('traxxx', regexp_replace(query, '\\.|-|(XXX\\.[\\d+|hd|sd].*$)', ' ', 'ig'))) DESC;
|
2020-02-29 21:47:48 +00:00
|
|
|
$$ LANGUAGE SQL STABLE;
|
2020-01-04 01:51:58 +00:00
|
|
|
|
2020-02-15 00:10:32 +00:00
|
|
|
CREATE FUNCTION search_sites(search text) RETURNS SETOF sites AS $$
|
2020-02-26 21:33:15 +00:00
|
|
|
SELECT * FROM sites
|
|
|
|
WHERE
|
|
|
|
name ILIKE ('%' || search || '%') OR
|
|
|
|
slug ILIKE ('%' || search || '%') OR
|
|
|
|
url ILIKE ('%' || search || '%')
|
|
|
|
$$ LANGUAGE SQL STABLE;
|
|
|
|
|
2020-03-02 02:41:41 +00:00
|
|
|
CREATE FUNCTION releases_is_new(release releases) RETURNS boolean AS $$
|
|
|
|
SELECT NOT EXISTS(SELECT true FROM batches WHERE batches.id = release.created_batch_id + 1 LIMIT 1);
|
|
|
|
$$ LANGUAGE sql STABLE;
|
|
|
|
|
2020-03-09 04:06:37 +00:00
|
|
|
CREATE VIEW movie_actors AS
|
|
|
|
SELECT releases_movies.movie_id, releases_actors.actor_id FROM releases_movies
|
|
|
|
LEFT JOIN releases ON releases.id = releases_movies.scene_id
|
|
|
|
LEFT JOIN releases_actors ON releases_actors.release_id = releases.id
|
|
|
|
GROUP BY movie_id, actor_id;
|
|
|
|
|
2020-03-09 15:54:45 +00:00
|
|
|
CREATE VIEW movie_tags AS
|
|
|
|
SELECT releases_movies.movie_id, releases_tags.tag_id FROM releases_movies
|
|
|
|
LEFT JOIN releases ON releases.id = releases_movies.scene_id
|
|
|
|
LEFT JOIN releases_tags ON releases_tags.release_id = releases.id
|
|
|
|
GROUP BY movie_id, tag_id;
|
|
|
|
|
2020-03-09 04:06:37 +00:00
|
|
|
COMMENT ON VIEW movie_actors IS E'@foreignKey (movie_id) references releases (id)\n@foreignKey (actor_id) references actors (id)';
|
2020-03-09 15:54:45 +00:00
|
|
|
COMMENT ON VIEW movie_tags IS E'@foreignKey (movie_id) references releases (id)\n@foreignKey (tag_id) references tags (id)';
|
2020-03-09 04:06:37 +00:00
|
|
|
|
2020-02-29 21:47:48 +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';
|
2019-12-15 04:42:51 +00:00
|
|
|
`));
|
2019-03-25 02:57:33 +00:00
|
|
|
|
2019-12-19 01:35:07 +00:00
|
|
|
exports.down = knex => knex.raw(`
|
|
|
|
DROP FUNCTION IF EXISTS releases_by_tag_slugs;
|
2020-02-15 00:13:10 +00:00
|
|
|
DROP FUNCTION IF EXISTS search_sites;
|
2019-12-19 01:35:07 +00:00
|
|
|
|
2020-03-09 04:06:37 +00:00
|
|
|
DROP VIEW IF EXISTS movie_actors;
|
2020-03-09 15:54:45 +00:00
|
|
|
DROP VIEW IF EXISTS movie_tags;
|
2019-12-19 03:42:50 +00:00
|
|
|
|
2019-12-19 01:35:07 +00:00
|
|
|
DROP TABLE IF EXISTS releases_actors CASCADE;
|
2020-03-09 04:06:37 +00:00
|
|
|
DROP TABLE IF EXISTS releases_movies CASCADE;
|
2019-12-19 01:35:07 +00:00
|
|
|
DROP TABLE IF EXISTS releases_directors CASCADE;
|
|
|
|
DROP TABLE IF EXISTS releases_posters CASCADE;
|
|
|
|
DROP TABLE IF EXISTS releases_photos CASCADE;
|
2019-12-31 02:12:52 +00:00
|
|
|
DROP TABLE IF EXISTS releases_covers CASCADE;
|
2019-12-19 03:42:50 +00:00
|
|
|
DROP TABLE IF EXISTS releases_trailers CASCADE;
|
2020-02-02 04:14:58 +00:00
|
|
|
DROP TABLE IF EXISTS releases_teasers CASCADE;
|
2019-12-19 01:35:07 +00:00
|
|
|
DROP TABLE IF EXISTS releases_tags CASCADE;
|
2020-02-26 21:33:15 +00:00
|
|
|
DROP TABLE IF EXISTS releases_search CASCADE;
|
2020-03-02 02:41:41 +00:00
|
|
|
DROP TABLE IF EXISTS batches CASCADE;
|
2019-12-19 01:35:07 +00:00
|
|
|
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 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;
|
|
|
|
DROP TABLE IF EXISTS releases CASCADE;
|
|
|
|
DROP TABLE IF EXISTS actors CASCADE;
|
|
|
|
DROP TABLE IF EXISTS directors 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 CASCADE;
|
|
|
|
DROP TABLE IF EXISTS countries CASCADE;
|
|
|
|
DROP TABLE IF EXISTS networks CASCADE;
|
2020-02-29 04:00:50 +00:00
|
|
|
|
|
|
|
DROP TEXT SEARCH CONFIGURATION IF EXISTS traxxx;
|
2020-02-29 21:47:48 +00:00
|
|
|
DROP TEXT SEARCH DICTIONARY IF EXISTS traxxx_dict;
|
2019-12-19 01:35:07 +00:00
|
|
|
`);
|