184 lines
5.3 KiB
JavaScript
184 lines
5.3 KiB
JavaScript
exports.up = knex => Promise.resolve()
|
|
.then(() => knex.schema.createTable('actors', (table) => {
|
|
table.increments('id', 12);
|
|
|
|
table.string('name')
|
|
.unique()
|
|
.notNullable();
|
|
table.string('gender', 18);
|
|
|
|
table.integer('alias_for', 12)
|
|
.references('id')
|
|
.inTable('actors');
|
|
|
|
table.string('slug', 32)
|
|
.unique();
|
|
}))
|
|
.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();
|
|
}))
|
|
.then(() => knex.schema.createTable('tags_groups', (table) => {
|
|
table.increments('id', 12);
|
|
|
|
table.string('group', 32);
|
|
table.string('slug', 32)
|
|
.unique();
|
|
}))
|
|
.then(() => knex.schema.createTable('tags', (table) => {
|
|
table.increments('id', 12);
|
|
table.string('name');
|
|
|
|
table.integer('group_id', 12)
|
|
.references('id')
|
|
.inTable('tags_groups');
|
|
|
|
table.integer('alias_for', 12)
|
|
.references('id')
|
|
.inTable('tags');
|
|
|
|
table.string('slug', 32)
|
|
.unique();
|
|
}))
|
|
.then(() => knex.schema.createTable('networks', (table) => {
|
|
table.increments('id', 12);
|
|
|
|
table.string('name');
|
|
table.string('url');
|
|
table.text('description');
|
|
table.enum('orientation', ['gay', 'bi', 'lesbian', 'trans']);
|
|
|
|
table.string('slug', 32)
|
|
.unique();
|
|
}))
|
|
.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.enum('orientation', ['gay', 'bi', 'lesbian', 'trans']);
|
|
table.string('parameters');
|
|
|
|
table.string('slug', 32)
|
|
.unique();
|
|
}))
|
|
.then(() => knex.schema.createTable('releases', (table) => {
|
|
table.increments('id', 16);
|
|
|
|
table.integer('site_id', 12)
|
|
.notNullable()
|
|
.references('id')
|
|
.inTable('sites');
|
|
|
|
table.string('shoot_id');
|
|
table.string('entry_id');
|
|
table.unique(['site_id', 'shoot_id']);
|
|
table.unique(['site_id', 'entry_id']);
|
|
|
|
table.string('url');
|
|
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.integer('rating')
|
|
.unsigned();
|
|
|
|
table.enum('orientation', ['gay', 'bi', 'lesbian', 'trans']);
|
|
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.integer('index');
|
|
table.string('mime');
|
|
|
|
table.enum('domain', ['networks', 'sites', 'releases', 'actors', 'directors']);
|
|
table.integer('target_id', 16);
|
|
|
|
table.enum('role', ['photo', 'poster', 'trailer', 'logo', 'profile']);
|
|
table.string('quality', 6);
|
|
}))
|
|
.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');
|
|
}))
|
|
.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');
|
|
}))
|
|
.then(() => knex.schema.createTable('tags_associated', (table) => {
|
|
table.integer('tag_id', 12)
|
|
.notNullable()
|
|
.references('id')
|
|
.inTable('tags');
|
|
|
|
table.integer('site_id', 12)
|
|
.references('id')
|
|
.inTable('sites');
|
|
|
|
table.integer('release_id', 16)
|
|
.references('id')
|
|
.inTable('releases');
|
|
}));
|
|
|
|
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('actors'))
|
|
.then(() => knex.schema.dropTable('releases'))
|
|
.then(() => knex.schema.dropTable('sites'))
|
|
.then(() => knex.schema.dropTable('directors'))
|
|
.then(() => knex.schema.dropTable('networks'));
|