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-03-25 02:57:33 +00:00
|
|
|
.then(() => knex.schema.createTable('actors', (table) => {
|
2019-09-08 01:53:09 +00:00
|
|
|
table.increments('id', 12);
|
2019-03-25 02:57:33 +00:00
|
|
|
|
2019-05-06 00:01:57 +00:00
|
|
|
table.string('name')
|
|
|
|
.unique()
|
|
|
|
.notNullable();
|
2019-11-10 03:20:22 +00:00
|
|
|
|
|
|
|
table.date('birthdate');
|
2019-11-17 02:56:45 +00:00
|
|
|
table.string('gender', 18);
|
2019-11-20 03:53:36 +00:00
|
|
|
table.text('description');
|
2019-11-17 02:56:45 +00:00
|
|
|
|
2019-11-29 04:46:06 +00:00
|
|
|
table.string('birth_city');
|
|
|
|
table.string('birth_state');
|
2019-11-17 02:56:45 +00:00
|
|
|
table.string('birth_country_alpha2', 2)
|
|
|
|
.references('alpha2')
|
|
|
|
.inTable('countries');
|
|
|
|
|
2019-11-29 04:46:06 +00:00
|
|
|
table.string('residence_city');
|
|
|
|
table.string('residence_state');
|
2019-11-17 02:56:45 +00:00
|
|
|
table.string('residence_country_alpha2', 2)
|
|
|
|
.references('alpha2')
|
|
|
|
.inTable('countries');
|
|
|
|
|
2019-11-29 04:46:06 +00:00
|
|
|
table.string('ethnicity');
|
2019-11-17 02:56:45 +00:00
|
|
|
|
2019-11-21 03:05:32 +00:00
|
|
|
table.string('bust', 10);
|
|
|
|
table.integer('waist', 3);
|
|
|
|
table.integer('hip', 3);
|
|
|
|
table.boolean('natural_boobs');
|
2019-04-06 21:24:26 +00:00
|
|
|
|
2019-11-20 03:53:36 +00:00
|
|
|
table.integer('height', 3);
|
|
|
|
table.integer('weight', 3);
|
|
|
|
table.string('eyes');
|
2019-11-17 02:56:45 +00:00
|
|
|
table.string('hair');
|
|
|
|
|
2019-11-20 03:53:36 +00:00
|
|
|
table.boolean('has_tattoos');
|
|
|
|
table.boolean('has_piercings');
|
|
|
|
table.string('piercings');
|
|
|
|
table.string('tattoos');
|
2019-11-17 02:56:45 +00:00
|
|
|
|
2019-09-08 01:53:09 +00:00
|
|
|
table.integer('alias_for', 12)
|
2019-03-25 02:57:33 +00:00
|
|
|
.references('id')
|
|
|
|
.inTable('actors');
|
2019-07-06 03:29:12 +00:00
|
|
|
|
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-11-19 03:36:15 +00:00
|
|
|
|
|
|
|
table.datetime('scraped_at');
|
|
|
|
table.boolean('scrape_success');
|
2019-03-25 02:57:33 +00:00
|
|
|
}))
|
2019-04-04 02:00:28 +00:00
|
|
|
.then(() => knex.schema.createTable('directors', (table) => {
|
2019-09-08 01:53:09 +00:00
|
|
|
table.increments('id', 12);
|
2019-04-04 02:00:28 +00:00
|
|
|
|
|
|
|
table.string('name');
|
2019-09-08 01:53:09 +00:00
|
|
|
table.integer('alias_for', 12)
|
2019-04-04 02:00:28 +00:00
|
|
|
.references('id')
|
|
|
|
.inTable('directors');
|
2019-07-06 03:29:12 +00:00
|
|
|
|
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-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);
|
|
|
|
|
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
|
|
|
}))
|
|
|
|
.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');
|
2019-11-04 04:47:37 +00:00
|
|
|
table.string('parameters');
|
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
|
|
|
}))
|
|
|
|
.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');
|
|
|
|
table.string('url');
|
2019-05-06 00:01:57 +00:00
|
|
|
table.text('description');
|
2019-03-26 00:26:47 +00:00
|
|
|
table.string('parameters');
|
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-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-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');
|
|
|
|
|
2019-12-11 04:15:23 +00:00
|
|
|
table.string('type', 10);
|
|
|
|
|
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');
|
|
|
|
table.date('date');
|
|
|
|
table.text('description');
|
|
|
|
|
2019-09-08 01:53:09 +00:00
|
|
|
table.integer('director', 12)
|
2019-04-04 02:00:28 +00:00
|
|
|
.references('id')
|
|
|
|
.inTable('directors');
|
|
|
|
|
2019-03-25 02:57:33 +00:00
|
|
|
table.integer('duration')
|
|
|
|
.unsigned();
|
|
|
|
|
2019-12-11 04:15:23 +00:00
|
|
|
table.integer('parent', 16)
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases');
|
2019-05-06 00:01:57 +00:00
|
|
|
|
2019-09-26 01:27:01 +00:00
|
|
|
table.boolean('deep');
|
|
|
|
|
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-09-08 01:53:09 +00:00
|
|
|
.then(() => knex.schema.createTable('media', (table) => {
|
|
|
|
table.increments('id', 16);
|
|
|
|
|
2019-09-25 02:52:58 +00:00
|
|
|
table.string('path');
|
2019-11-11 02:20:00 +00:00
|
|
|
table.string('thumbnail');
|
2019-09-08 01:53:09 +00:00
|
|
|
table.integer('index');
|
|
|
|
table.string('mime');
|
|
|
|
|
2019-11-12 00:22:20 +00:00
|
|
|
table.string('domain');
|
2019-09-08 01:53:09 +00:00
|
|
|
table.integer('target_id', 16);
|
|
|
|
|
2019-11-12 00:22:20 +00:00
|
|
|
table.string('role');
|
2019-09-25 02:52:58 +00:00
|
|
|
table.string('quality', 6);
|
2019-11-12 00:22:20 +00:00
|
|
|
|
|
|
|
table.string('hash');
|
2019-12-04 20:58:08 +00:00
|
|
|
table.text('comment');
|
2019-11-12 00:22:20 +00:00
|
|
|
table.string('source', 1000);
|
|
|
|
|
2019-11-20 03:53:36 +00:00
|
|
|
table.unique(['domain', 'target_id', 'role', 'hash']);
|
|
|
|
|
2019-11-12 00:22:20 +00:00
|
|
|
table.datetime('created_at')
|
|
|
|
.defaultTo(knex.fn.now());
|
2019-09-08 01:53:09 +00:00
|
|
|
}))
|
2019-11-27 03:58:38 +00:00
|
|
|
.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());
|
|
|
|
}))
|
2019-03-25 02:57:33 +00:00
|
|
|
.then(() => knex.schema.createTable('actors_associated', (table) => {
|
|
|
|
table.increments('id', 16);
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
table.integer('actor_id', 8)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('actors');
|
2019-11-19 03:36:15 +00:00
|
|
|
|
|
|
|
table.unique(['release_id', 'actor_id']);
|
2019-03-25 02:57:33 +00:00
|
|
|
}))
|
2019-07-06 03:29:12 +00:00
|
|
|
.then(() => knex.schema.createTable('directors_associated', (table) => {
|
|
|
|
table.increments('id', 16);
|
|
|
|
|
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-03-25 02:57:33 +00:00
|
|
|
.then(() => knex.schema.createTable('tags_associated', (table) => {
|
2019-09-08 01:53:09 +00:00
|
|
|
table.integer('tag_id', 12)
|
2019-03-25 02:57:33 +00:00
|
|
|
.notNullable()
|
2019-09-08 01:53:09 +00:00
|
|
|
.references('id')
|
2019-03-25 02:57:33 +00:00
|
|
|
.inTable('tags');
|
|
|
|
|
2019-12-07 03:41:16 +00:00
|
|
|
table.string('domain');
|
|
|
|
table.integer('target_id', 16);
|
2019-11-19 03:36:15 +00:00
|
|
|
|
2019-12-07 03:41:16 +00:00
|
|
|
table.unique(['domain', 'tag_id', 'target_id']);
|
2019-03-25 02:57:33 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
exports.down = knex => Promise.resolve()
|
|
|
|
.then(() => knex.schema.dropTable('tags_associated'))
|
2019-07-06 03:29:12 +00:00
|
|
|
.then(() => knex.schema.dropTable('directors_associated'))
|
2019-03-25 02:57:33 +00:00
|
|
|
.then(() => knex.schema.dropTable('actors_associated'))
|
2019-05-06 00:01:57 +00:00
|
|
|
.then(() => knex.schema.dropTable('tags'))
|
|
|
|
.then(() => knex.schema.dropTable('tags_groups'))
|
2019-09-08 01:53:09 +00:00
|
|
|
.then(() => knex.schema.dropTable('media'))
|
2019-11-27 03:58:38 +00:00
|
|
|
.then(() => knex.schema.dropTable('social'))
|
2019-05-06 00:01:57 +00:00
|
|
|
.then(() => knex.schema.dropTable('actors'))
|
2019-03-25 02:57:33 +00:00
|
|
|
.then(() => knex.schema.dropTable('releases'))
|
|
|
|
.then(() => knex.schema.dropTable('sites'))
|
2019-10-30 03:45:42 +00:00
|
|
|
.then(() => knex.schema.dropTable('studios'))
|
2019-04-06 21:24:26 +00:00
|
|
|
.then(() => knex.schema.dropTable('directors'))
|
2019-11-17 02:56:45 +00:00
|
|
|
.then(() => knex.schema.dropTable('networks'))
|
|
|
|
.then(() => knex.schema.dropTable('countries'));
|