forked from DebaucheryLibrarian/traxxx
Adding networks and sites as entities,
This commit is contained in:
@@ -140,6 +140,59 @@ exports.up = knex => Promise.resolve()
|
||||
|
||||
table.unique(['tag_id', 'media_id']);
|
||||
}))
|
||||
.then(() => knex.schema.createTable('entities_types', (table) => {
|
||||
table.increments('id', 4);
|
||||
table.text('type');
|
||||
}))
|
||||
.then(() => knex('entities_types').insert([
|
||||
{ type: 'network' },
|
||||
{ type: 'channel' },
|
||||
{ type: 'studio' },
|
||||
]))
|
||||
.then(() => knex.schema.createTable('entities', (table) => {
|
||||
table.increments('id', 12);
|
||||
|
||||
table.integer('parent_id', 12)
|
||||
.references('id')
|
||||
.inTable('entities');
|
||||
|
||||
table.integer('type', 4)
|
||||
.references('id')
|
||||
.inTable('entities_types')
|
||||
.defaultTo(2);
|
||||
|
||||
table.text('name');
|
||||
table.text('slug', 32)
|
||||
.unique();
|
||||
table.text('alias');
|
||||
|
||||
table.text('url');
|
||||
table.text('description');
|
||||
table.json('parameters');
|
||||
|
||||
table.boolean('active');
|
||||
table.integer('priority', 3)
|
||||
.defaultTo(0);
|
||||
|
||||
table.datetime('created_at')
|
||||
.defaultTo(knex.fn.now());
|
||||
}))
|
||||
.then(() => knex.schema.createTable('entities_tags', (table) => {
|
||||
table.integer('tag_id', 12)
|
||||
.notNullable()
|
||||
.references('id')
|
||||
.inTable('tags');
|
||||
|
||||
table.integer('entity_id', 12)
|
||||
.notNullable()
|
||||
.references('id')
|
||||
.inTable('entities');
|
||||
|
||||
table.boolean('inherit')
|
||||
.defaultTo(false);
|
||||
|
||||
table.unique(['tag_id', 'entity_id']);
|
||||
}))
|
||||
.then(() => knex.schema.createTable('networks', (table) => {
|
||||
table.increments('id', 12);
|
||||
|
||||
@@ -897,6 +950,7 @@ exports.down = (knex) => { // eslint-disable-line arrow-body-style
|
||||
DROP TABLE IF EXISTS actors_piercings CASCADE;
|
||||
DROP TABLE IF EXISTS body CASCADE;
|
||||
|
||||
DROP TABLE IF EXISTS entities_tags CASCADE;
|
||||
DROP TABLE IF EXISTS sites_tags CASCADE;
|
||||
DROP TABLE IF EXISTS sites_social CASCADE;
|
||||
DROP TABLE IF EXISTS networks_social CASCADE;
|
||||
@@ -915,6 +969,9 @@ exports.down = (knex) => { // eslint-disable-line arrow-body-style
|
||||
DROP TABLE IF EXISTS countries CASCADE;
|
||||
DROP TABLE IF EXISTS networks CASCADE;
|
||||
|
||||
DROP TABLE IF EXISTS entities_types CASCADE;
|
||||
DROP TABLE IF EXISTS entities CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS search_sites;
|
||||
DROP FUNCTION IF EXISTS search_actors;
|
||||
DROP FUNCTION IF EXISTS get_random_sfw_media_id;
|
||||
|
||||
Reference in New Issue
Block a user