2019-03-25 02:57:33 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
exports.up = knex => Promise.resolve()
|
|
|
|
.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-04-06 21:24:26 +00:00
|
|
|
table.string('gender', 18);
|
|
|
|
|
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-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-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-09-08 01:53:09 +00:00
|
|
|
table.string('group', 32);
|
|
|
|
table.string('slug', 32)
|
|
|
|
.unique();
|
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);
|
|
|
|
table.string('tag');
|
2019-05-06 00:01:57 +00:00
|
|
|
|
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-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-09-08 01:53:09 +00:00
|
|
|
|
|
|
|
table.string('slug', 32)
|
|
|
|
.unique();
|
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-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');
|
|
|
|
|
|
|
|
table.string('shoot_id');
|
2019-04-06 21:24:26 +00:00
|
|
|
table.string('entry_id');
|
2019-04-01 00:45:15 +00:00
|
|
|
table.unique(['site_id', 'shoot_id']);
|
2019-04-06 21:24:26 +00:00
|
|
|
table.unique(['site_id', 'entry_id']);
|
2019-04-01 00:45:15 +00:00
|
|
|
|
|
|
|
table.string('url');
|
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();
|
|
|
|
|
|
|
|
table.integer('likes')
|
|
|
|
.unsigned();
|
|
|
|
|
|
|
|
table.integer('dislikes')
|
|
|
|
.unsigned();
|
|
|
|
|
|
|
|
table.integer('rating')
|
|
|
|
.unsigned();
|
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);
|
|
|
|
|
|
|
|
table.string('file');
|
|
|
|
table.integer('index');
|
|
|
|
table.string('mime');
|
|
|
|
|
|
|
|
table.enum('domain', ['networks', 'sites', 'releases', 'actors', 'directors']);
|
|
|
|
table.integer('target_id', 16);
|
|
|
|
|
|
|
|
table.enum('role', ['poster', 'logo', 'profile']);
|
|
|
|
}))
|
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-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-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-09-08 01:53:09 +00:00
|
|
|
table.integer('site_id', 12)
|
2019-03-25 02:57:33 +00:00
|
|
|
.references('id')
|
|
|
|
.inTable('sites');
|
|
|
|
|
2019-09-08 01:53:09 +00:00
|
|
|
table.integer('release_id', 16)
|
2019-03-25 02:57:33 +00:00
|
|
|
.references('id')
|
|
|
|
.inTable('releases');
|
|
|
|
}));
|
|
|
|
|
|
|
|
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-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-04-06 21:24:26 +00:00
|
|
|
.then(() => knex.schema.dropTable('directors'))
|
2019-05-06 00:01:57 +00:00
|
|
|
.then(() => knex.schema.dropTable('networks'));
|