mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
WIP
This commit is contained in:
17
server/src/database/manager.js
Normal file
17
server/src/database/manager.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import knexManager from 'knex-db-manager';
|
||||
import knexfile from '@/../knexfile';
|
||||
|
||||
const config = knexfile[process.env.NODE_ENV];
|
||||
|
||||
const dbManager = knexManager.databaseManagerFactory({
|
||||
knex: config,
|
||||
dbManager: {
|
||||
// db manager related configuration
|
||||
collate: [],
|
||||
superUser: 'root',
|
||||
superPassword: 'root',
|
||||
// populatePathPattern: 'data/**/*.js', // glob format for searching seeds
|
||||
},
|
||||
});
|
||||
|
||||
export default dbManager;
|
||||
@@ -2,8 +2,8 @@
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.createTable('user_has_roles', (table) => {
|
||||
table.increments();
|
||||
table.integer('user_id').unsigned().references('id').inTable('users');
|
||||
table.integer('role_id').unsigned().references('id').inTable('roles');
|
||||
table.integer('user_id').unsigned();
|
||||
table.integer('role_id').unsigned();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ exports.up = function(knex) {
|
||||
table.integer('client_id').unsigned();
|
||||
table.string('refresh_token');
|
||||
table.date('refresh_token_expires_on');
|
||||
table.integer('user_id').unsigned().references('id').inTable('users');
|
||||
table.integer('user_id').unsigned();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.createTable('settings', (table) => {
|
||||
table.increments();
|
||||
table.integer('user_id').unsigned().references('id').inTable('users');
|
||||
table.integer('user_id').unsigned();
|
||||
table.string('group');
|
||||
table.string('type');
|
||||
table.string('key');
|
||||
|
||||
@@ -13,7 +13,7 @@ exports.up = function (knex) {
|
||||
table.boolean('columnable');
|
||||
table.integer('index');
|
||||
table.json('options');
|
||||
table.integer('resource_id').unsigned().references('id').inTable('resources');
|
||||
table.integer('resource_id').unsigned();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.createTable('role_has_accounts', (table) => {
|
||||
table.increments();
|
||||
table.integer('role_id').unsigned().references('id').inTable('roles');
|
||||
table.integer('account_id').unsigned().references('id').inTable('accounts');
|
||||
table.integer('role_id').unsigned();
|
||||
table.integer('account_id').unsigned();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.createTable('role_has_permissions', (table) => {
|
||||
table.increments();
|
||||
table.integer('role_id').unsigned().references('id').inTable('roles');
|
||||
table.integer('permission_id').unsigned().references('id').inTable('permissions');
|
||||
table.integer('resource_id').unsigned().references('id').inTable('resources');
|
||||
table.integer('role_id').unsigned();
|
||||
table.integer('permission_id').unsigned();
|
||||
table.integer('resource_id').unsigned();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ exports.up = function (knex) {
|
||||
return knex.schema.createTable('view_roles', (table) => {
|
||||
table.increments();
|
||||
table.integer('index');
|
||||
table.integer('field_id').unsigned().references('id').inTable('resource_fields');
|
||||
table.integer('field_id').unsigned();
|
||||
table.string('comparator');
|
||||
table.string('value');
|
||||
table.integer('view_id').unsigned();
|
||||
|
||||
@@ -7,10 +7,10 @@ exports.up = function(knex) {
|
||||
table.string('transaction_type');
|
||||
table.string('reference_type');
|
||||
table.integer('reference_id');
|
||||
table.integer('account_id').unsigned().references('id').inTable('accounts');
|
||||
table.integer('account_id').unsigned();
|
||||
table.string('note');
|
||||
table.boolean('draft').defaultTo(false);
|
||||
table.integer('user_id').unsigned().references('id').inTable('users');
|
||||
table.integer('user_id').unsigned();
|
||||
table.date('date');
|
||||
table.timestamps();
|
||||
});
|
||||
|
||||
@@ -6,11 +6,11 @@ exports.up = function(knex) {
|
||||
table.string('currency_code');
|
||||
table.decimal('exchange_rate');
|
||||
table.text('description');
|
||||
table.integer('expense_account_id').unsigned().references('id').inTable('accounts');
|
||||
table.integer('payment_account_id').unsigned().references('id').inTable('accounts');
|
||||
table.integer('expense_account_id').unsigned();
|
||||
table.integer('payment_account_id').unsigned();
|
||||
table.string('reference');
|
||||
table.boolean('published').defaultTo(false);
|
||||
table.integer('user_id').unsigned().references('id').inTable('users');
|
||||
table.integer('user_id').unsigned();
|
||||
table.date('date');
|
||||
// table.timestamps();
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ exports.up = function(knex) {
|
||||
table.decimal('amount');
|
||||
table.date('date');
|
||||
table.string('note');
|
||||
table.integer('user_id').unsigned().references('id').inTable('users');
|
||||
table.integer('user_id').unsigned();
|
||||
table.timestamps();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('budget_entries', (table) => {
|
||||
table.increments();
|
||||
table.integer('budget_id').unsigned().references('id').inTable('budgets');
|
||||
table.integer('account_id').unsigned().references('id').inTable('accounts');
|
||||
table.integer('budget_id').unsigned();
|
||||
table.integer('account_id').unsigned();
|
||||
table.decimal('amount', 15, 5);
|
||||
table.integer('order');
|
||||
})
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('resource_custom_fields_metadata', (table) => {
|
||||
table.increments();
|
||||
table.integer('resource_id').unsigned().references('id').inTable('resources');
|
||||
table.integer('resource_id').unsigned();
|
||||
table.integer('resource_item_id').unsigned();
|
||||
table.string('key');
|
||||
table.string('value');
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function(knex) {
|
||||
|
||||
@@ -8,54 +8,63 @@ exports.seed = (knex) => {
|
||||
{
|
||||
id: 1,
|
||||
name: 'Fixed Asset',
|
||||
normal: 'debit',
|
||||
balance_sheet: true,
|
||||
income_sheet: false,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Current Asset',
|
||||
normal: 'debit',
|
||||
balance_sheet: true,
|
||||
income_sheet: false,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Long Term Liability',
|
||||
normal: 'credit',
|
||||
balance_sheet: false,
|
||||
income_sheet: true,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'Current Liability',
|
||||
normal: 'credit',
|
||||
balance_sheet: false,
|
||||
income_sheet: true,
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: 'Equity',
|
||||
normal: 'credit',
|
||||
balance_sheet: false,
|
||||
income_sheet: true,
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: 'Expense',
|
||||
normal: 'debit',
|
||||
balance_sheet: false,
|
||||
income_sheet: true,
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: 'Income',
|
||||
normal: 'credit',
|
||||
balance_sheet: false,
|
||||
income_sheet: true,
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
name: 'Accounts Receivable',
|
||||
normal: 'debit',
|
||||
balance_sheet: true,
|
||||
income_sheet: false,
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
name: 'Accounts Payable',
|
||||
normal: 'credit',
|
||||
balance_sheet: true,
|
||||
income_sheet: false,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user