Last active
August 29, 2015 14:16
-
-
Save stevebauman/9dac869eb860b5918804 to your computer and use it in GitHub Desktop.
Transaction Tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Schema::create('inventory_transactions', function (Blueprint $table) | |
{ | |
$table->increments('id'); | |
$table->timestamps(); | |
$table->integer('stock_id')->unsigned(); | |
$table->string('state'); | |
$table->decimal('quantity', 8, 2)->default(0); | |
$table->foreign('stock_id')->references('id')->on('inventory_stocks') | |
->onUpdate('restrict') | |
->onDelete('cascade'); | |
}); | |
Schema::create('inventory_transaction_histories', function (Blueprint $table) | |
{ | |
$table->increments('id'); | |
$table->timestamps(); | |
$table->integer('transaction_id')->unsigned(); | |
/* | |
* Allows tracking states for each transaction | |
*/ | |
$table->string('state_before'); | |
$table->string('state_after'); | |
/* | |
* Allows tracking the quantities of each transaction | |
*/ | |
$table->string('quantity_before'); | |
$table->string('quantity_after'); | |
$table->foreign('transaction_id')->references('id')->on('inventory_transactions') | |
->onUpdate('restrict') | |
->onDelete('cascade'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment