Files
dots-bot-api/database/migrations/2023_06_15_134235_create_carts_table.php
T
KKlochko ea120c8c9c Update User, Cart models.
Added isEmpty (no items), setCity, dropItems to Cart.
The cart field, company, was made nullable.

Updated the user field from name to username and made it unique.
2023-06-16 16:50:12 +03:00

39 lines
1.1 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('carts', function (Blueprint $table) {
$table->id();
$table->unsignedBiginteger('city_id')->unsigned();
$table->unsignedBiginteger('company_id')->unsigned()->nullable();
$table->unsignedBiginteger('user_id')->unsigned();
$table->string('status'); // CART | DONE
$table->foreign('city_id')->references('id')
->on('cities')->onDelete('cascade');
$table->foreign('company_id')->references('id')
->on('companies')->onDelete('cascade');
$table->foreign('user_id')->references('id')
->on('users')->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('carts');
}
};