remove test files
This commit is contained in:
parent
285dbf2b5a
commit
9e17775575
@ -1,102 +0,0 @@
|
||||
digraph {
|
||||
node [shape=box,margin=0,height=0]
|
||||
edge [arrowhead=open,style=dashed]
|
||||
rankdir="RL";
|
||||
|
||||
users [label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td border="2"><b>users</b></td></tr>
|
||||
<tr><td port="id">🔑 id</td></tr>
|
||||
<tr><td port="name">★ name ''</td></tr>
|
||||
<tr><td port="email">★ email ''</td></tr>
|
||||
<tr><td port="password">password ''</td></tr>
|
||||
<tr><td port="salt">salt ''</td></tr>
|
||||
<tr><td port="deleted">deleted ✓</td></tr>
|
||||
</table>
|
||||
>]
|
||||
|
||||
applications [label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td border="2"><b>applications</b></td></tr>
|
||||
<tr><td port="id">🔑 id</td></tr>
|
||||
<tr><td port="name">name ''</td></tr>
|
||||
</table>
|
||||
>]
|
||||
|
||||
permissions [label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td border="2"><b>permissions</b></td></tr>
|
||||
<tr><td port="id">🔑 id</td></tr>
|
||||
<tr><td port="user_id">user_id #</td></tr>
|
||||
<tr><td>create_app ✓</td></tr>
|
||||
<tr><td>manage_users ✓</td></tr>
|
||||
<tr><td>manage_permissions ✓</td></tr>
|
||||
<tr><td>manage_apps ✓</td></tr>
|
||||
<tr><td>manage_keys ✓</td></tr>
|
||||
<tr><td>issue_key ✓</td></tr>
|
||||
</table>
|
||||
>]
|
||||
|
||||
user_access [label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td border="2"><b>user_access</b></td></tr>
|
||||
<tr><td port="id">🔑 id</td></tr>
|
||||
<tr><td port="user_id">user_id #</td></tr>
|
||||
<tr><td port="app_id">app_id #</td></tr>
|
||||
<tr><td port="crud">crud ''</td></tr>
|
||||
</table>
|
||||
>]
|
||||
|
||||
auth_keys [label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td border="2"><b>auth_keys</b></td></tr>
|
||||
<tr><td port="id">🔑 id</td></tr>
|
||||
<tr><td port="key">★ key ''</td></tr>
|
||||
<tr><td port="app_id">app_id #</td></tr>
|
||||
<tr><td port="read_data">read_data ✓</td></tr>
|
||||
<tr><td port="hash">★ hash ''</td></tr>
|
||||
<tr><td port="name">name ''</td></tr>
|
||||
</table>
|
||||
>]
|
||||
|
||||
categories [label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td border="2"><b>categories</b></td></tr>
|
||||
<tr><td port="id">🔑 id</td></tr>
|
||||
<tr><td port="name">★ name ''</td></tr>
|
||||
<tr><td port="app_id">app_id #</td></tr>
|
||||
</table>
|
||||
>, shape=box, margin=0]
|
||||
|
||||
log [label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td border="2"><b>log</b></td></tr>
|
||||
<tr><td port="id">🔑 id</td></tr>
|
||||
<tr><td port="key_id">key_id #</td></tr>
|
||||
<tr><td port="app_id">app_id #</td></tr>
|
||||
<tr><td port="timestamp">timestamp #</td></tr>
|
||||
<tr><td port="category_id">category_id #</td></tr>
|
||||
</table>
|
||||
>]
|
||||
|
||||
data [label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td border="2"><b>data</b></td></tr>
|
||||
<tr><td port="id">🔑 id</td></tr>
|
||||
<tr><td port="log_id">log_id #</td></tr>
|
||||
<tr><td port="key">key ''</td></tr>
|
||||
<tr><td port="value">value ''</td></tr>
|
||||
</table>
|
||||
>]
|
||||
|
||||
data:log_id -> log:id [color=blue]
|
||||
permissions:user_id -> users:id [color=blue]
|
||||
log:key_id -> auth_keys:id [color=blue]
|
||||
auth_keys:app_id -> applications:id [color=blue]
|
||||
user_access:user_id -> users:id [color=red]
|
||||
user_access:app_id -> applications:id [color=red]
|
||||
log:app_id -> applications:id [color=blue]
|
||||
log:category_id -> categories:id [color=blue]
|
||||
categories:app_id -> applications:id [color=blue]
|
||||
}
|
||||
data_key [label=key]
|
@ -1,13 +0,0 @@
|
||||
/* eslint-disable no-console */
|
||||
'use strict';
|
||||
|
||||
const dot_parser = require ('../snippets/db/dot_parser');
|
||||
|
||||
/**
|
||||
* test
|
||||
*/
|
||||
async function test () {
|
||||
const data = await dot_parser.create_migration ('db_structure.dot');
|
||||
console.log (data);
|
||||
}
|
||||
test ();
|
191
test/test.js
191
test/test.js
@ -1,191 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* create table users
|
||||
*
|
||||
* @param {any} knex database connection
|
||||
* @returns {Promise} result
|
||||
*/
|
||||
function create_users (knex) {
|
||||
return knex.schema.createTable ('users', (table) => {
|
||||
table.increments ('id');
|
||||
table.string ('name');
|
||||
table.string ('email');
|
||||
table.string ('password');
|
||||
table.string ('salt');
|
||||
table.boolean ('deleted');
|
||||
|
||||
table.unique ('name', 'email');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* create table applications
|
||||
*
|
||||
* @param {any} knex database connection
|
||||
* @returns {Promise} result
|
||||
*/
|
||||
function create_applications (knex) {
|
||||
return knex.schema.createTable ('applications', (table) => {
|
||||
table.increments ('id');
|
||||
table.string ('name');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* create table permissions
|
||||
*
|
||||
* @param {any} knex database connection
|
||||
* @returns {Promise} result
|
||||
*/
|
||||
function create_permissions (knex) {
|
||||
return knex.schema.createTable ('permissions', (table) => {
|
||||
table.increments ('id');
|
||||
table.integer ('user_id');
|
||||
table.boolean ('create_app');
|
||||
table.boolean ('manage_users');
|
||||
table.boolean ('manage_permissions');
|
||||
table.boolean ('manage_apps');
|
||||
table.boolean ('manage_keys');
|
||||
table.boolean ('issue_key');
|
||||
|
||||
table.foreign ('user_id')
|
||||
.references ('id')
|
||||
.inTable ('users');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* create table user_access
|
||||
*
|
||||
* @param {any} knex database connection
|
||||
* @returns {Promise} result
|
||||
*/
|
||||
function create_user_access (knex) {
|
||||
return knex.schema.createTable ('user_access', (table) => {
|
||||
table.increments ('id');
|
||||
table.integer ('user_id');
|
||||
table.integer ('app_id');
|
||||
table.string ('crud');
|
||||
|
||||
table.foreign ('user_id')
|
||||
.references ('id')
|
||||
.inTable ('users');
|
||||
table.foreign ('app_id')
|
||||
.references ('id')
|
||||
.inTable ('applications');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* create table auth_keys
|
||||
*
|
||||
* @param {any} knex database connection
|
||||
* @returns {Promise} result
|
||||
*/
|
||||
function create_auth_keys (knex) {
|
||||
return knex.schema.createTable ('auth_keys', (table) => {
|
||||
table.increments ('id');
|
||||
table.string ('key');
|
||||
table.integer ('app_id');
|
||||
table.boolean ('read_data');
|
||||
table.string ('hash');
|
||||
table.string ('name');
|
||||
|
||||
table.unique ('key', 'hash');
|
||||
|
||||
table.foreign ('app_id')
|
||||
.references ('id')
|
||||
.inTable ('applications');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* create table categories
|
||||
*
|
||||
* @param {any} knex database connection
|
||||
* @returns {Promise} result
|
||||
*/
|
||||
function create_categories (knex) {
|
||||
return knex.schema.createTable ('categories', (table) => {
|
||||
table.increments ('id');
|
||||
table.string ('name');
|
||||
table.integer ('app_id');
|
||||
|
||||
table.unique ('name');
|
||||
|
||||
table.foreign ('app_id')
|
||||
.references ('id')
|
||||
.inTable ('applications');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* create table log
|
||||
*
|
||||
* @param {any} knex database connection
|
||||
* @returns {Promise} result
|
||||
*/
|
||||
function create_log (knex) {
|
||||
return knex.schema.createTable ('log', (table) => {
|
||||
table.increments ('id');
|
||||
table.integer ('key_id');
|
||||
table.integer ('app_id');
|
||||
table.integer ('timestamp');
|
||||
table.integer ('category_id');
|
||||
|
||||
table.foreign ('key_id')
|
||||
.references ('id')
|
||||
.inTable ('auth_keys');
|
||||
table.foreign ('app_id')
|
||||
.references ('id')
|
||||
.inTable ('applications');
|
||||
table.foreign ('category_id')
|
||||
.references ('id')
|
||||
.inTable ('categories');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* create table data
|
||||
*
|
||||
* @param {any} knex database connection
|
||||
* @returns {Promise} result
|
||||
*/
|
||||
function create_data (knex) {
|
||||
return knex.schema.createTable ('data', (table) => {
|
||||
table.increments ('id');
|
||||
table.integer ('log_id');
|
||||
table.string ('key');
|
||||
table.string ('value');
|
||||
|
||||
table.foreign ('log_id')
|
||||
.references ('id')
|
||||
.inTable ('log');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* run migration
|
||||
*
|
||||
* @param {any} knex db connection
|
||||
*/
|
||||
async function up (knex) {
|
||||
await create_users (knex);
|
||||
await create_applications (knex);
|
||||
await create_permissions (knex);
|
||||
await create_user_access (knex);
|
||||
await create_auth_keys (knex);
|
||||
await create_categories (knex);
|
||||
await create_log (knex);
|
||||
await create_data (knex);
|
||||
}
|
||||
|
||||
/**
|
||||
* revert migration
|
||||
*/
|
||||
function down () {
|
||||
// noop
|
||||
}
|
||||
|
||||
module.exports = { up, down };
|
Loading…
x
Reference in New Issue
Block a user