refactored migrations
This commit is contained in:
parent
b6e07f0d8e
commit
01617f242c
@ -39,8 +39,7 @@ class Version200 extends Listener
|
||||
// Cache Clear
|
||||
Artisan::call('cache:clear');
|
||||
|
||||
// Update database
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
$this->updateDatabase();
|
||||
|
||||
$this->updateCompanies();
|
||||
|
||||
@ -61,6 +60,17 @@ class Version200 extends Listener
|
||||
$this->deleteOldFiles();
|
||||
}
|
||||
|
||||
public function updateDatabase()
|
||||
{
|
||||
DB::table('migrations')->insert([
|
||||
'id' => DB::table('migrations')->max('id') + 1,
|
||||
'migration' => '2017_09_14_000000_core_v1',
|
||||
'batch' => DB::table('migrations')->max('batch') + 1,
|
||||
]);
|
||||
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
}
|
||||
|
||||
protected function updateCompanies()
|
||||
{
|
||||
$company_id = session('company_id');
|
||||
|
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAccountsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('accounts', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->string('number');
|
||||
$table->string('currency_code');
|
||||
$table->double('opening_balance', 15, 4)->default('0.0000');
|
||||
$table->string('bank_name')->nullable();
|
||||
$table->string('bank_phone')->nullable();
|
||||
$table->text('bank_address')->nullable();
|
||||
$table->boolean('enabled');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('accounts');
|
||||
}
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateBillsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('bills', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('bill_number');
|
||||
$table->string('order_number')->nullable();
|
||||
$table->string('bill_status_code');
|
||||
$table->date('billed_at');
|
||||
$table->date('due_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code');
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->integer('vendor_id');
|
||||
$table->string('vendor_name');
|
||||
$table->string('vendor_email');
|
||||
$table->string('vendor_tax_number')->nullable();
|
||||
$table->string('vendor_phone')->nullable();
|
||||
$table->text('vendor_address')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->string('attachment')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'bill_number', 'deleted_at']);
|
||||
});
|
||||
|
||||
Schema::create('bill_items', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('bill_id');
|
||||
$table->integer('item_id')->nullable();
|
||||
$table->string('name');
|
||||
$table->string('sku')->nullable();
|
||||
$table->double('quantity', 7, 2);
|
||||
$table->double('price', 15, 4);
|
||||
$table->double('total', 15, 4);
|
||||
$table->float('tax', 15, 4)->default('0.0000');
|
||||
$table->integer('tax_id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::create('bill_statuses', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->string('code');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::create('bill_payments', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('bill_id');
|
||||
$table->integer('account_id');
|
||||
$table->date('paid_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code');
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->text('description')->nullable();
|
||||
$table->string('payment_method');
|
||||
$table->string('reference')->nullable();
|
||||
$table->string('attachment')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::create('bill_histories', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('bill_id');
|
||||
$table->string('status_code');
|
||||
$table->boolean('notify');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('bills');
|
||||
Schema::drop('bill_items');
|
||||
Schema::drop('bill_statuses');
|
||||
Schema::drop('bill_payments');
|
||||
Schema::drop('bill_histories');
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateCategoriesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('categories', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->string('type');
|
||||
$table->string('color');
|
||||
$table->boolean('enabled');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('categories');
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateCompaniesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('companies', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('domain')->nullable();
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('companies');
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateCurrenciesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('currencies', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->string('code');
|
||||
$table->double('rate', 15, 8);
|
||||
$table->tinyInteger('enabled')->default(0);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'code', 'deleted_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('currencies');
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateCustomersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('customers', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('name');
|
||||
$table->string('email');
|
||||
$table->string('tax_number')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->string('website')->nullable();
|
||||
$table->string('currency_code');
|
||||
$table->boolean('enabled');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'email', 'deleted_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('customers');
|
||||
}
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateInvoicesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('invoices', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('invoice_number');
|
||||
$table->string('order_number')->nullable();
|
||||
$table->string('invoice_status_code');
|
||||
$table->date('invoiced_at');
|
||||
$table->date('due_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code');
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->integer('customer_id');
|
||||
$table->string('customer_name');
|
||||
$table->string('customer_email');
|
||||
$table->string('customer_tax_number')->nullable();
|
||||
$table->string('customer_phone')->nullable();
|
||||
$table->text('customer_address')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->string('attachment')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'invoice_number', 'deleted_at']);
|
||||
});
|
||||
|
||||
Schema::create('invoice_items', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('invoice_id');
|
||||
$table->integer('item_id')->nullable();
|
||||
$table->string('name');
|
||||
$table->string('sku')->nullable();
|
||||
$table->double('quantity', 7, 2);
|
||||
$table->double('price', 15, 4);
|
||||
$table->double('total', 15, 4);
|
||||
$table->double('tax', 15, 4)->default('0.0000');
|
||||
$table->integer('tax_id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::create('invoice_statuses', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->string('code');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::create('invoice_payments', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('invoice_id');
|
||||
$table->integer('account_id');
|
||||
$table->date('paid_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code');
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->text('description')->nullable();
|
||||
$table->string('payment_method');
|
||||
$table->string('reference')->nullable();
|
||||
$table->string('attachment')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::create('invoice_histories', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('invoice_id');
|
||||
$table->string('status_code');
|
||||
$table->boolean('notify');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('invoices');
|
||||
Schema::drop('invoice_items');
|
||||
Schema::drop('invoice_statuses');
|
||||
Schema::drop('invoice_payments');
|
||||
Schema::drop('invoice_histories');
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateItemsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('items', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->string('sku');
|
||||
$table->text('description')->nullable();
|
||||
$table->double('sale_price', 15, 4);
|
||||
$table->double('purchase_price', 15, 4);
|
||||
$table->integer('quantity');
|
||||
$table->integer('category_id')->nullable();
|
||||
$table->integer('tax_id')->nullable();
|
||||
$table->string('picture')->nullable();
|
||||
$table->boolean('enabled');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'sku', 'deleted_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('items');
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateJobsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('queue');
|
||||
$table->longText('payload');
|
||||
$table->tinyInteger('attempts')->unsigned();
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
|
||||
$table->index(['queue', 'reserved_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateModulesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('modules', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('alias');
|
||||
$table->integer('status');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'alias', 'deleted_at']);
|
||||
});
|
||||
|
||||
Schema::create('module_histories', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('module_id');
|
||||
$table->string('category');
|
||||
$table->string('version');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'module_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('modules');
|
||||
Schema::drop('module_histories');
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateNotificationsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('notifications', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('type');
|
||||
$table->morphs('notifiable');
|
||||
$table->text('data');
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('notifications');
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePasswordResetsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('password_resets', function (Blueprint $table) {
|
||||
$table->string('email');
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
|
||||
$table->index('email');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('password_resets');
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePaymentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('payments', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('account_id');
|
||||
$table->date('paid_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code');
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->integer('vendor_id')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->integer('category_id');
|
||||
$table->string('payment_method');
|
||||
$table->string('reference')->nullable();
|
||||
$table->string('attachment')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('payments');
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRevenuesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('revenues', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('account_id');
|
||||
$table->date('paid_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code');
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->integer('customer_id')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->integer('category_id');
|
||||
$table->string('payment_method');
|
||||
$table->string('reference')->nullable();
|
||||
$table->string('attachment')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('revenues');
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRolesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Create table for storing roles
|
||||
Schema::create('roles', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('display_name');
|
||||
$table->string('description')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique('name');
|
||||
});
|
||||
|
||||
// Create table for associating roles to users (Many To Many Polymorphic)
|
||||
Schema::create('user_roles', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('role_id')->unsigned();
|
||||
$table->string('user_type');
|
||||
|
||||
$table->foreign('role_id')->references('id')->on('roles')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
|
||||
$table->primary(['user_id', 'role_id', 'user_type']);
|
||||
});
|
||||
|
||||
// Create table for storing permissions
|
||||
Schema::create('permissions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('display_name');
|
||||
$table->string('description')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique('name');
|
||||
});
|
||||
|
||||
// Create table for associating permissions to roles (Many-to-Many)
|
||||
Schema::create('role_permissions', function (Blueprint $table) {
|
||||
$table->integer('role_id')->unsigned();
|
||||
$table->integer('permission_id')->unsigned();
|
||||
|
||||
$table->foreign('role_id')->references('id')->on('roles')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreign('permission_id')->references('id')->on('permissions')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
|
||||
$table->primary(['role_id', 'permission_id']);
|
||||
});
|
||||
|
||||
// Create table for associating permissions to users (Many To Many Polymorphic)
|
||||
Schema::create('user_permissions', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('permission_id')->unsigned();
|
||||
$table->string('user_type');
|
||||
|
||||
$table->foreign('permission_id')->references('id')->on('permissions')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
|
||||
$table->primary(['user_id', 'permission_id', 'user_type']);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
// Cascade table first
|
||||
Schema::dropIfExists('user_permissions');
|
||||
Schema::dropIfExists('role_permissions');
|
||||
Schema::dropIfExists('permissions');
|
||||
Schema::dropIfExists('user_roles');
|
||||
Schema::dropIfExists('roles');
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSessionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->unique();
|
||||
$table->unsignedInteger('user_id')->nullable();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->text('payload');
|
||||
$table->integer('last_activity');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSettingsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('settings', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('key');
|
||||
$table->text('value')->nullable();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'key']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('settings');
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateTaxesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('taxes', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->double('rate', 15, 4);
|
||||
$table->boolean('enabled');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('taxes');
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateTransfersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('transfers', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('payment_id');
|
||||
$table->integer('revenue_id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('transfers');
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('email');
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->string('picture')->nullable();
|
||||
$table->timestamp('last_logged_in_at')->nullable();
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['email', 'deleted_at']);
|
||||
});
|
||||
|
||||
// Create table for associating companies to users (Many To Many Polymorphic)
|
||||
Schema::create('user_companies', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('company_id')->unsigned();
|
||||
$table->string('user_type');
|
||||
|
||||
$table->primary(['user_id', 'company_id', 'user_type']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
// Cascade table first
|
||||
Schema::dropIfExists('user_companies');
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateVendorsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('vendors', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('name');
|
||||
$table->string('email');
|
||||
$table->string('tax_number')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->string('website')->nullable();
|
||||
$table->string('currency_code');
|
||||
$table->boolean('enabled');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'email', 'deleted_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('vendors');
|
||||
}
|
||||
}
|
596
database/migrations/2017_09_14_000000_core_v1.php
Normal file
596
database/migrations/2017_09_14_000000_core_v1.php
Normal file
@ -0,0 +1,596 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV1 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Accounts
|
||||
Schema::create('accounts', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->string('number');
|
||||
$table->string('currency_code');
|
||||
$table->double('opening_balance', 15, 4)->default('0.0000');
|
||||
$table->string('bank_name')->nullable();
|
||||
$table->string('bank_phone')->nullable();
|
||||
$table->text('bank_address')->nullable();
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
// Bills
|
||||
Schema::create('bills', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('bill_number');
|
||||
$table->string('order_number')->nullable();
|
||||
$table->string('bill_status_code');
|
||||
$table->dateTime('billed_at');
|
||||
$table->dateTime('due_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code');
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->integer('category_id')->default(1);
|
||||
$table->integer('vendor_id');
|
||||
$table->string('vendor_name');
|
||||
$table->string('vendor_email')->nullable();
|
||||
$table->string('vendor_tax_number')->nullable();
|
||||
$table->string('vendor_phone')->nullable();
|
||||
$table->text('vendor_address')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->integer('parent_id')->default(0);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'bill_number', 'deleted_at']);
|
||||
});
|
||||
|
||||
Schema::create('bill_histories', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('bill_id');
|
||||
$table->string('status_code');
|
||||
$table->boolean('notify');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::create('bill_items', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('bill_id');
|
||||
$table->integer('item_id')->nullable();
|
||||
$table->string('name');
|
||||
$table->string('sku')->nullable();
|
||||
$table->double('quantity', 7, 2);
|
||||
$table->double('price', 15, 4);
|
||||
$table->double('total', 15, 4);
|
||||
$table->float('tax', 15, 4)->default('0.0000');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::create('bill_item_taxes', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('bill_id');
|
||||
$table->integer('bill_item_id');
|
||||
$table->integer('tax_id');
|
||||
$table->string('name');
|
||||
$table->double('amount', 15, 4)->default('0.0000');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::create('bill_statuses', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->string('code');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::create('bill_totals', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('bill_id');
|
||||
$table->string('code')->nullable();
|
||||
$table->string('name');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->integer('sort_order');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
// Categories
|
||||
Schema::create('categories', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->string('type');
|
||||
$table->string('color');
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
// Companies
|
||||
Schema::create('companies', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('domain');
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
// Currencies
|
||||
Schema::create('currencies', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->string('code');
|
||||
$table->double('rate', 15, 8);
|
||||
$table->string('precision')->nullable();
|
||||
$table->string('symbol')->nullable();
|
||||
$table->integer('symbol_first')->default(1);
|
||||
$table->string('decimal_mark')->nullable();
|
||||
$table->string('thousands_separator')->nullable();
|
||||
$table->tinyInteger('enabled')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'code', 'deleted_at']);
|
||||
});
|
||||
|
||||
// Invoices
|
||||
Schema::create('invoices', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('invoice_number');
|
||||
$table->string('order_number')->nullable();
|
||||
$table->string('invoice_status_code');
|
||||
$table->dateTime('invoiced_at');
|
||||
$table->dateTime('due_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code');
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->integer('category_id')->default(1);
|
||||
$table->integer('customer_id');
|
||||
$table->string('customer_name');
|
||||
$table->string('customer_email')->nullable();
|
||||
$table->string('customer_tax_number')->nullable();
|
||||
$table->string('customer_phone')->nullable();
|
||||
$table->text('customer_address')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->integer('parent_id')->default(0);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'invoice_number', 'deleted_at']);
|
||||
});
|
||||
|
||||
Schema::create('invoice_histories', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('invoice_id');
|
||||
$table->string('status_code');
|
||||
$table->boolean('notify');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::create('invoice_items', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('invoice_id');
|
||||
$table->integer('item_id')->nullable();
|
||||
$table->string('name');
|
||||
$table->string('sku')->nullable();
|
||||
$table->double('quantity', 7, 2);
|
||||
$table->double('price', 15, 4);
|
||||
$table->double('total', 15, 4);
|
||||
$table->double('tax', 15, 4)->default('0.0000');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::create('invoice_item_taxes', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('invoice_id');
|
||||
$table->integer('invoice_item_id');
|
||||
$table->integer('tax_id');
|
||||
$table->string('name');
|
||||
$table->double('amount', 15, 4)->default('0.0000');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::create('invoice_statuses', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->string('code');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::create('invoice_totals', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('invoice_id');
|
||||
$table->string('code')->nullable();
|
||||
$table->string('name');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->integer('sort_order');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
// Items
|
||||
Schema::create('items', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->string('sku');
|
||||
$table->text('description')->nullable();
|
||||
$table->double('sale_price', 15, 4);
|
||||
$table->double('purchase_price', 15, 4);
|
||||
$table->integer('quantity');
|
||||
$table->integer('category_id')->nullable();
|
||||
$table->integer('tax_id')->nullable();
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'sku', 'deleted_at']);
|
||||
});
|
||||
|
||||
// Jobs
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('queue');
|
||||
$table->longText('payload');
|
||||
$table->tinyInteger('attempts')->unsigned();
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
|
||||
$table->index(['queue', 'reserved_at']);
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
|
||||
// Media
|
||||
Schema::create('media', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('disk', 32);
|
||||
$table->string('directory', 68);
|
||||
$table->string('filename', 121);
|
||||
$table->string('extension', 28);
|
||||
$table->string('mime_type', 128);
|
||||
$table->string('aggregate_type', 32);
|
||||
$table->integer('size')->unsigned();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['disk', 'directory']);
|
||||
$table->index('aggregate_type');
|
||||
$table->unique(['disk', 'directory', 'filename', 'extension', 'deleted_at']);
|
||||
});
|
||||
|
||||
Schema::create('mediables', function (Blueprint $table) {
|
||||
$table->integer('media_id')->unsigned();
|
||||
$table->string('mediable_type', 152);
|
||||
$table->integer('mediable_id')->unsigned();
|
||||
$table->string('tag', 68);
|
||||
$table->integer('order')->unsigned();
|
||||
|
||||
$table->primary(['media_id', 'mediable_type', 'mediable_id', 'tag']);
|
||||
$table->index(['mediable_id', 'mediable_type']);
|
||||
$table->index('tag');
|
||||
$table->index('order');
|
||||
$table->foreign('media_id')->references('id')->on('media')->onDelete('cascade');
|
||||
});
|
||||
|
||||
// Modules
|
||||
Schema::create('modules', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('alias');
|
||||
$table->integer('status');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'alias', 'deleted_at']);
|
||||
});
|
||||
|
||||
Schema::create('module_histories', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('module_id');
|
||||
$table->string('category');
|
||||
$table->string('version');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'module_id']);
|
||||
});
|
||||
|
||||
// Notifications
|
||||
Schema::create('notifications', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('type');
|
||||
$table->morphs('notifiable');
|
||||
$table->text('data');
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// Password resets
|
||||
Schema::create('password_resets', function (Blueprint $table) {
|
||||
$table->string('email');
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
|
||||
$table->index('email');
|
||||
});
|
||||
|
||||
// Permissions
|
||||
Schema::create('permissions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('display_name');
|
||||
$table->string('description')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique('name');
|
||||
});
|
||||
|
||||
Schema::create('roles', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('display_name');
|
||||
$table->string('description')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique('name');
|
||||
});
|
||||
|
||||
Schema::create('role_permissions', function (Blueprint $table) {
|
||||
$table->integer('role_id')->unsigned();
|
||||
$table->integer('permission_id')->unsigned();
|
||||
|
||||
$table->foreign('role_id')->references('id')->on('roles')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreign('permission_id')->references('id')->on('permissions')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
|
||||
$table->primary(['role_id', 'permission_id']);
|
||||
});
|
||||
|
||||
Schema::create('user_permissions', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('permission_id')->unsigned();
|
||||
$table->string('user_type');
|
||||
|
||||
$table->foreign('permission_id')->references('id')->on('permissions')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
|
||||
$table->primary(['user_id', 'permission_id', 'user_type']);
|
||||
});
|
||||
|
||||
Schema::create('user_roles', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('role_id')->unsigned();
|
||||
$table->string('user_type');
|
||||
|
||||
$table->foreign('role_id')->references('id')->on('roles')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
|
||||
$table->primary(['user_id', 'role_id', 'user_type']);
|
||||
});
|
||||
|
||||
// Reconciliations
|
||||
Schema::create('reconciliations', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('account_id');
|
||||
$table->dateTime('started_at');
|
||||
$table->dateTime('ended_at');
|
||||
$table->double('closing_balance', 15, 4)->default('0.0000');
|
||||
$table->boolean('reconciled');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
// Recurring
|
||||
Schema::create('recurring', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->morphs('recurable');
|
||||
$table->string('frequency');
|
||||
$table->integer('interval')->default(1);
|
||||
$table->dateTime('started_at');
|
||||
$table->integer('count')->default(0);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
// Sessions
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->unique();
|
||||
$table->unsignedInteger('user_id')->nullable();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->text('payload');
|
||||
$table->integer('last_activity');
|
||||
});
|
||||
|
||||
// Settings
|
||||
Schema::create('settings', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('key');
|
||||
$table->text('value')->nullable();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'key']);
|
||||
});
|
||||
|
||||
// Taxes
|
||||
Schema::create('taxes', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->double('rate', 15, 4);
|
||||
$table->string('type')->default('normal');
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
// Transfers
|
||||
Schema::create('transfers', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('payment_id');
|
||||
$table->integer('revenue_id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
// Users
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('email');
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamp('last_logged_in_at')->nullable();
|
||||
$table->string('locale')->default(config('app.locale'));
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['email', 'deleted_at']);
|
||||
});
|
||||
|
||||
Schema::create('user_companies', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('company_id')->unsigned();
|
||||
$table->string('user_type');
|
||||
|
||||
$table->primary(['user_id', 'company_id', 'user_type']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('accounts');
|
||||
Schema::drop('bills');
|
||||
Schema::drop('bill_histories');
|
||||
Schema::drop('bill_items');
|
||||
Schema::drop('bill_item_taxes');
|
||||
Schema::drop('bill_statuses');
|
||||
Schema::drop('bill_totals');
|
||||
Schema::drop('categories');
|
||||
Schema::drop('companies');
|
||||
Schema::drop('currencies');
|
||||
Schema::drop('invoices');
|
||||
Schema::drop('invoice_histories');
|
||||
Schema::drop('invoice_items');
|
||||
Schema::drop('invoice_item_taxes');
|
||||
Schema::drop('invoice_statuses');
|
||||
Schema::drop('invoice_totals');
|
||||
Schema::drop('items');
|
||||
Schema::drop('jobs');
|
||||
Schema::drop('failed_jobs');
|
||||
Schema::drop('media');
|
||||
Schema::drop('mediables');
|
||||
Schema::drop('modules');
|
||||
Schema::drop('module_histories');
|
||||
Schema::drop('notifications');
|
||||
Schema::drop('password_resets');
|
||||
|
||||
// Cascade table first
|
||||
Schema::drop('user_permissions');
|
||||
Schema::drop('role_permissions');
|
||||
Schema::drop('permissions');
|
||||
Schema::drop('user_roles');
|
||||
Schema::drop('roles');
|
||||
|
||||
Schema::drop('reconciliations');
|
||||
Schema::drop('recurring');
|
||||
Schema::drop('sessions');
|
||||
Schema::drop('settings');
|
||||
Schema::drop('taxes');
|
||||
Schema::drop('transfers');
|
||||
Schema::drop('users');
|
||||
Schema::drop('user_companies');
|
||||
}
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use App\Models\Common\Company;
|
||||
use App\Models\Purchase\Bill;
|
||||
use App\Models\Purchase\BillItem;
|
||||
use App\Models\Purchase\BillTotal;
|
||||
use App\Models\Setting\Tax;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateBillTotalsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('bill_totals', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('bill_id');
|
||||
$table->string('code')->nullable();
|
||||
$table->string('name');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->integer('sort_order');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Model::unguard();
|
||||
|
||||
$companies = Company::all();
|
||||
|
||||
foreach ($companies as $company) {
|
||||
$bills = Bill::where('company_id', $company->id)->get();
|
||||
|
||||
foreach ($bills as $bill) {
|
||||
$bill_items = BillItem::where('company_id', $company->id)->where('bill_id', $bill->id)->get();
|
||||
|
||||
$taxes = [];
|
||||
$tax_total = 0;
|
||||
$sub_total = 0;
|
||||
|
||||
foreach ($bill_items as $bill_item) {
|
||||
unset($tax_object);
|
||||
|
||||
$bill_item->total = $bill_item->price * $bill_item->quantity;
|
||||
|
||||
if (!empty($bill_item->tax_id)) {
|
||||
$tax_object = Tax::where('company_id', $company->id)->where('id', $bill_item->tax_id)->first();
|
||||
|
||||
$bill_item->tax = (($bill_item->price * $bill_item->quantity) / 100) * $tax_object->rate;
|
||||
}
|
||||
|
||||
$bill_item->update();
|
||||
|
||||
if (isset($tax_object)) {
|
||||
if (array_key_exists($bill_item->tax_id, $taxes)) {
|
||||
$taxes[$bill_item->tax_id]['amount'] += $bill_item->tax;
|
||||
} else {
|
||||
$taxes[$bill_item->tax_id] = [
|
||||
'name' => $tax_object->name,
|
||||
'amount' => $bill_item->tax
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$tax_total += $bill_item->tax;
|
||||
$sub_total += $bill_item->price * $bill_item->quantity;
|
||||
}
|
||||
|
||||
$bill->amount = $sub_total + $tax_total;
|
||||
|
||||
$bill->update();
|
||||
|
||||
// Added bill total sub total
|
||||
$bill_sub_total = [
|
||||
'company_id' => $company->id,
|
||||
'bill_id' => $bill->id,
|
||||
'code' => 'sub_total',
|
||||
'name' => 'bills.sub_total',
|
||||
'amount' => $sub_total,
|
||||
'sort_order' => 1,
|
||||
];
|
||||
|
||||
BillTotal::create($bill_sub_total);
|
||||
|
||||
$sort_order = 2;
|
||||
|
||||
// Added bill total taxes
|
||||
if ($taxes) {
|
||||
foreach ($taxes as $tax) {
|
||||
$bill_tax_total = [
|
||||
'company_id' => $company->id,
|
||||
'bill_id' => $bill->id,
|
||||
'code' => 'tax',
|
||||
'name' => $tax['name'],
|
||||
'amount' => $tax['amount'],
|
||||
'sort_order' => $sort_order,
|
||||
];
|
||||
|
||||
BillTotal::create($bill_tax_total);
|
||||
|
||||
$sort_order++;
|
||||
}
|
||||
}
|
||||
|
||||
// Added bill total total
|
||||
$bill_total = [
|
||||
'company_id' => $company->id,
|
||||
'bill_id' => $bill->id,
|
||||
'code' => 'total',
|
||||
'name' => 'bills.total',
|
||||
'amount' => $sub_total + $tax_total,
|
||||
'sort_order' => $sort_order,
|
||||
];
|
||||
|
||||
BillTotal::create($bill_total);
|
||||
}
|
||||
}
|
||||
|
||||
Model::reguard();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('bill_totals');
|
||||
}
|
||||
}
|
@ -1,140 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use App\Models\Common\Company;
|
||||
use App\Models\Sale\Invoice;
|
||||
use App\Models\Sale\InvoiceItem;
|
||||
use App\Models\Sale\InvoiceTotal;
|
||||
use App\Models\Setting\Tax;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateInvoiceTotalsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('invoice_totals', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('invoice_id');
|
||||
$table->string('code')->nullable();
|
||||
$table->string('name');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->integer('sort_order');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Model::unguard();
|
||||
|
||||
$companies = Company::all();
|
||||
|
||||
foreach ($companies as $company) {
|
||||
$invoices = Invoice::where('company_id', $company->id)->get();
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
$invoice_items = InvoiceItem::where('company_id', $company->id)->where('invoice_id', $invoice->id)->get();
|
||||
|
||||
$taxes = [];
|
||||
$tax_total = 0;
|
||||
$sub_total = 0;
|
||||
|
||||
foreach ($invoice_items as $invoice_item) {
|
||||
unset($tax_object);
|
||||
|
||||
$invoice_item->total = $invoice_item->price * $invoice_item->quantity;
|
||||
|
||||
if (!empty($invoice_item->tax_id)) {
|
||||
$tax_object = Tax::where('company_id', $company->id)->where('id', $invoice_item->tax_id)->first();
|
||||
|
||||
$invoice_item->tax = (($invoice_item->price * $invoice_item->quantity) / 100) * $tax_object->rate;
|
||||
}
|
||||
|
||||
$invoice_item->update();
|
||||
|
||||
if (isset($tax_object)) {
|
||||
if (array_key_exists($invoice_item->tax_id, $taxes)) {
|
||||
$taxes[$invoice_item->tax_id]['amount'] += $invoice_item->tax;
|
||||
} else {
|
||||
$taxes[$invoice_item->tax_id] = [
|
||||
'name' => $tax_object->name,
|
||||
'amount' => $invoice_item->tax
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$tax_total += $invoice_item->tax;
|
||||
$sub_total += $invoice_item->price * $invoice_item->quantity;
|
||||
}
|
||||
|
||||
$invoice->amount = $sub_total + $tax_total;
|
||||
|
||||
$invoice->update();
|
||||
|
||||
// Added invoice total sub total
|
||||
$invoice_sub_total = [
|
||||
'company_id' => $company->id,
|
||||
'invoice_id' => $invoice->id,
|
||||
'code' => 'sub_total',
|
||||
'name' => 'invoices.sub_total',
|
||||
'amount' => $sub_total,
|
||||
'sort_order' => 1,
|
||||
];
|
||||
|
||||
InvoiceTotal::create($invoice_sub_total);
|
||||
|
||||
$sort_order = 2;
|
||||
|
||||
// Added invoice total taxes
|
||||
if ($taxes) {
|
||||
foreach ($taxes as $tax) {
|
||||
$invoice_tax_total = [
|
||||
'company_id' => $company->id,
|
||||
'invoice_id' => $invoice->id,
|
||||
'code' => 'tax',
|
||||
'name' => $tax['name'],
|
||||
'amount' => $tax['amount'],
|
||||
'sort_order' => $sort_order,
|
||||
];
|
||||
|
||||
InvoiceTotal::create($invoice_tax_total);
|
||||
|
||||
$sort_order++;
|
||||
}
|
||||
}
|
||||
|
||||
// Added invoice total total
|
||||
$invoice_total = [
|
||||
'company_id' => $company->id,
|
||||
'invoice_id' => $invoice->id,
|
||||
'code' => 'total',
|
||||
'name' => 'invoices.total',
|
||||
'amount' => $sub_total + $tax_total,
|
||||
'sort_order' => $sort_order,
|
||||
];
|
||||
|
||||
InvoiceTotal::create($invoice_total);
|
||||
}
|
||||
}
|
||||
|
||||
Model::reguard();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('invoice_totals');
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateFailedJobsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddCurrencyColumns extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('currencies', function (Blueprint $table) {
|
||||
$table->string('precision')->nullable();
|
||||
$table->string('symbol')->nullable();
|
||||
$table->integer('symbol_first')->default(1);
|
||||
$table->string('decimal_mark')->nullable();
|
||||
$table->string('thousands_separator')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('currencies', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'precision',
|
||||
'symbol',
|
||||
'symbol_first',
|
||||
'decimal_mark',
|
||||
'thousands_separator',
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateMediableTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('media', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('disk', 32);
|
||||
$table->string('directory', 68);
|
||||
$table->string('filename', 121);
|
||||
$table->string('extension', 28);
|
||||
$table->string('mime_type', 128);
|
||||
$table->string('aggregate_type', 32);
|
||||
$table->integer('size')->unsigned();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['disk', 'directory']);
|
||||
$table->unique(['disk', 'directory', 'filename', 'extension']);
|
||||
$table->index('aggregate_type');
|
||||
});
|
||||
|
||||
Schema::create('mediables', function (Blueprint $table) {
|
||||
$table->integer('media_id')->unsigned();
|
||||
$table->string('mediable_type', 152);
|
||||
$table->integer('mediable_id')->unsigned();
|
||||
$table->string('tag', 68);
|
||||
$table->integer('order')->unsigned();
|
||||
|
||||
$table->primary(['media_id', 'mediable_type', 'mediable_id', 'tag']);
|
||||
$table->index(['mediable_id', 'mediable_type']);
|
||||
$table->index('tag');
|
||||
$table->index('order');
|
||||
$table->foreign('media_id')->references('id')->on('media')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('mediables');
|
||||
Schema::drop('media');
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class DropAttachmentColumnBillPaymentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('bill_payments', function (Blueprint $table) {
|
||||
$table->dropColumn('attachment');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('bill_payments', function (Blueprint $table) {
|
||||
$table->string('attachment')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class DropAttachmentColumnBillsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('bills', function (Blueprint $table) {
|
||||
$table->dropColumn('attachment');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('bills', function (Blueprint $table) {
|
||||
$table->string('attachment')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class DropAttachmentColumnInvoicePaymentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('invoice_payments', function (Blueprint $table) {
|
||||
$table->dropColumn('attachment');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('invoice_payments', function (Blueprint $table) {
|
||||
$table->string('attachment')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class DropAttachmentColumnInvoicesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->dropColumn('attachment');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->string('attachment')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class DropAttachmentColumnPaymentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('payments', function (Blueprint $table) {
|
||||
$table->dropColumn('attachment');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('payments', function (Blueprint $table) {
|
||||
$table->string('attachment')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class DropAttachmentColumnRevenuesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('revenues', function (Blueprint $table) {
|
||||
$table->dropColumn('attachment');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('revenues', function (Blueprint $table) {
|
||||
$table->string('attachment')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class DropPictureColumnItemsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->dropColumn('picture');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->string('picture')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class DropPictureColumnUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('picture');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('picture')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddCategoryColumnInvoicesBills extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->integer('category_id')->default();
|
||||
});
|
||||
|
||||
Schema::table('bills', function (Blueprint $table) {
|
||||
$table->integer('category_id')->default();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->dropColumn('category_id');
|
||||
});
|
||||
|
||||
Schema::table('bills', function (Blueprint $table) {
|
||||
$table->dropColumn('category_id');
|
||||
});
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRecurringTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('recurring', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->morphs('recurable');
|
||||
$table->string('frequency');
|
||||
$table->integer('interval')->default(1);
|
||||
$table->date('started_at');
|
||||
$table->integer('count')->default(0);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('recurring');
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddParentColumn extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->integer('parent_id')->default(0);
|
||||
});
|
||||
|
||||
Schema::table('revenues', function (Blueprint $table) {
|
||||
$table->integer('parent_id')->default(0);
|
||||
});
|
||||
|
||||
Schema::table('bills', function (Blueprint $table) {
|
||||
$table->integer('parent_id')->default(0);
|
||||
});
|
||||
|
||||
Schema::table('payments', function (Blueprint $table) {
|
||||
$table->integer('parent_id')->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->dropColumn('parent_id');
|
||||
});
|
||||
|
||||
Schema::table('revenues', function (Blueprint $table) {
|
||||
$table->dropColumn('parent_id');
|
||||
});
|
||||
|
||||
Schema::table('bills', function (Blueprint $table) {
|
||||
$table->dropColumn('parent_id');
|
||||
});
|
||||
|
||||
Schema::table('payments', function (Blueprint $table) {
|
||||
$table->dropColumn('parent_id');
|
||||
});
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ModifyEmailColumn extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('customers', function (Blueprint $table) {
|
||||
$table->string('email')->nullable()->change();
|
||||
});
|
||||
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->string('customer_email')->nullable()->change();
|
||||
});
|
||||
|
||||
Schema::table('vendors', function (Blueprint $table) {
|
||||
$table->string('email')->nullable()->change();
|
||||
});
|
||||
|
||||
Schema::table('bills', function (Blueprint $table) {
|
||||
$table->string('vendor_email')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ModifyEnabledColumn extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
$table->boolean('enabled')->default(1)->change();
|
||||
});
|
||||
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->boolean('enabled')->default(1)->change();
|
||||
});
|
||||
|
||||
Schema::table('currencies', function (Blueprint $table) {
|
||||
$table->boolean('enabled')->default(1)->change();
|
||||
});
|
||||
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->boolean('enabled')->default(1)->change();
|
||||
});
|
||||
|
||||
Schema::table('customers', function (Blueprint $table) {
|
||||
$table->boolean('enabled')->default(1)->change();
|
||||
});
|
||||
|
||||
Schema::table('vendors', function (Blueprint $table) {
|
||||
$table->boolean('enabled')->default(1)->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ModifyDateColumn extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('bills', function (Blueprint $table) {
|
||||
$table->dateTime('billed_at')->change();
|
||||
$table->dateTime('due_at')->change();
|
||||
});
|
||||
|
||||
Schema::table('bill_payments', function (Blueprint $table) {
|
||||
$table->dateTime('paid_at')->change();
|
||||
});
|
||||
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->dateTime('invoiced_at')->change();
|
||||
$table->dateTime('due_at')->change();
|
||||
});
|
||||
|
||||
Schema::table('invoice_payments', function (Blueprint $table) {
|
||||
$table->dateTime('paid_at')->change();
|
||||
});
|
||||
|
||||
Schema::table('payments', function (Blueprint $table) {
|
||||
$table->dateTime('paid_at')->change();
|
||||
});
|
||||
|
||||
Schema::table('revenues', function (Blueprint $table) {
|
||||
$table->dateTime('paid_at')->change();
|
||||
});
|
||||
|
||||
Schema::table('recurring', function (Blueprint $table) {
|
||||
$table->dateTime('started_at')->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddReferenceColumnCustomers extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('customers', function (Blueprint $table) {
|
||||
$table->string('reference')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('customers', function (Blueprint $table) {
|
||||
$table->dropColumn('reference');
|
||||
});
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddReferenceColumnVendors extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('vendors', function (Blueprint $table) {
|
||||
$table->string('reference')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('vendors', function (Blueprint $table) {
|
||||
$table->dropColumn('reference');
|
||||
});
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateBillItemTaxesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('bill_item_taxes', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('bill_id');
|
||||
$table->integer('bill_item_id');
|
||||
$table->integer('tax_id');
|
||||
$table->string('name');
|
||||
$table->double('amount', 15, 4)->default('0.0000');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('bill_item_taxes');
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateInvoiceItemTaxesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('invoice_item_taxes', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('invoice_id');
|
||||
$table->integer('invoice_item_id');
|
||||
$table->integer('tax_id');
|
||||
$table->string('name');
|
||||
$table->double('amount', 15, 4)->default('0.0000');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('invoice_item_taxes');
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddReconciledColumn extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('bill_payments', function (Blueprint $table) {
|
||||
$table->boolean('reconciled')->default(0);
|
||||
});
|
||||
|
||||
Schema::table('invoice_payments', function (Blueprint $table) {
|
||||
$table->boolean('reconciled')->default(0);
|
||||
});
|
||||
|
||||
Schema::table('payments', function (Blueprint $table) {
|
||||
$table->boolean('reconciled')->default(0);
|
||||
});
|
||||
|
||||
Schema::table('revenues', function (Blueprint $table) {
|
||||
$table->boolean('reconciled')->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('bill_payments', function (Blueprint $table) {
|
||||
$table->dropColumn('reconciled');
|
||||
});
|
||||
|
||||
Schema::table('invoice_payments', function (Blueprint $table) {
|
||||
$table->dropColumn('reconciled');
|
||||
});
|
||||
|
||||
Schema::table('payments', function (Blueprint $table) {
|
||||
$table->dropColumn('reconciled');
|
||||
});
|
||||
|
||||
Schema::table('revenues', function (Blueprint $table) {
|
||||
$table->dropColumn('reconciled');
|
||||
});
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateReconciliationsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('reconciliations', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('account_id');
|
||||
$table->dateTime('started_at');
|
||||
$table->dateTime('ended_at');
|
||||
$table->double('closing_balance', 15, 4)->default('0.0000');
|
||||
$table->boolean('reconciled');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('reconciliations');
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddTaxColumns extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('taxes', function (Blueprint $table) {
|
||||
$table->string('type')->default('normal');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('taxes', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'type',
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class DropTaxIdColumn extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('bill_items', function (Blueprint $table) {
|
||||
$table->dropColumn('tax_id');
|
||||
});
|
||||
|
||||
Schema::table('invoice_items', function (Blueprint $table) {
|
||||
$table->dropColumn('tax_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('bill_items', function (Blueprint $table) {
|
||||
$table->integer('tax_id')->default(0);
|
||||
});
|
||||
|
||||
Schema::table('invoice_items', function (Blueprint $table) {
|
||||
$table->integer('tax_id')->default(0);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ModifyDeletedAtColumnMediaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->dropUnique(['disk', 'directory', 'filename', 'extension']);
|
||||
|
||||
$table->unique(['disk', 'directory', 'filename', 'extension', 'deleted_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->dropUnique(['disk', 'directory', 'filename', 'extension', 'deleted_at']);
|
||||
|
||||
$table->unique(['disk', 'directory', 'filename', 'extension']);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddFooterColumnInvoicesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->text('footer')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->dropColumn('footer');
|
||||
});
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateContactsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('contacts', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('type');
|
||||
$table->string('name');
|
||||
$table->string('email')->nullable();
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('tax_number')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->string('website')->nullable();
|
||||
$table->string('currency_code', 3);
|
||||
$table->boolean('enabled');
|
||||
$table->string('reference')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'type']);
|
||||
$table->unique(['company_id', 'type', 'email', 'deleted_at']);
|
||||
});
|
||||
|
||||
$rename_bills = [
|
||||
'vendor_id' => 'contact_id',
|
||||
'vendor_name' => 'contact_name',
|
||||
'vendor_email' => 'contact_email',
|
||||
'vendor_tax_number' => 'contact_tax_number',
|
||||
'vendor_phone' => 'contact_phone',
|
||||
'vendor_address' => 'contact_address',
|
||||
];
|
||||
|
||||
foreach ($rename_bills as $from => $to) {
|
||||
Schema::table('bills', function (Blueprint $table) use ($from, $to) {
|
||||
$table->renameColumn($from, $to);
|
||||
});
|
||||
}
|
||||
|
||||
$rename_invoices = [
|
||||
'customer_id' => 'contact_id',
|
||||
'customer_name' => 'contact_name',
|
||||
'customer_email' => 'contact_email',
|
||||
'customer_tax_number' => 'contact_tax_number',
|
||||
'customer_phone' => 'contact_phone',
|
||||
'customer_address' => 'contact_address',
|
||||
];
|
||||
|
||||
foreach ($rename_invoices as $from => $to) {
|
||||
Schema::table('invoices', function (Blueprint $table) use ($from, $to) {
|
||||
$table->renameColumn($from, $to);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('contacts');
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateDashboardsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('dashboards', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id']);
|
||||
});
|
||||
|
||||
Schema::create('user_dashboards', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('dashboard_id')->unsigned();
|
||||
$table->string('user_type', 20);
|
||||
|
||||
$table->primary(['user_id', 'dashboard_id', 'user_type']);
|
||||
});
|
||||
|
||||
Schema::create('widgets', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('dashboard_id');
|
||||
$table->string('class');
|
||||
$table->string('name');
|
||||
$table->text('settings')->nullable();
|
||||
$table->integer('sort')->default(0);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'dashboard_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('dashboards');
|
||||
Schema::drop('user_dashboards');
|
||||
Schema::drop('widgets');
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateEmailTemplatesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('email_templates', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('alias');
|
||||
$table->string('subject');
|
||||
$table->text('body');
|
||||
$table->text('params')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'alias', 'deleted_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('email_templates');
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateFirewallTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('firewall_ips', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('ip');
|
||||
$table->integer('log_id')->nullable();
|
||||
$table->boolean('blocked')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('ip');
|
||||
$table->unique(['ip', 'deleted_at']);
|
||||
});
|
||||
|
||||
Schema::create('firewall_logs', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('ip');
|
||||
$table->string('level')->default('medium');
|
||||
$table->string('middleware');
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('url')->nullable();
|
||||
$table->string('referrer')->nullable();
|
||||
$table->text('request')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('ip');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('firewall_ips');
|
||||
Schema::drop('firewall_logs');
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateReportsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('reports', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('class');
|
||||
$table->string('name');
|
||||
$table->text('description');
|
||||
$table->string('group');
|
||||
$table->string('period');
|
||||
$table->string('basis');
|
||||
$table->string('chart');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('reports');
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateTransactionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('transactions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('type');
|
||||
$table->integer('account_id');
|
||||
$table->dateTime('paid_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code', 3);
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->integer('document_id')->nullable();
|
||||
$table->integer('contact_id')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->integer('category_id');
|
||||
$table->string('payment_method');
|
||||
$table->string('reference')->nullable();
|
||||
$table->integer('parent_id')->default(0);
|
||||
$table->boolean('reconciled')->default(0);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'type']);
|
||||
});
|
||||
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->renameColumn('payment_id', 'expense_transaction_id');
|
||||
});
|
||||
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->renameColumn('revenue_id', 'income_transaction_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('transactions');
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ModifyDomainColumnCompaniesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->string('domain')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->string('domain')->change();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ModifyStatusColumnModulesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->renameColumn('status', 'enabled');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->renameColumn('enabled', 'status');
|
||||
});
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ModifySkuQuantityColumnItemsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->string('sku')->nullable()->change();
|
||||
$table->integer('quantity')->default(1)->change();
|
||||
|
||||
$connection = Schema::getConnection();
|
||||
$d_table = $connection->getDoctrineSchemaManager()->listTableDetails($connection->getTablePrefix() . 'items');
|
||||
|
||||
if ($d_table->hasIndex('items_company_id_sku_deleted_at_unique')) {
|
||||
// 1.3 update
|
||||
$table->dropUnique('items_company_id_sku_deleted_at_unique');
|
||||
} else {
|
||||
// 2.0 install
|
||||
$table->dropUnique(['company_id', 'sku', 'deleted_at']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->string('sku')->change();
|
||||
$table->integer('quantity')->change();
|
||||
$table->unique(['company_id', 'sku', 'deleted_at']);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddLocaleColumn extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('locale')->default(config('app.locale'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('locale');
|
||||
});
|
||||
}
|
||||
}
|
262
database/migrations/2020_01_08_000000_core_v200.php
Normal file
262
database/migrations/2020_01_08_000000_core_v200.php
Normal file
@ -0,0 +1,262 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV200 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Footer column
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->text('footer')->nullable();
|
||||
});
|
||||
|
||||
// Contacts
|
||||
Schema::create('contacts', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('type');
|
||||
$table->string('name');
|
||||
$table->string('email')->nullable();
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('tax_number')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->string('website')->nullable();
|
||||
$table->string('currency_code', 3);
|
||||
$table->boolean('enabled');
|
||||
$table->string('reference')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'type']);
|
||||
$table->unique(['company_id', 'type', 'email', 'deleted_at']);
|
||||
});
|
||||
|
||||
$rename_bills = [
|
||||
'vendor_id' => 'contact_id',
|
||||
'vendor_name' => 'contact_name',
|
||||
'vendor_email' => 'contact_email',
|
||||
'vendor_tax_number' => 'contact_tax_number',
|
||||
'vendor_phone' => 'contact_phone',
|
||||
'vendor_address' => 'contact_address',
|
||||
];
|
||||
|
||||
foreach ($rename_bills as $from => $to) {
|
||||
Schema::table('bills', function (Blueprint $table) use ($from, $to) {
|
||||
$table->renameColumn($from, $to);
|
||||
});
|
||||
}
|
||||
|
||||
$rename_invoices = [
|
||||
'customer_id' => 'contact_id',
|
||||
'customer_name' => 'contact_name',
|
||||
'customer_email' => 'contact_email',
|
||||
'customer_tax_number' => 'contact_tax_number',
|
||||
'customer_phone' => 'contact_phone',
|
||||
'customer_address' => 'contact_address',
|
||||
];
|
||||
|
||||
foreach ($rename_invoices as $from => $to) {
|
||||
Schema::table('invoices', function (Blueprint $table) use ($from, $to) {
|
||||
$table->renameColumn($from, $to);
|
||||
});
|
||||
}
|
||||
|
||||
// Dashboards
|
||||
Schema::create('dashboards', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id']);
|
||||
});
|
||||
|
||||
Schema::create('user_dashboards', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('dashboard_id')->unsigned();
|
||||
$table->string('user_type', 20);
|
||||
|
||||
$table->primary(['user_id', 'dashboard_id', 'user_type']);
|
||||
});
|
||||
|
||||
Schema::create('widgets', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('dashboard_id');
|
||||
$table->string('class');
|
||||
$table->string('name');
|
||||
$table->text('settings')->nullable();
|
||||
$table->integer('sort')->default(0);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'dashboard_id']);
|
||||
});
|
||||
|
||||
// Email templates
|
||||
Schema::create('email_templates', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('alias');
|
||||
$table->string('subject');
|
||||
$table->text('body');
|
||||
$table->text('params')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'alias', 'deleted_at']);
|
||||
});
|
||||
|
||||
// Firewall
|
||||
Schema::create('firewall_ips', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('ip');
|
||||
$table->integer('log_id')->nullable();
|
||||
$table->boolean('blocked')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('ip');
|
||||
$table->unique(['ip', 'deleted_at']);
|
||||
});
|
||||
|
||||
Schema::create('firewall_logs', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('ip');
|
||||
$table->string('level')->default('medium');
|
||||
$table->string('middleware');
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('url')->nullable();
|
||||
$table->string('referrer')->nullable();
|
||||
$table->text('request')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('ip');
|
||||
});
|
||||
|
||||
// Reports
|
||||
Schema::create('reports', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('class');
|
||||
$table->string('name');
|
||||
$table->text('description');
|
||||
$table->string('group');
|
||||
$table->string('period');
|
||||
$table->string('basis');
|
||||
$table->string('chart');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
// Transactions
|
||||
Schema::create('transactions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('type');
|
||||
$table->integer('account_id');
|
||||
$table->dateTime('paid_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code', 3);
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->integer('document_id')->nullable();
|
||||
$table->integer('contact_id')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->integer('category_id')->default(1);
|
||||
$table->string('payment_method');
|
||||
$table->string('reference')->nullable();
|
||||
$table->integer('parent_id')->default(0);
|
||||
$table->boolean('reconciled')->default(0);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'type']);
|
||||
});
|
||||
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->renameColumn('payment_id', 'expense_transaction_id');
|
||||
});
|
||||
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->renameColumn('revenue_id', 'income_transaction_id');
|
||||
});
|
||||
|
||||
// Domain column
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->string('domain')->nullable()->change();
|
||||
});
|
||||
|
||||
// Status column
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->renameColumn('status', 'enabled');
|
||||
});
|
||||
|
||||
// Sku and quantity columns
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->string('sku')->nullable()->change();
|
||||
$table->integer('quantity')->default(1)->change();
|
||||
|
||||
$connection = Schema::getConnection();
|
||||
$d_table = $connection->getDoctrineSchemaManager()->listTableDetails($connection->getTablePrefix() . 'items');
|
||||
|
||||
if ($d_table->hasIndex('items_company_id_sku_deleted_at_unique')) {
|
||||
// 1.3 update
|
||||
$table->dropUnique('items_company_id_sku_deleted_at_unique');
|
||||
} else {
|
||||
// 2.0 install
|
||||
$table->dropUnique(['company_id', 'sku', 'deleted_at']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->dropColumn('footer');
|
||||
});
|
||||
|
||||
Schema::drop('contacts');
|
||||
Schema::drop('dashboards');
|
||||
Schema::drop('user_dashboards');
|
||||
Schema::drop('widgets');
|
||||
Schema::drop('email_templates');
|
||||
Schema::drop('firewall_ips');
|
||||
Schema::drop('firewall_logs');
|
||||
Schema::drop('reports');
|
||||
Schema::drop('transactions');
|
||||
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->string('domain')->change();
|
||||
});
|
||||
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->renameColumn('enabled', 'status');
|
||||
});
|
||||
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->string('sku')->change();
|
||||
$table->integer('quantity')->change();
|
||||
$table->unique(['company_id', 'sku', 'deleted_at']);
|
||||
});
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ namespace Database\Seeds;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Date;
|
||||
|
||||
class Settings extends Seeder
|
||||
{
|
||||
@ -28,8 +27,26 @@ class Settings extends Seeder
|
||||
|
||||
setting()->setExtraColumns(['company_id' => $company_id]);
|
||||
|
||||
$offline_payments = [];
|
||||
|
||||
$offline_payments[] = [
|
||||
'code' => 'offline-payments.cash.1',
|
||||
'name' => trans('demo.offline_payments.cash'),
|
||||
'customer' => '0',
|
||||
'order' => '1',
|
||||
'description' => null,
|
||||
];
|
||||
|
||||
$offline_payments[] = [
|
||||
'code' => 'offline-payments.bank_transfer.2',
|
||||
'name' => trans('demo.offline_payments.bank'),
|
||||
'customer' => '0',
|
||||
'order' => '2',
|
||||
'description' => null,
|
||||
];
|
||||
|
||||
setting()->set([
|
||||
'localisation.financial_start' => Date::now()->startOfYear()->format('d-m'),
|
||||
'localisation.financial_start' => now()->startOfYear()->format('d-m'),
|
||||
'localisation.timezone' => 'Europe/London',
|
||||
'localisation.date_format' => 'd M Y',
|
||||
'localisation.date_separator' => 'space',
|
||||
@ -54,7 +71,7 @@ class Settings extends Seeder
|
||||
'schedule.bill_days' => '10,5,3,1',
|
||||
'schedule.time' => '09:00',
|
||||
'wizard.completed' => '0',
|
||||
'offline-payments.methods' => '[{"code":"offline-payments.cash.1","name":"Cash","order":"1","description":null},{"code":"offline-payments.bank_transfer.2","name":"Bank Transfer","order":"2","description":null}]',
|
||||
'offline-payments.methods' => json_encode($offline_payments),
|
||||
'contact.type.customer' => 'customer',
|
||||
'contact.type.vendor' => 'vendor',
|
||||
]);
|
||||
|
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class OfflineFile extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$module = Module::get('Offline');
|
||||
|
||||
if (!empty($module) && version_compare($module->get('version'), '1.0.0') == 0) {
|
||||
$offline_payments = json_decode(setting('offline.payment.methods'), true);
|
||||
|
||||
if (!empty($offline_payments)) {
|
||||
$offlinepayment = array();
|
||||
|
||||
foreach ($offline_payments as $offline_payment) {
|
||||
$code = explode('.', $offline_payment['code']);
|
||||
|
||||
$offline_payment['code'] = $code[1];
|
||||
|
||||
$offlinepayment[] = array(
|
||||
'code' => 'offlinepayment.' . $code[1] . '.' . $code[2],
|
||||
'name' => $offline_payment['name'],
|
||||
'customer' => 0,
|
||||
'order' => $offline_payment['order'],
|
||||
'description' => $offline_payment['description']
|
||||
);
|
||||
}
|
||||
|
||||
//$company_id = $this->command->argument('company');
|
||||
|
||||
// Set the active company settings
|
||||
setting()->setExtraColumns(['company_id' => 1]);
|
||||
|
||||
setting()->set('offline-payments.methods', json_encode($offlinepayment));
|
||||
|
||||
setting()->forget('offline.payment.methods');
|
||||
|
||||
setting()->save();
|
||||
}
|
||||
|
||||
$module->delete();
|
||||
|
||||
Artisan::call('cache:clear');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayments\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Setting;
|
||||
|
||||
class OfflinePaymentsDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Model::unguard();
|
||||
|
||||
$this->create();
|
||||
|
||||
Model::reguard();
|
||||
}
|
||||
|
||||
private function create()
|
||||
{
|
||||
$methods = array();
|
||||
|
||||
$methods[] = array(
|
||||
'code' => 'offline-payments.cash.1',
|
||||
'name' => 'Cash',
|
||||
'customer' => '0',
|
||||
'order' => '1',
|
||||
'description' => null,
|
||||
);
|
||||
|
||||
$methods[] = array(
|
||||
'code' => 'offline-payments.bank_transfer.2',
|
||||
'name' => 'Bank Transfer',
|
||||
'customer' => '0',
|
||||
'order' => '2',
|
||||
'description' => null,
|
||||
);
|
||||
|
||||
Setting::set('offline-payments.methods', json_encode($methods));
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ class Main extends Provider
|
||||
public function boot()
|
||||
{
|
||||
$this->loadTranslations();
|
||||
$this->loadMigrations();
|
||||
$this->loadViews();
|
||||
$this->loadEvents();
|
||||
}
|
||||
@ -51,16 +50,6 @@ class Main extends Provider
|
||||
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'offline-payments');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadMigrations()
|
||||
{
|
||||
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load events.
|
||||
*
|
||||
|
@ -18,6 +18,11 @@ return [
|
||||
'try' => 'Turkish Lira',
|
||||
],
|
||||
|
||||
'offline_payments' => [
|
||||
'cash' => 'Cash',
|
||||
'bank' => 'Bank Transfer',
|
||||
],
|
||||
|
||||
'reports' => [
|
||||
'income' => 'Monthly income summary by category.',
|
||||
'expense' => 'Monthly expense summary by category.',
|
||||
|
Loading…
x
Reference in New Issue
Block a user