Namespace selection for users, reports and report-templates
This commit is contained in:
parent
4822a50d0b
commit
e7bdfb7745
16 changed files with 210 additions and 62 deletions
|
@ -3,10 +3,7 @@ exports.up = function(knex, Promise) {
|
|||
table.increments('id').primary();
|
||||
table.string('name');
|
||||
table.text('description');
|
||||
table.integer('parent').unsigned().references('namespaces.id').onDelete('CASCADE');
|
||||
})
|
||||
.table('lists', table => {
|
||||
table.integer('namespace').unsigned().notNullable();
|
||||
table.integer('namespace').unsigned().references('namespaces.id').onDelete('CASCADE');
|
||||
})
|
||||
|
||||
.then(() => knex('namespaces').insert({
|
||||
|
@ -15,11 +12,43 @@ exports.up = function(knex, Promise) {
|
|||
description: 'Global namespace'
|
||||
}))
|
||||
|
||||
.then(() => knex('lists').update({
|
||||
.then(() => knex.schema.table('users', table => {
|
||||
table.integer('namespace').unsigned().notNullable();
|
||||
}))
|
||||
.then(() => knex('users').update({
|
||||
namespace: 1
|
||||
}))
|
||||
.then(() => knex.schema.table('users', table => {
|
||||
table.foreign('namespace').references('namespaces.id').onDelete('CASCADE');
|
||||
}))
|
||||
|
||||
.then(() => knex.schema.table('lists', table => {
|
||||
table.integer('namespace').unsigned().notNullable();
|
||||
}))
|
||||
.then(() => knex('lists').update({
|
||||
namespace: 1
|
||||
}))
|
||||
.then(() => knex.schema.table('lists', table => {
|
||||
table.foreign('namespace').references('namespaces.id').onDelete('CASCADE');
|
||||
}))
|
||||
|
||||
.then(() => knex.schema.table('report_templates', table => {
|
||||
table.integer('namespace').unsigned().notNullable();
|
||||
}))
|
||||
.then(() => knex('report_templates').update({
|
||||
namespace: 1
|
||||
}))
|
||||
.then(() => knex.schema.table('report_templates', table => {
|
||||
table.foreign('namespace').references('namespaces.id').onDelete('CASCADE');
|
||||
}))
|
||||
|
||||
.then(() => knex.schema.table('reports', table => {
|
||||
table.integer('namespace').unsigned().notNullable();
|
||||
}))
|
||||
.then(() => knex('reports').update({
|
||||
namespace: 1
|
||||
}))
|
||||
.then(() => knex.schema.table('reports', table => {
|
||||
table.foreign('namespace').references('namespaces.id').onDelete('CASCADE');
|
||||
}))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue