forked from DebaucheryLibrarian/traxxx
Added user sign up and login.
This commit is contained in:
@@ -105,6 +105,10 @@ exports.up = knex => Promise.resolve()
|
||||
.inTable('entities')
|
||||
.onDelete('cascade');
|
||||
|
||||
table.date('date');
|
||||
table.enum('date_precision', ['year', 'month', 'day', 'hour', 'minute', 'second'])
|
||||
.defaultTo('year');
|
||||
|
||||
table.text('comment');
|
||||
table.text('group');
|
||||
|
||||
@@ -980,6 +984,69 @@ exports.up = knex => Promise.resolve()
|
||||
|
||||
table.unique(['tag_id', 'chapter_id']);
|
||||
}))
|
||||
.then(() => knex.schema.createTable('users_roles', (table) => {
|
||||
table.string('role')
|
||||
.primary();
|
||||
|
||||
table.json('abilities');
|
||||
}))
|
||||
.then(() => knex('users_roles').insert([
|
||||
{
|
||||
role: 'admin',
|
||||
abilities: JSON.stringify([ // serialization necessary to avoid array being interpreted as a PG array
|
||||
{ subject: 'scene', action: 'create' },
|
||||
{ subject: 'scene', action: 'update' },
|
||||
{ subject: 'scene', action: 'delete' },
|
||||
{ subject: 'actor', action: 'create' },
|
||||
{ subject: 'actor', action: 'update' },
|
||||
{ subject: 'actor', action: 'delete' },
|
||||
]),
|
||||
},
|
||||
{
|
||||
role: 'editor',
|
||||
abilities: JSON.stringify([ // serialization necessary to avoid array being interpreted as a PG array
|
||||
{ subject: 'scene', action: 'update' },
|
||||
{ subject: 'actor', action: 'update' },
|
||||
]),
|
||||
},
|
||||
{
|
||||
role: 'user',
|
||||
},
|
||||
]))
|
||||
.then(() => knex.schema.createTable('users', (table) => {
|
||||
table.increments('id');
|
||||
|
||||
table.text('username')
|
||||
.unique()
|
||||
.notNullable();
|
||||
|
||||
table.text('email')
|
||||
.unique()
|
||||
.notNullable();
|
||||
|
||||
table.text('password')
|
||||
.notNullable();
|
||||
|
||||
table.string('role')
|
||||
.references('role')
|
||||
.inTable('users_roles')
|
||||
.defaultTo('user')
|
||||
.notNullable();
|
||||
|
||||
table.json('abilities');
|
||||
|
||||
table.boolean('email_verified')
|
||||
.notNullable()
|
||||
.defaultTo(false);
|
||||
|
||||
table.boolean('identity_verified')
|
||||
.notNullable()
|
||||
.defaultTo(false);
|
||||
|
||||
table.datetime('created_at')
|
||||
.notNullable()
|
||||
.defaultTo(knex.fn.now());
|
||||
}))
|
||||
// SEARCH
|
||||
.then(() => { // eslint-disable-line arrow-body-style
|
||||
// allow vim fold
|
||||
@@ -1173,6 +1240,9 @@ exports.up = knex => Promise.resolve()
|
||||
.then(() => { // eslint-disable-line arrow-body-style
|
||||
// allow vim fold
|
||||
return knex.raw(`
|
||||
COMMENT ON TABLE users IS E'@omit';
|
||||
COMMENT ON TABLE users_roles IS E'@omit';
|
||||
|
||||
COMMENT ON COLUMN actors.height IS E'@omit read,update,create,delete,all,many';
|
||||
COMMENT ON COLUMN actors.weight IS E'@omit read,update,create,delete,all,many';
|
||||
COMMENT ON COLUMN actors.penis_length IS E'@omit read,update,create,delete,all,many';
|
||||
@@ -1249,6 +1319,9 @@ exports.down = (knex) => { // eslint-disable-line arrow-body-style
|
||||
DROP TABLE IF EXISTS entities_types CASCADE;
|
||||
DROP TABLE IF EXISTS entities CASCADE;
|
||||
|
||||
DROP TABLE IF EXISTS users CASCADE;
|
||||
DROP TABLE IF EXISTS users_roles CASCADE;
|
||||
|
||||
DROP FUNCTION IF EXISTS search_releases;
|
||||
DROP FUNCTION IF EXISTS search_sites;
|
||||
DROP FUNCTION IF EXISTS search_entities;
|
||||
|
||||
Reference in New Issue
Block a user