Refactored various modules for entities. Updated and refactored Kink scraper.
This commit is contained in:
@@ -141,8 +141,8 @@ exports.up = knex => Promise.resolve()
|
||||
table.unique(['tag_id', 'media_id']);
|
||||
}))
|
||||
.then(() => knex.schema.createTable('entities_types', (table) => {
|
||||
table.increments('id', 4);
|
||||
table.text('type');
|
||||
table.text('type')
|
||||
.primary();
|
||||
}))
|
||||
.then(() => knex('entities_types').insert([
|
||||
{ type: 'network' },
|
||||
@@ -160,10 +160,11 @@ exports.up = knex => Promise.resolve()
|
||||
table.text('name');
|
||||
table.text('slug', 32);
|
||||
|
||||
table.integer('type', 4)
|
||||
.references('id')
|
||||
table.text('type')
|
||||
.notNullable()
|
||||
.references('type')
|
||||
.inTable('entities_types')
|
||||
.defaultTo(2);
|
||||
.defaultTo('channel');
|
||||
|
||||
table.unique(['slug', 'type']);
|
||||
|
||||
@@ -196,114 +197,18 @@ exports.up = knex => Promise.resolve()
|
||||
|
||||
table.unique(['tag_id', 'entity_id']);
|
||||
}))
|
||||
.then(() => knex.schema.createTable('networks', (table) => {
|
||||
table.increments('id', 12);
|
||||
|
||||
table.text('name');
|
||||
table.text('alias');
|
||||
table.text('url');
|
||||
table.text('description');
|
||||
table.json('parameters');
|
||||
|
||||
table.integer('parent_id', 12)
|
||||
.references('id')
|
||||
.inTable('networks');
|
||||
|
||||
table.text('slug', 32)
|
||||
.unique();
|
||||
|
||||
table.datetime('created_at')
|
||||
.defaultTo(knex.fn.now());
|
||||
}))
|
||||
.then(() => knex.schema.createTable('networks_social', (table) => {
|
||||
.then(() => knex.schema.createTable('entities_social', (table) => {
|
||||
table.increments('id', 16);
|
||||
|
||||
table.text('url');
|
||||
table.text('platform');
|
||||
|
||||
table.integer('network_id', 12)
|
||||
table.integer('entity_id', 12)
|
||||
.notNullable()
|
||||
.references('id')
|
||||
.inTable('networks');
|
||||
.inTable('entities');
|
||||
|
||||
table.unique(['url', 'network_id']);
|
||||
|
||||
table.datetime('created_at')
|
||||
.defaultTo(knex.fn.now());
|
||||
}))
|
||||
.then(() => knex.schema.createTable('sites', (table) => {
|
||||
table.increments('id', 12);
|
||||
|
||||
table.integer('network_id', 12)
|
||||
.notNullable()
|
||||
.references('id')
|
||||
.inTable('networks');
|
||||
|
||||
table.text('name');
|
||||
table.text('slug', 32)
|
||||
.unique();
|
||||
|
||||
table.text('alias');
|
||||
|
||||
table.text('url');
|
||||
table.text('description');
|
||||
table.json('parameters');
|
||||
|
||||
table.integer('priority', 3)
|
||||
.defaultTo(0);
|
||||
|
||||
table.boolean('show')
|
||||
.defaultTo(true);
|
||||
|
||||
table.datetime('created_at')
|
||||
.defaultTo(knex.fn.now());
|
||||
}))
|
||||
.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');
|
||||
|
||||
table.boolean('inherit')
|
||||
.defaultTo(false);
|
||||
|
||||
table.unique(['tag_id', 'site_id']);
|
||||
}))
|
||||
.then(() => knex.schema.createTable('sites_social', (table) => {
|
||||
table.increments('id', 16);
|
||||
|
||||
table.text('url');
|
||||
table.text('platform');
|
||||
|
||||
table.integer('site_id', 12)
|
||||
.notNullable()
|
||||
.references('id')
|
||||
.inTable('sites');
|
||||
|
||||
table.unique(['url', 'site_id']);
|
||||
|
||||
table.datetime('created_at')
|
||||
.defaultTo(knex.fn.now());
|
||||
}))
|
||||
.then(() => knex.schema.createTable('studios', (table) => {
|
||||
table.increments('id', 12);
|
||||
|
||||
table.integer('network_id', 12)
|
||||
.notNullable()
|
||||
.references('id')
|
||||
.inTable('networks');
|
||||
|
||||
table.text('name');
|
||||
table.text('url');
|
||||
table.text('description');
|
||||
|
||||
table.text('slug', 32)
|
||||
.unique();
|
||||
table.unique(['url', 'entity_id']);
|
||||
|
||||
table.datetime('created_at')
|
||||
.defaultTo(knex.fn.now());
|
||||
@@ -683,7 +588,7 @@ exports.up = knex => Promise.resolve()
|
||||
|
||||
table.integer('studio_id', 12)
|
||||
.references('id')
|
||||
.inTable('studios');
|
||||
.inTable('entities');
|
||||
|
||||
table.text('type', 10)
|
||||
.defaultTo('scene');
|
||||
@@ -878,8 +783,8 @@ exports.up = knex => Promise.resolve()
|
||||
);
|
||||
$$ LANGUAGE SQL STABLE;
|
||||
|
||||
CREATE FUNCTION search_sites(search text) RETURNS SETOF sites AS $$
|
||||
SELECT * FROM sites
|
||||
CREATE FUNCTION search_entities(search text) RETURNS SETOF entities AS $$
|
||||
SELECT * FROM entities
|
||||
WHERE
|
||||
name ILIKE ('%' || search || '%') OR
|
||||
slug ILIKE ('%' || search || '%') OR
|
||||
@@ -944,6 +849,7 @@ exports.down = (knex) => { // eslint-disable-line arrow-body-style
|
||||
DROP TABLE IF EXISTS body CASCADE;
|
||||
|
||||
DROP TABLE IF EXISTS entities_tags CASCADE;
|
||||
DROP TABLE IF EXISTS entities_social CASCADE;
|
||||
DROP TABLE IF EXISTS sites_tags CASCADE;
|
||||
DROP TABLE IF EXISTS sites_social CASCADE;
|
||||
DROP TABLE IF EXISTS networks_social CASCADE;
|
||||
@@ -966,6 +872,7 @@ exports.down = (knex) => { // eslint-disable-line arrow-body-style
|
||||
DROP TABLE IF EXISTS entities CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS search_sites;
|
||||
DROP FUNCTION IF EXISTS search_entities;
|
||||
DROP FUNCTION IF EXISTS search_actors;
|
||||
DROP FUNCTION IF EXISTS get_random_sfw_media_id;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user