akaunting 3.0 (the last dance)
This commit is contained in:
@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV1 extends Migration
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
@ -465,6 +465,8 @@ class CoreV1 extends Migration
|
||||
$table->string('key');
|
||||
$table->text('value')->nullable();
|
||||
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'key']);
|
||||
});
|
||||
@ -514,9 +516,8 @@ class CoreV1 extends Migration
|
||||
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']);
|
||||
$table->primary(['user_id', 'company_id']);
|
||||
});
|
||||
}
|
||||
|
||||
@ -527,44 +528,6 @@ class CoreV1 extends Migration
|
||||
*/
|
||||
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_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_totals');
|
||||
Schema::drop('items');
|
||||
Schema::drop('jobs');
|
||||
Schema::drop('failed_jobs');
|
||||
Schema::drop('mediables');
|
||||
Schema::drop('media');
|
||||
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');
|
||||
//
|
||||
}
|
||||
}
|
||||
};
|
||||
|
460
database/migrations/2019_11_16_000000_core_v2.php
Normal file
460
database/migrations/2019_11_16_000000_core_v2.php
Normal file
@ -0,0 +1,460 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Accounts
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
// Categories
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
// Companies
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->string('domain')->nullable()->change();
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
// 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('city')->nullable();
|
||||
$table->string('zip_code')->nullable();
|
||||
$table->string('state')->nullable();
|
||||
$table->string('country')->nullable();
|
||||
$table->string('website')->nullable();
|
||||
$table->string('currency_code');
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->string('reference')->nullable();
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'type']);
|
||||
$table->unique(['company_id', 'type', 'email', 'deleted_at']);
|
||||
});
|
||||
|
||||
// Currencies
|
||||
Schema::table('currencies', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
// Dashboards & Widgets
|
||||
Schema::create('dashboards', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$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->primary(['user_id', 'dashboard_id']);
|
||||
});
|
||||
|
||||
Schema::create('widgets', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('dashboard_id');
|
||||
$table->string('class');
|
||||
$table->string('name');
|
||||
$table->integer('sort')->default(0);
|
||||
$table->text('settings')->nullable();
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'dashboard_id']);
|
||||
$table->index('class');
|
||||
});
|
||||
|
||||
// Documents
|
||||
Schema::create('documents', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->string('document_number');
|
||||
$table->string('order_number')->nullable();
|
||||
$table->string('status');
|
||||
$table->dateTime('issued_at');
|
||||
$table->dateTime('due_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code');
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->unsignedInteger('category_id')->default(1);
|
||||
$table->unsignedInteger('contact_id');
|
||||
$table->string('contact_name');
|
||||
$table->string('contact_email')->nullable();
|
||||
$table->string('contact_tax_number')->nullable();
|
||||
$table->string('contact_phone')->nullable();
|
||||
$table->text('contact_address')->nullable();
|
||||
$table->string('contact_city')->nullable();
|
||||
$table->string('contact_zip_code')->nullable();
|
||||
$table->string('contact_state')->nullable();
|
||||
$table->string('contact_country')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->text('footer')->nullable();
|
||||
$table->unsignedInteger('parent_id')->default(0);
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->unique(['document_number', 'deleted_at', 'company_id', 'type']);
|
||||
});
|
||||
|
||||
Schema::create('document_histories', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->string('status');
|
||||
$table->boolean('notify');
|
||||
$table->text('description')->nullable();
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
Schema::create('document_items', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->unsignedInteger('item_id')->nullable();
|
||||
$table->string('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->string('sku')->nullable();
|
||||
$table->double('quantity', 7, 2);
|
||||
$table->double('price', 15, 4);
|
||||
$table->float('tax', 15, 4)->default('0.0000');
|
||||
$table->string('discount_type')->default('normal');
|
||||
$table->double('discount_rate', 15, 4)->default('0.0000');
|
||||
$table->double('total', 15, 4);
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
Schema::create('document_item_taxes', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->unsignedInteger('document_item_id');
|
||||
$table->unsignedInteger('tax_id');
|
||||
$table->string('name');
|
||||
$table->double('amount', 15, 4)->default('0.0000');
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
Schema::create('document_totals', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->string('code')->nullable();
|
||||
$table->string('name');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->integer('sort_order');
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
// Email templates
|
||||
Schema::create('email_templates', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('alias');
|
||||
$table->string('class');
|
||||
$table->string('name');
|
||||
$table->string('subject');
|
||||
$table->text('body');
|
||||
$table->text('params')->nullable();
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'alias', 'deleted_at']);
|
||||
});
|
||||
|
||||
// Jobs
|
||||
Schema::table('failed_jobs', function (Blueprint $table) {
|
||||
$table->string('uuid')->after('id')->nullable()->unique();
|
||||
});
|
||||
|
||||
// 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');
|
||||
});
|
||||
|
||||
// Items
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->string('sku')->nullable()->change();
|
||||
$table->integer('quantity')->default(1)->change();
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
|
||||
$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']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create('item_taxes', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('item_id');
|
||||
$table->integer('tax_id')->nullable();
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'item_id']);
|
||||
});
|
||||
|
||||
// Media
|
||||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->unsignedInteger('company_id')->default(0)->after('id');
|
||||
$table->unsignedInteger('created_by')->nullable()->after('size');
|
||||
$table->string('created_from', 100)->nullable()->after('size');
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::table('mediables', function (Blueprint $table) {
|
||||
$table->unsignedInteger('company_id')->default(0)->after('media_id');
|
||||
$table->unsignedInteger('created_by')->nullable()->after('order');
|
||||
$table->string('created_from', 100)->nullable()->after('order');
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
// Modules
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->renameColumn('status', 'enabled');
|
||||
});
|
||||
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('module_histories', function (Blueprint $table) {
|
||||
$table->dropColumn('category');
|
||||
});
|
||||
|
||||
Schema::table('module_histories', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('description');
|
||||
$table->string('created_from', 100)->nullable()->after('description');
|
||||
});
|
||||
|
||||
// Reconciliations
|
||||
Schema::table('reconciliations', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('reconciled');
|
||||
$table->string('created_from', 100)->nullable()->after('reconciled');
|
||||
});
|
||||
|
||||
// Recurring
|
||||
Schema::table('recurring', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('count');
|
||||
$table->string('created_from', 100)->nullable()->after('count');
|
||||
});
|
||||
|
||||
// Reports
|
||||
Schema::create('reports', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('class');
|
||||
$table->string('name');
|
||||
$table->text('description');
|
||||
$table->text('settings')->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('class');
|
||||
});
|
||||
|
||||
// Roles
|
||||
Schema::table('roles', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('description');
|
||||
$table->string('created_from', 100)->nullable()->after('description');
|
||||
});
|
||||
|
||||
// Taxes
|
||||
Schema::table('taxes', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
// Transactions
|
||||
Schema::create('transactions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('type');
|
||||
$table->dateTime('paid_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code');
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->integer('account_id');
|
||||
$table->integer('document_id')->nullable();
|
||||
$table->integer('contact_id')->nullable();
|
||||
$table->integer('category_id')->default(1);
|
||||
$table->text('description')->nullable();
|
||||
$table->string('payment_method');
|
||||
$table->string('reference')->nullable();
|
||||
$table->integer('parent_id')->default(0);
|
||||
$table->boolean('reconciled')->default(0);
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'type']);
|
||||
$table->index('account_id');
|
||||
$table->index('category_id');
|
||||
$table->index('contact_id');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
// Transfers
|
||||
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');
|
||||
});
|
||||
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('income_transaction_id');
|
||||
$table->string('created_from', 100)->nullable()->after('income_transaction_id');
|
||||
});
|
||||
|
||||
// Users
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('landing_page', 70)->nullable()->default('dashboard')->after('locale');
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('invoices');
|
||||
Schema::dropIfExists('invoice_histories');
|
||||
Schema::dropIfExists('invoice_items');
|
||||
Schema::dropIfExists('invoice_item_taxes');
|
||||
Schema::dropIfExists('invoice_statuses');
|
||||
Schema::dropIfExists('invoice_totals');
|
||||
Schema::dropIfExists('bills');
|
||||
Schema::dropIfExists('bill_histories');
|
||||
Schema::dropIfExists('bill_items');
|
||||
Schema::dropIfExists('bill_item_taxes');
|
||||
Schema::dropIfExists('bill_statuses');
|
||||
Schema::dropIfExists('bill_totals');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
@ -1,280 +0,0 @@
|
||||
<?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()->after('notes');
|
||||
});
|
||||
|
||||
// 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 = [
|
||||
'bill_status_code' => 'status',
|
||||
'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);
|
||||
});
|
||||
}
|
||||
|
||||
Schema::table('bill_histories', function (Blueprint $table) {
|
||||
$table->renameColumn('status_code', 'status');
|
||||
});
|
||||
|
||||
Schema::drop('bill_statuses');
|
||||
|
||||
$rename_invoices = [
|
||||
'invoice_status_code' => 'status',
|
||||
'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);
|
||||
});
|
||||
}
|
||||
|
||||
Schema::table('invoice_histories', function (Blueprint $table) {
|
||||
$table->renameColumn('status_code', 'status');
|
||||
});
|
||||
|
||||
Schema::drop('invoice_statuses');
|
||||
|
||||
// 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->integer('sort')->default(0);
|
||||
$table->text('settings')->nullable();
|
||||
$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('class');
|
||||
$table->string('name');
|
||||
$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->text('settings')->nullable();
|
||||
$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->dateTime('paid_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code', 3);
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->integer('account_id');
|
||||
$table->integer('document_id')->nullable();
|
||||
$table->integer('contact_id')->nullable();
|
||||
$table->integer('category_id')->default(1);
|
||||
$table->text('description')->nullable();
|
||||
$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']);
|
||||
}
|
||||
});
|
||||
|
||||
// Landing page column
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('landing_page', 70)->nullable()->default('dashboard')->after('locale');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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']);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV208 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('invoice_items', function (Blueprint $table) {
|
||||
$table->double('discount_rate', 15, 4)->default('0.0000')->after('tax');
|
||||
$table->string('discount_type')->default('normal')->after('discount_rate');
|
||||
});
|
||||
|
||||
Schema::table('bill_items', function (Blueprint $table) {
|
||||
$table->double('discount_rate', 15, 4)->default('0.0000')->after('tax');
|
||||
$table->string('discount_type')->default('normal')->after('discount_rate');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('invoice_items', function (Blueprint $table) {
|
||||
$table->dropColumn(['discount_rate', 'discount_type']);
|
||||
});
|
||||
|
||||
Schema::table('bill_items', function (Blueprint $table) {
|
||||
$table->dropColumn(['discount_rate', 'discount_type']);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2014 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$doc_types = ['invoice', 'bill'];
|
||||
$doc_tables = ['histories', 'items', 'item_taxes', 'totals'];
|
||||
|
||||
foreach ($doc_types as $doc_type) {
|
||||
foreach ($doc_tables as $doc_table) {
|
||||
Schema::table($doc_type . '_' . $doc_table, function (Blueprint $table) use ($doc_type) {
|
||||
$table->index($doc_type . '_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$table->index('account_id');
|
||||
$table->index('category_id');
|
||||
$table->index('contact_id');
|
||||
$table->index('document_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2017 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('module_histories', function (Blueprint $table) {
|
||||
$table->dropColumn('category');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,154 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV210 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('failed_jobs', function (Blueprint $table) {
|
||||
$table->string('uuid')->after('id')->nullable()->unique();
|
||||
});
|
||||
|
||||
Schema::create('documents', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->string('document_number');
|
||||
$table->string('order_number')->nullable();
|
||||
$table->string('status');
|
||||
$table->dateTime('issued_at');
|
||||
$table->dateTime('due_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code');
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->unsignedInteger('category_id')->default(1);
|
||||
$table->unsignedInteger('contact_id');
|
||||
$table->string('contact_name');
|
||||
$table->string('contact_email')->nullable();
|
||||
$table->string('contact_tax_number')->nullable();
|
||||
$table->string('contact_phone')->nullable();
|
||||
$table->text('contact_address')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->text('footer')->nullable();
|
||||
$table->unsignedInteger('parent_id')->default(0);
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->unique(['document_number', 'deleted_at', 'company_id', 'type']);
|
||||
});
|
||||
|
||||
Schema::create('document_histories', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->string('status');
|
||||
$table->boolean('notify');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
Schema::create('document_items', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->unsignedInteger('item_id')->nullable();
|
||||
$table->string('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->string('sku')->nullable();
|
||||
$table->double('quantity', 7, 2);
|
||||
$table->double('price', 15, 4);
|
||||
$table->float('tax', 15, 4)->default('0.0000');
|
||||
$table->string('discount_type')->default('normal');
|
||||
$table->double('discount_rate', 15, 4)->default('0.0000');
|
||||
$table->double('total', 15, 4);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
Schema::create('document_item_taxes', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->unsignedInteger('document_item_id');
|
||||
$table->unsignedInteger('tax_id');
|
||||
$table->string('name');
|
||||
$table->double('amount', 15, 4)->default('0.0000');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
Schema::create('document_totals', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_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');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
Schema::create('item_taxes', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('item_id');
|
||||
$table->integer('tax_id')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'item_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('failed_jobs', function (Blueprint $table) {
|
||||
$table->dropColumn('uuid');
|
||||
});
|
||||
|
||||
Schema::drop('documents');
|
||||
Schema::drop('document_histories');
|
||||
Schema::drop('document_items');
|
||||
Schema::drop('document_item_taxes');
|
||||
Schema::drop('document_totals');
|
||||
Schema::drop('item_taxes');
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV219 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('reports', function (Blueprint $table) {
|
||||
$table->index('class');
|
||||
});
|
||||
|
||||
Schema::table('widgets', function (Blueprint $table) {
|
||||
$table->index('class');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2114 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->unsignedInteger('company_id')->default(0)->after('id');
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::table('mediables', function (Blueprint $table) {
|
||||
$table->unsignedInteger('company_id')->default(0)->after('media_id');
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->dropColumn('company_id');
|
||||
});
|
||||
|
||||
Schema::table('mediables', function (Blueprint $table) {
|
||||
$table->dropColumn('company_id');
|
||||
});
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2117 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('contacts', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('reference');
|
||||
});
|
||||
|
||||
Schema::table('currencies', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('dashboards', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('documents', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('parent_id');
|
||||
});
|
||||
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('reconciliations', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('reconciled');
|
||||
});
|
||||
|
||||
Schema::table('reports', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('settings');
|
||||
});
|
||||
|
||||
Schema::table('taxes', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('parent_id');
|
||||
});
|
||||
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('income_transaction_id');
|
||||
});
|
||||
|
||||
Schema::table('widgets', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('settings');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,154 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2124 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('contacts', function (Blueprint $table) {
|
||||
$table->string('country')->nullable()->after('address');
|
||||
$table->string('state')->nullable()->after('address');
|
||||
$table->string('zip_code')->nullable()->after('address');
|
||||
$table->string('city')->nullable()->after('address');
|
||||
});
|
||||
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('contacts', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('reference');
|
||||
});
|
||||
|
||||
Schema::table('currencies', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('dashboards', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('documents', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('parent_id');
|
||||
});
|
||||
|
||||
Schema::table('document_histories', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('description');
|
||||
$table->string('created_from', 30)->nullable()->after('description');
|
||||
});
|
||||
|
||||
Schema::table('document_items', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('total');
|
||||
$table->string('created_from', 30)->nullable()->after('total');
|
||||
});
|
||||
|
||||
Schema::table('document_item_taxes', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('amount');
|
||||
$table->string('created_from', 30)->nullable()->after('amount');
|
||||
});
|
||||
|
||||
Schema::table('document_totals', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('sort_order');
|
||||
$table->string('created_from', 30)->nullable()->after('sort_order');
|
||||
});
|
||||
|
||||
Schema::table('email_templates', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('params');
|
||||
$table->string('created_from', 30)->nullable()->after('params');
|
||||
});
|
||||
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('item_taxes', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('tax_id');
|
||||
$table->string('created_from', 30)->nullable()->after('tax_id');
|
||||
});
|
||||
|
||||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('original_media_id');
|
||||
$table->string('created_from', 30)->nullable()->after('original_media_id');
|
||||
});
|
||||
|
||||
Schema::table('mediables', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('order');
|
||||
$table->string('created_from', 30)->nullable()->after('order');
|
||||
});
|
||||
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('enabled');
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('module_histories', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('description');
|
||||
$table->string('created_from', 30)->nullable()->after('description');
|
||||
});
|
||||
|
||||
Schema::table('reconciliations', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('reconciled');
|
||||
});
|
||||
|
||||
Schema::table('recurring', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('count');
|
||||
$table->string('created_from', 30)->nullable()->after('count');
|
||||
});
|
||||
|
||||
Schema::table('reports', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('settings');
|
||||
});
|
||||
|
||||
Schema::table('roles', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('description');
|
||||
$table->string('created_from', 30)->nullable()->after('description');
|
||||
});
|
||||
|
||||
Schema::table('taxes', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('parent_id');
|
||||
});
|
||||
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('income_transaction_id');
|
||||
});
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('enabled');
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('widgets', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('settings');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2125 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('contacts', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('currencies', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('dashboards', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('documents', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('document_histories', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('document_items', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('document_item_taxes', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('document_totals', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('email_templates', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('item_taxes', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('mediables', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('module_histories', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('reconciliations', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('recurring', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('reports', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('roles', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('taxes', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('widgets', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2126 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('contacts', function (Blueprint $table) {
|
||||
$table->boolean('enabled')->default(1)->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2127 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('documents', function (Blueprint $table) {
|
||||
$table->string('contact_country')->nullable()->after('contact_address');
|
||||
$table->string('contact_state')->nullable()->after('contact_address');
|
||||
$table->string('contact_zip_code')->nullable()->after('contact_address');
|
||||
$table->string('contact_city')->nullable()->after('contact_address');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::table('user_companies', function (Blueprint $table) {
|
||||
$table->dropPrimary(['user_id', 'company_id', 'user_type']);
|
||||
$table->primary(['user_id', 'company_id']);
|
||||
});
|
||||
|
||||
Schema::table('user_companies', function (Blueprint $table) {
|
||||
$table->dropColumn('user_type');
|
||||
});
|
||||
|
||||
Schema::table('user_dashboards', function (Blueprint $table) {
|
||||
$table->dropPrimary(['user_id', 'dashboard_id', 'user_type']);
|
||||
$table->primary(['user_id', 'dashboard_id']);
|
||||
});
|
||||
|
||||
Schema::table('user_dashboards', function (Blueprint $table) {
|
||||
$table->dropColumn('user_type');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('contacts', function (Blueprint $table) {
|
||||
$table->string('currency_code')->change();
|
||||
});
|
||||
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$table->string('currency_code')->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
105
database/migrations/2022_05_10_000000_core_v300.php
Normal file
105
database/migrations/2022_05_10_000000_core_v300.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
use App\Traits\Database;
|
||||
use Doctrine\DBAL\Types\FloatType;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
use Database;
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (! Type::hasType('double')) {
|
||||
Type::addType('double', FloatType::class);
|
||||
}
|
||||
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$table->unsignedInteger('split_id')->nullable()->after('parent_id');
|
||||
|
||||
$table->foreign('split_id')->references('id')->on('transactions');
|
||||
});
|
||||
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->unsignedInteger('parent_id')->nullable()->after('enabled');
|
||||
|
||||
$table->foreign('parent_id')->references('id')->on('categories');
|
||||
});
|
||||
|
||||
Schema::table('items', function(Blueprint $table) {
|
||||
$table->dropColumn('tax_id');
|
||||
});
|
||||
|
||||
Schema::table('items', function(Blueprint $table) {
|
||||
$table->dropColumn('quantity');
|
||||
});
|
||||
|
||||
Schema::table('items', function(Blueprint $table) {
|
||||
$table->string('type')->default('product')->after('company_id');
|
||||
$table->double('sale_price', 15, 4)->nullable()->change();
|
||||
$table->double('purchase_price', 15, 4)->nullable()->change();
|
||||
});
|
||||
|
||||
Schema::table('recurring', function(Blueprint $table) {
|
||||
$table->renameColumn('count', 'limit_count')->nullable();
|
||||
});
|
||||
|
||||
Schema::table('recurring', function (Blueprint $table) {
|
||||
$table->string('status')->default('active')->after('started_at');
|
||||
$table->string('limit_by')->default('count')->after('status');
|
||||
$table->dateTime('limit_date')->nullable()->after('limit_count');
|
||||
$table->boolean('auto_send')->default(1)->after('limit_date');
|
||||
});
|
||||
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$number = $table->string('number')->after('type');
|
||||
|
||||
if ($this->databaseDriverIs('sqlite')) {
|
||||
$number->nullable();
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('accounts', function(Blueprint $table) {
|
||||
$table->string('type')->default('bank')->after('company_id');
|
||||
});
|
||||
|
||||
if (! Schema::hasTable('personal_access_tokens')) {
|
||||
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->string('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
Schema::create('user_invitations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('company_id')->unsigned();
|
||||
$table->string('token');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user