forked from DebaucheryLibrarian/traxxx
309 lines
8.4 KiB
JavaScript
309 lines
8.4 KiB
JavaScript
exports.up = knex => Promise.resolve()
|
|
.then(() => knex.schema.createTable('countries', (table) => {
|
|
table.string('alpha2', 2)
|
|
.unique()
|
|
.primary();
|
|
|
|
table.string('alpha3', 3)
|
|
.unique();
|
|
|
|
table.string('name')
|
|
.notNullable();
|
|
|
|
table.string('alias');
|
|
|
|
table.integer('code', 3);
|
|
table.string('nationality');
|
|
table.integer('priority', 2)
|
|
.defaultTo(0);
|
|
}))
|
|
.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('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());
|
|
}))
|
|
.then(() => knex.schema.createTable('tags_groups', (table) => {
|
|
table.increments('id', 12);
|
|
|
|
table.string('name', 32);
|
|
table.text('description');
|
|
|
|
table.string('slug', 32)
|
|
.unique();
|
|
|
|
table.datetime('created_at')
|
|
.defaultTo(knex.fn.now());
|
|
}))
|
|
.then(() => knex.schema.createTable('tags', (table) => {
|
|
table.increments('id', 12);
|
|
table.string('name');
|
|
|
|
table.text('description');
|
|
|
|
table.integer('priority', 2)
|
|
.defaultTo(0);
|
|
|
|
table.integer('group_id', 12)
|
|
.references('id')
|
|
.inTable('tags_groups');
|
|
|
|
table.integer('alias_for', 12)
|
|
.references('id')
|
|
.inTable('tags');
|
|
|
|
table.string('slug', 32)
|
|
.unique();
|
|
|
|
table.datetime('created_at')
|
|
.defaultTo(knex.fn.now());
|
|
}))
|
|
.then(() => knex.schema.createTable('networks', (table) => {
|
|
table.increments('id', 12);
|
|
|
|
table.string('name');
|
|
table.string('url');
|
|
table.text('description');
|
|
table.string('parameters');
|
|
|
|
table.string('slug', 32)
|
|
.unique();
|
|
|
|
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.string('name');
|
|
table.string('url');
|
|
table.text('description');
|
|
table.string('parameters');
|
|
|
|
table.string('slug', 32)
|
|
.unique();
|
|
|
|
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.string('name');
|
|
table.string('url');
|
|
table.text('description');
|
|
|
|
table.string('slug', 32)
|
|
.unique();
|
|
|
|
table.datetime('created_at')
|
|
.defaultTo(knex.fn.now());
|
|
}))
|
|
.then(() => knex.schema.createTable('releases', (table) => {
|
|
table.increments('id', 16);
|
|
|
|
table.integer('site_id', 12)
|
|
.notNullable()
|
|
.references('id')
|
|
.inTable('sites');
|
|
|
|
table.integer('studio_id', 12)
|
|
.references('id')
|
|
.inTable('studios');
|
|
|
|
table.string('shoot_id');
|
|
table.string('entry_id');
|
|
table.unique(['site_id', 'entry_id']);
|
|
|
|
table.string('url', 1000);
|
|
table.string('title');
|
|
table.date('date');
|
|
table.text('description');
|
|
|
|
table.integer('director', 12)
|
|
.references('id')
|
|
.inTable('directors');
|
|
|
|
table.integer('duration')
|
|
.unsigned();
|
|
|
|
table.integer('likes')
|
|
.unsigned();
|
|
|
|
table.integer('dislikes')
|
|
.unsigned();
|
|
|
|
table.float('rating', 2)
|
|
.unsigned();
|
|
|
|
table.boolean('deep');
|
|
|
|
table.datetime('created_at')
|
|
.defaultTo(knex.fn.now());
|
|
}))
|
|
.then(() => knex.schema.createTable('media', (table) => {
|
|
table.increments('id', 16);
|
|
|
|
table.string('path');
|
|
table.string('thumbnail');
|
|
table.integer('index');
|
|
table.string('mime');
|
|
|
|
table.string('domain');
|
|
table.integer('target_id', 16);
|
|
|
|
table.string('role');
|
|
table.string('quality', 6);
|
|
|
|
table.string('hash');
|
|
table.text('comment');
|
|
table.string('source', 1000);
|
|
|
|
table.unique(['domain', 'target_id', 'role', 'hash']);
|
|
|
|
table.datetime('created_at')
|
|
.defaultTo(knex.fn.now());
|
|
}))
|
|
.then(() => knex.schema.createTable('social', (table) => {
|
|
table.increments('id', 16);
|
|
|
|
table.string('url');
|
|
table.string('platform');
|
|
|
|
table.string('domain');
|
|
table.integer('target_id', 16);
|
|
|
|
table.unique(['url', 'domain', 'target_id']);
|
|
|
|
table.datetime('created_at')
|
|
.defaultTo(knex.fn.now());
|
|
}))
|
|
.then(() => knex.schema.createTable('actors_associated', (table) => {
|
|
table.increments('id', 16);
|
|
|
|
table.integer('release_id', 16)
|
|
.notNullable()
|
|
.references('id')
|
|
.inTable('releases');
|
|
|
|
table.integer('actor_id', 8)
|
|
.notNullable()
|
|
.references('id')
|
|
.inTable('actors');
|
|
|
|
table.unique(['release_id', 'actor_id']);
|
|
}))
|
|
.then(() => knex.schema.createTable('directors_associated', (table) => {
|
|
table.increments('id', 16);
|
|
|
|
table.integer('release_id', 16)
|
|
.notNullable()
|
|
.references('id')
|
|
.inTable('releases');
|
|
|
|
table.integer('director_id', 8)
|
|
.notNullable()
|
|
.references('id')
|
|
.inTable('directors');
|
|
|
|
table.unique(['release_id', 'director_id']);
|
|
}))
|
|
.then(() => knex.schema.createTable('tags_associated', (table) => {
|
|
table.integer('tag_id', 12)
|
|
.notNullable()
|
|
.references('id')
|
|
.inTable('tags');
|
|
|
|
table.string('domain');
|
|
table.integer('target_id', 16);
|
|
|
|
table.unique(['domain', 'tag_id', 'target_id']);
|
|
}));
|
|
|
|
exports.down = knex => Promise.resolve()
|
|
.then(() => knex.schema.dropTable('tags_associated'))
|
|
.then(() => knex.schema.dropTable('directors_associated'))
|
|
.then(() => knex.schema.dropTable('actors_associated'))
|
|
.then(() => knex.schema.dropTable('tags'))
|
|
.then(() => knex.schema.dropTable('tags_groups'))
|
|
.then(() => knex.schema.dropTable('media'))
|
|
.then(() => knex.schema.dropTable('social'))
|
|
.then(() => knex.schema.dropTable('actors'))
|
|
.then(() => knex.schema.dropTable('releases'))
|
|
.then(() => knex.schema.dropTable('sites'))
|
|
.then(() => knex.schema.dropTable('studios'))
|
|
.then(() => knex.schema.dropTable('directors'))
|
|
.then(() => knex.schema.dropTable('networks'))
|
|
.then(() => knex.schema.dropTable('countries'));
|