Add comments to migrations,

Work on CartItem schema,
This commit is contained in:
Patrick Henninger
2022-02-06 23:35:12 +01:00
parent 177fba5424
commit 92ef805c67
2 changed files with 32 additions and 4 deletions

View File

@@ -13,12 +13,20 @@ class CreateShoppingcartTable extends Migration
public function up()
{
Schema::create(Config::get('cart.database.tables.cart'), function (Blueprint $table) {
$table->string('identifier');
$table->string('instance');
$table->longText('content');
$table->nullableTimestamps();
/* Primary identifier of the cart, i.e. uinque user id */
$table->string('identifier')->index();
/* Instance of the cart to allow for multiple carts per identifier */
$table->string('instance')->index();
/* Make primary key a combination of booth */
$table->primary(['identifier', 'instance']);
/* Content of the cart */
$table->longText('content');
/* Allow empty timestamps */
$table->nullableTimestamps();
});
}

View File

@@ -2,6 +2,7 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Schema;
class CreateShoppingcartItemsTable extends Migration
@@ -12,6 +13,25 @@ class CreateShoppingcartItemsTable extends Migration
public function up()
{
Schema::create(Config::get('cart.database.tables.cart_item'), function (Blueprint $table) {
/* RowID of the CartItem, based on id and options */
$table->string('row_id', 32)->index();
/* Relation CartItem to Cart */
$table->unsignedBigInteger('cart_id');
$table->foreign('cart_id')->references('id')->on(Config::get('cart.database.tables.cart'));
/* Make id and rowid primary so there can not be duplicates */
$table->primary(['cart_id', 'row_id']);
/* The price of the CartItem */
$table->unsignedBigInteger('price')->nullable();
$table->unsignedFloat('discount_rate')->nullable();
$table->unsignedBigInteger('discount_fixed')->nullable();
$table->unsignedFloat('taxRate')->nullable();
/* Custom-Options of the CartItem */
$table->json('options');
$table->timestamps();
});
}