WiP on namespaces and users
This commit is contained in:
parent
432e6ffaeb
commit
1b73282e90
18 changed files with 513 additions and 0 deletions
31
setup/knex/migrations/20170507083345_create_namespaces.js
Normal file
31
setup/knex/migrations/20170507083345_create_namespaces.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
exports.up = function(knex, Promise) {
|
||||
return knex.schema.createTable('namespaces', table => {
|
||||
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();
|
||||
})
|
||||
|
||||
.then(() => knex('namespaces').insert({
|
||||
id: 1,
|
||||
name: 'Global',
|
||||
description: 'Global namespace'
|
||||
}))
|
||||
|
||||
.then(() => knex('lists').update({
|
||||
namespace: 1
|
||||
}))
|
||||
|
||||
.then(() => knex.schema.table('lists', table => {
|
||||
table.foreign('namespace').references('namespaces.id').onDelete('CASCADE');
|
||||
}))
|
||||
|
||||
;
|
||||
};
|
||||
|
||||
exports.down = function(knex, Promise) {
|
||||
return knex.schema.dropTable('namespaces');
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue