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, actor_ids multi, actors text, tag_ids multi, tags text, meta text, date timestamp, 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, 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, weight int, height int, cup string, natural_boobs int, penis_length int, penis_girth int, stashed int, scenes int `; exports.up = async (knex) => { await utilsApi.sql(`create table scenes (${scenesFields})`); /* await utilsApi.sql(`create table scenes_stashed ( ${scenesFields}, user_id int, stash_id int )`); */ await utilsApi.sql(`create table scenes_stashed ( scene_id int, stash_id int, user_id int )`); await utilsApi.sql(`create table movies (${moviesFields})`); await utilsApi.sql(`create table movies_stashed ( ${moviesFields}, user_id int, stash_id int )`); await utilsApi.sql(`create table actors (${actorsFields})`); await utilsApi.sql(`create table actors_stashed ( ${actorsFields}, user_id int, stash_id int )`); 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')); }; 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')); };