WIP Items module.

This commit is contained in:
Ahmed Bouhuolia
2019-09-03 02:07:28 +02:00
parent cb8c294d74
commit 70809cb05c
142 changed files with 12674 additions and 64 deletions

View File

@@ -0,0 +1,10 @@
exports.up = (knex) => knex.schema.createTable('roles', (table) => {
table.increments();
table.string('name');
table.string('description');
table.boolean('predefined').default(false);
table.timestamps();
});
exports.down = (knex) => knex.schema.dropTable('roles');

View File

@@ -0,0 +1,20 @@
exports.up = function(knex) {
return knex.schema.createTable('users', (table) => {
table.increments();
table.string('first_name');
table.string('last_name');
table.string('email').unique();
table.string('phone_number').unique();
table.string('password');
table.boolean('active');
table.integer('role_id').unique();
table.string('language');
table.date('last_login_at');
table.timestamps();
});
};
exports.down = function(knex) {
return knex.schema.dropTableIfExists('users');
};

View File

@@ -0,0 +1,16 @@
exports.up = function(knex) {
return knex.schema.createTable('oauth_tokens', table => {
table.increments();
table.string('access_token');
table.date('access_token_expires_on');
table.integer('client_id').unsigned();
table.string('refresh_token');
table.date('refresh_token_expires_on');
table.integer('user_id').unsigned().references('id').inTable('users');
});
};
exports.down = function(knex) {
return knex.schema.dropTableIfExists('oauth_tokens');
};

View File

@@ -0,0 +1,11 @@
exports.up = function(knex) {
return knex.schema.createTable('oauth_clients', table => {
table.increments();
table.integer('client_id').unsigned();
table.string('client_secret');
table.string('redirect_uri');
});
};
exports.down = (knex) => knex.schema.dropTableIfExists('oauth_clients');

View File

@@ -0,0 +1,11 @@
exports.up = function(knex) {
return knex.schema.createTable('settings', table => {
table.increments();
table.integer('user_id').unsigned().references('id').inTable('users');
table.string('key');
table.string('value');
});
};
exports.down = (knex) => knex.schema.dropTableIfExists('settings');

View File

@@ -0,0 +1,20 @@
exports.up = function (knex) {
return knex.schema.createTable('items', (table) => {
table.increments();
table.string('name');
table.integer('type_id').unsigned();
table.decimal('cost_price').unsigned();
table.decimal('sell_price').unsigned();
table.string('currency_code', 3);
table.string('picture_uri');
table.integer('cost_account_id').unsigned();
table.integer('sell_account_id').unsigned();
table.text('note').nullable();
table.integer('category_id').unsigned();
table.integer('user_id').unsigned();
table.timestamps();
});
};
exports.down = (knex) => knex.schema.dropTableIfExists('items');

View File

@@ -0,0 +1,14 @@
exports.up = function (knex) {
return knex.schema.createTable('accounts', (table) => {
table.increments();
table.string('name');
table.string('type');
table.integer('parent_account_id');
table.string('code', 10);
table.text('description');
table.timestamps();
});
};
exports.down = (knex) => knex.schema.dropTableIfExists('accounts');

View File

@@ -0,0 +1,11 @@
exports.up = function (knex) {
return knex.schema.createTable('account_balance', (table) => {
table.increments();
table.integer('account_id');
table.decimal('amount');
table.string('currency_code', 3);
});
};
exports.down = (knex) => knex.schema.dropTableIfExists('account_balance');

View File

@@ -0,0 +1,13 @@
exports.up = function (knex) {
return knex.schema.createTable('items_categories', (table) => {
table.increments();
table.string('label');
table.integer('parent_category_id').unsigned();
table.text('description');
table.integer('user_id').unsigned();
table.timestamps();
});
};
exports.down = (knex) => knex.schema.dropTableIfExists('items_categories');

View File

@@ -0,0 +1,11 @@
exports.up = function (knex) {
return knex.schema.createTable('items_metadata', (table) => {
table.increments();
table.string('key');
table.string('value');
table.integer('item_id').unsigned();
});
};
exports.down = (knex) => knex.schema.dropTableIfExists('items_metadata');