2019-03-25 02:57:33 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
exports.up = knex => Promise.resolve()
|
|
|
|
.then(() => knex.schema.createTable('actors', (table) => {
|
|
|
|
table.increments('id', 8);
|
|
|
|
|
|
|
|
table.string('name');
|
|
|
|
table.integer('alias_for', 8)
|
|
|
|
.references('id')
|
|
|
|
.inTable('actors');
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('tags', (table) => {
|
|
|
|
table.string('tag', 20)
|
|
|
|
.primary();
|
|
|
|
|
|
|
|
table.string('alias_for', 20)
|
|
|
|
.references('tag')
|
|
|
|
.inTable('tags');
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('networks', (table) => {
|
|
|
|
table.string('id', 32)
|
|
|
|
.primary();
|
|
|
|
|
|
|
|
table.string('name');
|
|
|
|
table.string('url');
|
|
|
|
table.string('description');
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('sites', (table) => {
|
|
|
|
table.string('id', 32)
|
|
|
|
.primary();
|
|
|
|
|
|
|
|
table.string('label', 6);
|
|
|
|
|
|
|
|
table.string('network_id', 32)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('networks');
|
|
|
|
|
|
|
|
table.string('name');
|
|
|
|
table.string('url');
|
|
|
|
table.string('description');
|
2019-03-26 00:26:47 +00:00
|
|
|
table.string('parameters');
|
2019-03-25 02:57:33 +00:00
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('releases', (table) => {
|
|
|
|
table.increments('id', 12);
|
|
|
|
|
|
|
|
table.string('site_id', 32)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('sites');
|
|
|
|
|
|
|
|
table.string('shoot_id');
|
|
|
|
table.string('title');
|
|
|
|
table.date('date');
|
|
|
|
table.text('description');
|
|
|
|
|
|
|
|
table.integer('duration')
|
|
|
|
.unsigned();
|
|
|
|
|
|
|
|
table.integer('likes')
|
|
|
|
.unsigned();
|
|
|
|
|
|
|
|
table.integer('dislikes')
|
|
|
|
.unsigned();
|
|
|
|
|
|
|
|
table.integer('rating')
|
|
|
|
.unsigned();
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('actors_associated', (table) => {
|
|
|
|
table.increments('id', 16);
|
|
|
|
|
|
|
|
table.integer('release_id', 12)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases');
|
|
|
|
|
|
|
|
table.integer('actor_id', 8)
|
|
|
|
.notNullable()
|
|
|
|
.references('id')
|
|
|
|
.inTable('actors');
|
|
|
|
}))
|
|
|
|
.then(() => knex.schema.createTable('tags_associated', (table) => {
|
|
|
|
table.string('tag_id', 20)
|
|
|
|
.notNullable()
|
|
|
|
.references('tag')
|
|
|
|
.inTable('tags');
|
|
|
|
|
|
|
|
table.string('site_id')
|
|
|
|
.references('id')
|
|
|
|
.inTable('sites');
|
|
|
|
|
|
|
|
table.string('release_id')
|
|
|
|
.references('id')
|
|
|
|
.inTable('releases');
|
|
|
|
}));
|
|
|
|
|
|
|
|
exports.down = knex => Promise.resolve()
|
|
|
|
.then(() => knex.schema.dropTable('tags_associated'))
|
|
|
|
.then(() => knex.schema.dropTable('actors_associated'))
|
|
|
|
.then(() => knex.schema.dropTable('releases'))
|
|
|
|
.then(() => knex.schema.dropTable('sites'))
|
|
|
|
.then(() => knex.schema.dropTable('networks'))
|
|
|
|
.then(() => knex.schema.dropTable('actors'))
|
|
|
|
.then(() => knex.schema.dropTable('tags'));
|