130 lines
3.1 KiB
JavaScript
130 lines
3.1 KiB
JavaScript
const config = require('config');
|
|
const manticore = require('manticoresearch');
|
|
|
|
const mantiClient = new manticore.ApiClient();
|
|
|
|
mantiClient.basePath = `http://${config.database.manticore.host}:${config.database.manticore.httpPort}`;
|
|
|
|
const utilsApi = new manticore.UtilsApi(mantiClient);
|
|
|
|
const scenesFields = `
|
|
id int,
|
|
title text,
|
|
title_filtered text,
|
|
shoot_id text,
|
|
channel_id int,
|
|
channel_name text,
|
|
channel_slug text,
|
|
network_id int,
|
|
network_name text,
|
|
network_slug text,
|
|
entity_ids multi,
|
|
actor_ids multi,
|
|
actors text,
|
|
tag_ids multi,
|
|
tags text,
|
|
movie_ids multi,
|
|
serie_ids multi,
|
|
meta text,
|
|
date timestamp,
|
|
is_showcased bool,
|
|
created_at timestamp,
|
|
effective_date timestamp,
|
|
stashed int
|
|
`;
|
|
|
|
const moviesFields = `
|
|
id int,
|
|
title text,
|
|
title_filtered text,
|
|
channel_id int,
|
|
channel_name text,
|
|
channel_slug text,
|
|
network_id int,
|
|
network_name text,
|
|
network_slug text,
|
|
entity_ids multi,
|
|
actor_ids multi,
|
|
actors text,
|
|
tag_ids multi,
|
|
tags text,
|
|
meta text,
|
|
date timestamp,
|
|
has_cover bool,
|
|
created_at timestamp,
|
|
effective_date timestamp,
|
|
stashed int,
|
|
stashed_scenes int,
|
|
stashed_total int
|
|
`;
|
|
|
|
const actorsFields = `
|
|
id int,
|
|
name text,
|
|
slug string,
|
|
gender string,
|
|
date_of_birth timestamp,
|
|
country string,
|
|
has_avatar bool,
|
|
mass int,
|
|
height int,
|
|
cup string,
|
|
natural_boobs int,
|
|
penis_length int,
|
|
penis_girth int,
|
|
stashed int,
|
|
scenes int
|
|
`;
|
|
|
|
exports.up = async (knex) => {
|
|
try {
|
|
await utilsApi.sql(`create table scenes (${scenesFields})`);
|
|
|
|
await utilsApi.sql(`create table scenes_stashed (
|
|
scene_id int,
|
|
stash_id int,
|
|
user_id int,
|
|
created_at timestamp
|
|
)`);
|
|
|
|
await utilsApi.sql(`create table movies (${moviesFields})`);
|
|
|
|
await utilsApi.sql(`create table movies_stashed (
|
|
movie_id int,
|
|
stash_id int,
|
|
user_id int,
|
|
created_at timestamp
|
|
)`);
|
|
|
|
await utilsApi.sql(`create table actors (${actorsFields}) min_prefix_len='3'`);
|
|
|
|
await utilsApi.sql(`create table actors_stashed (
|
|
actor_id int,
|
|
stash_id int,
|
|
user_id int,
|
|
created_at timestamp
|
|
)`);
|
|
|
|
await knex.schema.alterTable('stashes_scenes', (table) => table.increments('id'));
|
|
await knex.schema.alterTable('stashes_movies', (table) => table.increments('id'));
|
|
await knex.schema.alterTable('stashes_actors', (table) => table.increments('id'));
|
|
await knex.schema.alterTable('stashes_series', (table) => table.increments('id'));
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
};
|
|
|
|
exports.down = async (knex) => {
|
|
await utilsApi.sql('drop table if exists scenes');
|
|
await utilsApi.sql('drop table if exists scenes_stashed');
|
|
await utilsApi.sql('drop table if exists movies');
|
|
await utilsApi.sql('drop table if exists movies_stashed');
|
|
await utilsApi.sql('drop table if exists actors');
|
|
await utilsApi.sql('drop table if exists actors_stashed');
|
|
|
|
await knex.schema.alterTable('stashes_scenes', (table) => table.dropColumn('id'));
|
|
await knex.schema.alterTable('stashes_movies', (table) => table.dropColumn('id'));
|
|
await knex.schema.alterTable('stashes_actors', (table) => table.dropColumn('id'));
|
|
await knex.schema.alterTable('stashes_series', (table) => table.dropColumn('id'));
|
|
};
|