mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
fix: database migrations FK relations.
fix: database columns indexing.
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
|
||||
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.boolean('active');
|
||||
table.integer('role_id').unique();
|
||||
table.string('language');
|
||||
table.date('last_login_at');
|
||||
|
||||
table.date('invite_accepted_at');
|
||||
table.timestamps();
|
||||
}).raw('ALTER TABLE `USERS` AUTO_INCREMENT = 1000');;
|
||||
};
|
||||
|
||||
exports.down = function (knex) {
|
||||
return knex.schema.dropTableIfExists('users');
|
||||
};
|
||||
@@ -3,9 +3,9 @@ exports.up = (knex) => {
|
||||
return knex.schema.createTable('account_types', (table) => {
|
||||
table.increments();
|
||||
table.string('name');
|
||||
table.string('key');
|
||||
table.string('normal');
|
||||
table.string('root_type');
|
||||
table.string('key').index();
|
||||
table.string('normal').index();
|
||||
table.string('root_type').index();
|
||||
table.string('child_type');
|
||||
table.boolean('balance_sheet');
|
||||
table.boolean('income_sheet');
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.createTable('accounts', (table) => {
|
||||
table.increments('id').comment('Auto-generated id');;
|
||||
table.string('name').index();
|
||||
table.string('slug');
|
||||
table.integer('account_type_id').unsigned().references('id').inTable('account_types');
|
||||
table.integer('parent_account_id').unsigned().references('id').inTable('accounts');
|
||||
table.string('code', 10).index();
|
||||
table.text('description');
|
||||
table.boolean('active').defaultTo(true).index();
|
||||
table.integer('index').unsigned();
|
||||
table.boolean('predefined').defaultTo(false).index();
|
||||
table.decimal('amount', 15, 5);
|
||||
table.string('currency_code', 3).index();
|
||||
table.timestamps();
|
||||
}).raw('ALTER TABLE `ACCOUNTS` AUTO_INCREMENT = 1000');
|
||||
};
|
||||
|
||||
exports.down = (knex) => knex.schema.dropTableIfExists('accounts');
|
||||
@@ -1,27 +0,0 @@
|
||||
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.createTable('items', (table) => {
|
||||
table.increments();
|
||||
table.string('name');
|
||||
table.string('type');
|
||||
table.string('sku');
|
||||
table.boolean('sellable');
|
||||
table.boolean('purchasable');
|
||||
table.decimal('sell_price', 13, 3).unsigned();
|
||||
table.decimal('cost_price', 13, 3).unsigned();
|
||||
table.string('currency_code', 3);
|
||||
table.string('picture_uri');
|
||||
table.integer('cost_account_id').unsigned();
|
||||
table.integer('sell_account_id').unsigned();
|
||||
table.integer('inventory_account_id').unsigned();
|
||||
table.text('sell_description').nullable();
|
||||
table.text('purchase_description').nullable();
|
||||
table.integer('quantity_on_hand');
|
||||
table.text('note').nullable();
|
||||
table.integer('category_id').unsigned();
|
||||
table.integer('user_id').unsigned();
|
||||
table.timestamps();
|
||||
}).raw('ALTER TABLE `ITEMS` AUTO_INCREMENT = 1000');;
|
||||
};
|
||||
|
||||
exports.down = (knex) => knex.schema.dropTableIfExists('items');
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.createTable('accounts', (table) => {
|
||||
table.bigIncrements('id').comment('Auto-generated id');;
|
||||
table.string('name');
|
||||
table.string('slug');
|
||||
table.integer('account_type_id').unsigned();
|
||||
table.integer('parent_account_id').unsigned();
|
||||
table.string('code', 10);
|
||||
table.text('description');
|
||||
table.boolean('active').defaultTo(true);
|
||||
table.integer('index').unsigned();
|
||||
table.boolean('predefined').defaultTo(false);
|
||||
table.decimal('amount', 15, 5);
|
||||
table.string('currency_code', 3);
|
||||
table.timestamps();
|
||||
}).raw('ALTER TABLE `ACCOUNTS` AUTO_INCREMENT = 1000');
|
||||
};
|
||||
|
||||
exports.down = (knex) => knex.schema.dropTableIfExists('accounts');
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.createTable('items_categories', (table) => {
|
||||
table.increments();
|
||||
table.string('name').index();
|
||||
table.integer('parent_category_id').unsigned().references('id').inTable('items_categories');
|
||||
table.text('description');
|
||||
table.integer('user_id').unsigned().index();
|
||||
|
||||
table.integer('cost_account_id').unsigned().references('id').inTable('accounts');
|
||||
table.integer('sell_account_id').unsigned().references('id').inTable('accounts');
|
||||
table.integer('inventory_account_id').unsigned().references('id').inTable('accounts');
|
||||
|
||||
table.string('cost_method');
|
||||
table.timestamps();
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = (knex) => knex.schema.dropTableIfExists('items_categories');
|
||||
@@ -1,19 +0,0 @@
|
||||
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.createTable('items_categories', (table) => {
|
||||
table.increments();
|
||||
table.string('name');
|
||||
table.integer('parent_category_id').unsigned();
|
||||
table.text('description');
|
||||
table.integer('user_id').unsigned();
|
||||
|
||||
table.integer('cost_account_id').unsigned();
|
||||
table.integer('sell_account_id').unsigned();
|
||||
table.integer('inventory_account_id').unsigned();
|
||||
|
||||
table.string('cost_method');
|
||||
table.timestamps();
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = (knex) => knex.schema.dropTableIfExists('items_categories');
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.createTable('items', (table) => {
|
||||
table.increments();
|
||||
table.string('name').index();
|
||||
table.string('type').index();
|
||||
table.string('sku');
|
||||
table.boolean('sellable').index();
|
||||
table.boolean('purchasable').index();
|
||||
table.decimal('sell_price', 13, 3).unsigned();
|
||||
table.decimal('cost_price', 13, 3).unsigned();
|
||||
table.string('currency_code', 3);
|
||||
table.string('picture_uri');
|
||||
table.integer('cost_account_id').nullable().unsigned().references('id').inTable('accounts');
|
||||
table.integer('sell_account_id').nullable().unsigned().references('id').inTable('accounts');
|
||||
table.integer('inventory_account_id').unsigned().references('id').inTable('accounts');
|
||||
table.text('sell_description').nullable();
|
||||
table.text('purchase_description').nullable();
|
||||
table.integer('quantity_on_hand');
|
||||
table.text('note').nullable();
|
||||
table.integer('category_id').unsigned().index().references('id').inTable('items_categories');
|
||||
table.integer('user_id').unsigned().index();
|
||||
table.timestamps();
|
||||
}).raw('ALTER TABLE `ITEMS` AUTO_INCREMENT = 1000');
|
||||
};
|
||||
|
||||
exports.down = (knex) => knex.schema.dropTableIfExists('items');
|
||||
@@ -2,9 +2,9 @@
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.createTable('views', (table) => {
|
||||
table.increments();
|
||||
table.string('name');
|
||||
table.string('name').index();
|
||||
table.boolean('predefined');
|
||||
table.string('resource_model');
|
||||
table.string('resource_model').index();
|
||||
table.boolean('favourite');
|
||||
table.string('roles_logic_expression');
|
||||
table.timestamps();
|
||||
@@ -2,10 +2,10 @@
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.createTable('settings', (table) => {
|
||||
table.increments();
|
||||
table.integer('user_id').unsigned();
|
||||
table.string('group');
|
||||
table.integer('user_id').unsigned().index();
|
||||
table.string('group').index();
|
||||
table.string('type');
|
||||
table.string('key');
|
||||
table.string('key').index();
|
||||
table.string('value');
|
||||
}).raw('ALTER TABLE `SETTINGS` AUTO_INCREMENT = 2000');
|
||||
};
|
||||
@@ -2,7 +2,7 @@
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.createTable('view_has_columns', (table) => {
|
||||
table.increments();
|
||||
table.integer('view_id').unsigned();
|
||||
table.integer('view_id').unsigned().index().references('id').inTable('views');
|
||||
table.string('field_key');
|
||||
table.integer('index').unsigned();
|
||||
}).raw('ALTER TABLE `ITEMS_CATEGORIES` AUTO_INCREMENT = 1000');
|
||||
|
||||
@@ -3,10 +3,10 @@ exports.up = function (knex) {
|
||||
return knex.schema.createTable('view_roles', (table) => {
|
||||
table.increments();
|
||||
table.integer('index');
|
||||
table.string('field_key');
|
||||
table.string('field_key').index();
|
||||
table.string('comparator');
|
||||
table.string('value');
|
||||
table.integer('view_id').unsigned();
|
||||
table.integer('view_id').unsigned().index().references('id').inTable('views');
|
||||
}).raw('ALTER TABLE `VIEW_ROLES` AUTO_INCREMENT = 1000');
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('contacts', table => {
|
||||
table.increments();
|
||||
|
||||
table.string('contact_service');
|
||||
table.string('contact_type');
|
||||
|
||||
table.decimal('balance', 13, 3).defaultTo(0);
|
||||
table.decimal('opening_balance', 13, 3).defaultTo(0);
|
||||
|
||||
table.string('first_name').nullable();
|
||||
table.string('last_name').nullable();
|
||||
table.string('company_name').nullable();
|
||||
|
||||
table.string('display_name');
|
||||
|
||||
table.string('email').nullable();
|
||||
table.string('work_phone').nullable();
|
||||
table.string('personal_phone').nullable();
|
||||
|
||||
table.string('billing_address_1').nullable();
|
||||
table.string('billing_address_2').nullable();
|
||||
table.string('billing_address_city').nullable();
|
||||
table.string('billing_address_country').nullable();
|
||||
table.string('billing_address_email').nullable();
|
||||
table.string('billing_address_zipcode').nullable();
|
||||
table.string('billing_address_phone').nullable();
|
||||
table.string('billing_address_state').nullable(),
|
||||
|
||||
table.string('shipping_address_1').nullable();
|
||||
table.string('shipping_address_2').nullable();
|
||||
table.string('shipping_address_city').nullable();
|
||||
table.string('shipping_address_country').nullable();
|
||||
table.string('shipping_address_email').nullable();
|
||||
table.string('shipping_address_zipcode').nullable();
|
||||
table.string('shipping_address_phone').nullable();
|
||||
table.string('shipping_address_state').nullable();
|
||||
|
||||
table.text('note');
|
||||
table.boolean('active').defaultTo(true);
|
||||
|
||||
table.timestamps();
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function(knex) {
|
||||
return knex.schema.dropTableIfExists('contacts');
|
||||
};
|
||||
@@ -4,17 +4,17 @@ exports.up = function(knex) {
|
||||
table.increments();
|
||||
table.decimal('credit', 13, 3);
|
||||
table.decimal('debit', 13, 3);
|
||||
table.string('transaction_type');
|
||||
table.string('reference_type');
|
||||
table.integer('reference_id');
|
||||
table.integer('account_id').unsigned();
|
||||
table.string('contact_type').nullable();
|
||||
table.integer('contact_id').unsigned().nullable();
|
||||
table.string('transaction_type').index();
|
||||
table.string('reference_type').index();
|
||||
table.integer('reference_id').index();
|
||||
table.integer('account_id').unsigned().index().references('id').inTable('accounts');
|
||||
table.string('contact_type').nullable().index();
|
||||
table.integer('contact_id').unsigned().nullable().index().references('id').inTable('contacts');
|
||||
table.string('note');
|
||||
table.boolean('draft').defaultTo(false);
|
||||
table.integer('user_id').unsigned();
|
||||
table.integer('user_id').unsigned().index();
|
||||
table.integer('index').unsigned();
|
||||
table.date('date');
|
||||
table.date('date').index();
|
||||
table.timestamps();
|
||||
}).raw('ALTER TABLE `ACCOUNTS_TRANSACTIONS` AUTO_INCREMENT = 1000');
|
||||
};
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('options', (table) => {
|
||||
table.increments();
|
||||
table.string('key');
|
||||
table.string('value');
|
||||
table.string('group');
|
||||
table.string('type');
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function(knex) {
|
||||
return knex.schema.dropTableIfExists('options');
|
||||
};
|
||||
@@ -5,12 +5,12 @@ exports.up = function(knex) {
|
||||
table.decimal('total_amount', 13, 3);
|
||||
table.string('currency_code', 3);
|
||||
table.text('description');
|
||||
table.integer('payment_account_id').unsigned();
|
||||
table.integer('payee_id').unsigned();
|
||||
table.integer('payment_account_id').unsigned().references('id').inTable('accounts');
|
||||
table.integer('payee_id').unsigned().references('id').inTable('contacts');;
|
||||
table.string('reference_no');
|
||||
table.date('published_at');
|
||||
table.integer('user_id').unsigned();
|
||||
table.date('payment_date');
|
||||
table.date('published_at').index();
|
||||
table.integer('user_id').unsigned().index();
|
||||
table.date('payment_date').index();
|
||||
table.timestamps();
|
||||
}).raw('ALTER TABLE `EXPENSES_TRANSACTIONS` AUTO_INCREMENT = 1000');
|
||||
};
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('manual_journals', (table) => {
|
||||
table.increments();
|
||||
table.string('journal_number');
|
||||
table.string('reference');
|
||||
table.string('journal_type');
|
||||
table.string('journal_number').index();
|
||||
table.string('reference').index();
|
||||
table.string('journal_type').index();
|
||||
table.decimal('amount', 13, 3);
|
||||
table.date('date');
|
||||
table.boolean('status').defaultTo(false);
|
||||
table.date('date').index();
|
||||
table.boolean('status').defaultTo(false).index();
|
||||
table.string('description');
|
||||
table.string('attachment_file');
|
||||
table.integer('user_id').unsigned();
|
||||
table.integer('user_id').unsigned().index();
|
||||
table.timestamps();
|
||||
}).raw('ALTER TABLE `MANUAL_JOURNALS` AUTO_INCREMENT = 1000');
|
||||
};
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('currencies', table => {
|
||||
table.increments();
|
||||
table.string('currency_name');
|
||||
table.string('currency_code', 4);
|
||||
table.string('currency_name').index();
|
||||
table.string('currency_code', 4).index();
|
||||
table.timestamps();
|
||||
}).raw('ALTER TABLE `CURRENCIES` AUTO_INCREMENT = 1000');
|
||||
};
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('exchange_rates', table => {
|
||||
table.increments();
|
||||
table.string('currency_code', 4);
|
||||
table.string('currency_code', 4).index();
|
||||
table.decimal('exchange_rate');
|
||||
table.date('date');
|
||||
table.date('date').index();
|
||||
table.timestamps();
|
||||
}).raw('ALTER TABLE `EXCHANGE_RATES` AUTO_INCREMENT = 1000');
|
||||
};
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('media_links', table => {
|
||||
table.increments();
|
||||
table.string('model_name');
|
||||
table.integer('media_id').unsigned();
|
||||
table.integer('model_id').unsigned();
|
||||
table.string('model_name').index();
|
||||
table.integer('media_id').unsigned().index();
|
||||
table.integer('model_id').unsigned().index();
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('expense_transaction_categories', table => {
|
||||
table.increments();
|
||||
table.integer('expense_account_id').unsigned();
|
||||
table.integer('expense_account_id').unsigned().index().references('id').inTable('accounts');
|
||||
table.integer('index').unsigned();
|
||||
table.text('description');
|
||||
table.decimal('amount', 13, 3);
|
||||
table.integer('expense_id').unsigned();
|
||||
table.integer('expense_id').unsigned().index().references('id').inTable('expenses_transactions');
|
||||
table.timestamps();
|
||||
}).raw('ALTER TABLE `EXPENSE_TRANSACTION_CATEGORIES` AUTO_INCREMENT = 1000');;
|
||||
};
|
||||
|
||||
@@ -3,15 +3,15 @@ exports.up = function(knex) {
|
||||
return knex.schema.createTable('sales_estimates', (table) => {
|
||||
table.increments();
|
||||
table.decimal('amount', 13, 3);
|
||||
table.integer('customer_id').unsigned();
|
||||
table.date('estimate_date');
|
||||
table.date('expiration_date');
|
||||
table.integer('customer_id').unsigned().index().references('id').inTable('contacts');
|
||||
table.date('estimate_date').index();
|
||||
table.date('expiration_date').index();
|
||||
table.string('reference');
|
||||
table.string('estimate_number');
|
||||
table.string('estimate_number').index();
|
||||
table.text('note');
|
||||
table.text('terms_conditions');
|
||||
|
||||
table.integer('user_id').unsigned();
|
||||
table.integer('user_id').unsigned().index();
|
||||
table.timestamps();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -3,9 +3,9 @@ exports.up = function(knex) {
|
||||
return knex.schema.createTable('sales_receipts', table => {
|
||||
table.increments();
|
||||
table.decimal('amount', 13, 3);
|
||||
table.integer('deposit_account_id').unsigned();
|
||||
table.integer('customer_id').unsigned();
|
||||
table.date('receipt_date');
|
||||
table.integer('deposit_account_id').unsigned().index().references('id').inTable('accounts');
|
||||
table.integer('customer_id').unsigned().index().references('id').inTable('contacts');
|
||||
table.date('receipt_date').index();
|
||||
table.string('reference_no');
|
||||
table.string('email_send_to');
|
||||
table.text('receipt_message');
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('sales_invoices', table => {
|
||||
table.increments();
|
||||
table.integer('customer_id');
|
||||
table.date('invoice_date');
|
||||
table.integer('customer_id').unsigned().index().references('id').inTable('contacts')
|
||||
table.date('invoice_date').index();
|
||||
table.date('due_date');
|
||||
table.string('invoice_no');
|
||||
table.string('invoice_no').index();
|
||||
table.string('reference_no');
|
||||
table.string('status');
|
||||
table.string('status').index();
|
||||
|
||||
table.text('invoice_message');
|
||||
table.text('terms_conditions');
|
||||
@@ -15,7 +15,7 @@ exports.up = function(knex) {
|
||||
table.decimal('balance', 13, 3);
|
||||
table.decimal('payment_amount', 13, 3);
|
||||
|
||||
table.string('inv_lot_number');
|
||||
table.string('inv_lot_number').index();
|
||||
table.timestamps();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -3,14 +3,14 @@ const { knexSnakeCaseMappers } = require("objection");
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('payment_receives', (table) => {
|
||||
table.increments();
|
||||
table.integer('customer_id').unsigned();
|
||||
table.date('payment_date');
|
||||
table.integer('customer_id').unsigned().index().references('id').inTable('contacts');
|
||||
table.date('payment_date').index();
|
||||
table.decimal('amount', 13, 3).defaultTo(0);
|
||||
table.string('reference_no');
|
||||
table.integer('deposit_account_id').unsigned();
|
||||
table.string('reference_no').index();
|
||||
table.integer('deposit_account_id').unsigned().references('id').inTable('accounts');
|
||||
table.string('payment_receive_no');
|
||||
table.text('description');
|
||||
table.integer('user_id').unsigned();
|
||||
table.integer('user_id').unsigned().index();
|
||||
table.timestamps();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('payment_receives_entries', table => {
|
||||
table.increments();
|
||||
table.integer('payment_receive_id').unsigned();
|
||||
table.integer('invoice_id').unsigned();
|
||||
table.integer('payment_receive_id').unsigned().index().references('id').inTable('payment_receives');
|
||||
table.integer('invoice_id').unsigned().index().references('id').inTable('sales_invoices');
|
||||
table.decimal('payment_amount').unsigned();
|
||||
})
|
||||
};
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('bills', (table) => {
|
||||
table.increments();
|
||||
table.integer('vendor_id').unsigned();
|
||||
table.integer('vendor_id').unsigned().index().references('id').inTable('contacts');
|
||||
table.string('bill_number');
|
||||
table.date('bill_date');
|
||||
table.date('due_date');
|
||||
table.date('bill_date').index();
|
||||
table.date('due_date').index();
|
||||
table.string('reference_no');
|
||||
table.string('status');
|
||||
table.string('status').index();
|
||||
table.text('note');
|
||||
|
||||
table.decimal('amount', 13, 3).defaultTo(0);
|
||||
table.decimal('payment_amount', 13, 3).defaultTo(0);
|
||||
|
||||
table.string('inv_lot_number');
|
||||
table.string('inv_lot_number').index();
|
||||
table.timestamps();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('bills_payments', table => {
|
||||
table.increments();
|
||||
table.integer('vendor_id').unsigned();
|
||||
table.integer('vendor_id').unsigned().index().references('id').inTable('contacts');
|
||||
table.decimal('amount', 13, 3).defaultTo(0);
|
||||
table.integer('payment_account_id');
|
||||
table.string('payment_number');
|
||||
table.date('payment_date');
|
||||
table.integer('payment_account_id').unsigned().references('id').inTable('accounts');
|
||||
table.string('payment_number').index();
|
||||
table.date('payment_date').index();
|
||||
table.string('payment_method');
|
||||
table.string('reference');
|
||||
table.integer('user_id').unsigned();
|
||||
table.integer('user_id').unsigned().index();
|
||||
table.text('description');
|
||||
table.timestamps();
|
||||
});
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('inventory_transactions', table => {
|
||||
table.increments('id');
|
||||
table.date('date');
|
||||
table.date('date').index();
|
||||
|
||||
table.string('direction');
|
||||
table.string('direction').index();
|
||||
|
||||
table.integer('item_id').unsigned();
|
||||
table.integer('item_id').unsigned().index().references('id').inTable('items');
|
||||
table.integer('quantity').unsigned();
|
||||
table.decimal('rate', 13, 3).unsigned();
|
||||
|
||||
table.integer('lot_number');
|
||||
table.integer('lot_number').index();
|
||||
|
||||
table.string('transaction_type');
|
||||
table.integer('transaction_id').unsigned();
|
||||
table.string('transaction_type').index();
|
||||
table.integer('transaction_id').unsigned().index();
|
||||
|
||||
table.integer('entry_id').unsigned();
|
||||
table.integer('entry_id').unsigned().index();
|
||||
table.timestamps();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('items_entries', (table) => {
|
||||
table.increments();
|
||||
table.string('reference_type');
|
||||
table.string('reference_id');
|
||||
table.string('reference_type').index();
|
||||
table.string('reference_id').index();
|
||||
|
||||
table.integer('index').unsigned();
|
||||
table.integer('item_id');
|
||||
table.integer('item_id').unsigned().index().references('id').inTable('items');
|
||||
table.text('description');
|
||||
table.integer('discount').unsigned();
|
||||
table.integer('quantity').unsigned();
|
||||
|
||||
@@ -3,8 +3,8 @@ exports.up = function(knex) {
|
||||
return knex.schema.createTable('bills_payments_entries', table => {
|
||||
table.increments();
|
||||
|
||||
table.integer('bill_payment_id').unsigned();
|
||||
table.integer('bill_id').unsigned();
|
||||
table.integer('bill_payment_id').unsigned().index().references('id').inTable('bills_payments');
|
||||
table.integer('bill_id').unsigned().index();
|
||||
table.decimal('payment_amount', 13, 3).unsigned();
|
||||
})
|
||||
};
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.createTable('inventory_cost_lot_tracker', table => {
|
||||
table.increments();
|
||||
table.date('date');
|
||||
table.string('direction');
|
||||
table.date('date').index();
|
||||
table.string('direction').index();
|
||||
|
||||
table.integer('item_id').unsigned();
|
||||
table.integer('quantity').unsigned();
|
||||
table.integer('item_id').unsigned().index();
|
||||
table.integer('quantity').unsigned().index();
|
||||
table.decimal('rate', 13, 3);
|
||||
table.integer('remaining');
|
||||
table.integer('cost');
|
||||
table.integer('lot_number');
|
||||
table.integer('lot_number').index();
|
||||
|
||||
table.string('transaction_type');
|
||||
table.integer('transaction_id').unsigned();
|
||||
table.integer('entry_id').unsigned();
|
||||
table.string('transaction_type').index();
|
||||
table.integer('transaction_id').unsigned().index();
|
||||
table.integer('entry_id').unsigned().index();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user