![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/ledger.corals.io/Corals/modules/Ledger/database/migrations/ |
<?php namespace Corals\Modules\Ledger\database\migrations; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class LedgerTables extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('ledger_accounts', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->nullable(); $table->string('phone')->nullable(); $table->string('address')->nullable(); $table->string('notes')->nullable(); $this->commonColumns($table); }); Schema::create('ledger_items', function (Blueprint $table) { $table->increments('id'); $table->string('code')->index(); $table->string('name'); $table->unsignedInteger('category_id')->nullable(); $table->foreign('category_id')->references('id')->on('utility_categories'); $table->decimal('price'); $table->decimal('wholesale_price')->nullable(); $table->decimal('quantity')->default(0); $table->text('description')->nullable(); $this->commonColumns($table); }); Schema::create('ledger_records', function (Blueprint $table) { $table->increments('id'); $table->string('code')->index(); $table->unsignedInteger('account_id'); $table->foreign('account_id')->references('id')->on('ledger_accounts') ->cascadeOnDelete()->cascadeOnUpdate(); $table->date('record_date')->index(); $table->string('status')->index(); $table->string('type')->index(); $table->string('payment_method')->index(); $table->decimal('amount')->nullable(); $table->string('currency')->index(); $table->text('notes')->nullable(); $this->commonColumns($table); }); Schema::create('ledger_record_items', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('item_id')->nullable(); $table->foreign('item_id')->references('id')->on('ledger_items') ->cascadeOnUpdate()->cascadeOnDelete(); $table->unsignedInteger('record_id')->nullable(); $table->foreign('record_id')->references('id')->on('ledger_records') ->cascadeOnUpdate()->cascadeOnDelete(); $table->decimal('price'); $table->decimal('quantity'); $table->decimal('amount'); $table->text('notes')->nullable(); $this->commonColumns($table); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('ledger_record_items'); Schema::dropIfExists('ledger_records'); Schema::dropIfExists('ledger_accounts'); Schema::dropIfExists('ledger_items'); } protected function commonColumns(Blueprint $table) { $table->text('properties')->nullable(); $table->auditable(); $table->softDeletes(); $table->timestamps(); } }