2023-03-03 13:45:51 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
use Illuminate\Database\Query\Expression;
|
|
|
|
|
|
|
|
return new class extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*/
|
|
|
|
public function up(): void
|
|
|
|
{
|
2023-03-03 15:43:38 +01:00
|
|
|
Schema::create('commandes', function (Blueprint $table){
|
2023-03-03 13:45:51 +01:00
|
|
|
$table->engine = 'InnoDB';
|
|
|
|
|
|
|
|
$table->bigIncrements('id')->unsigned();
|
2023-03-03 15:43:38 +01:00
|
|
|
$table->date('date');
|
|
|
|
$table->bigInteger('clients_id')->unsigned();
|
|
|
|
$table->json("adresse")->default(new Expression('(JSON_OBJECT())'));
|
2023-03-03 13:45:51 +01:00
|
|
|
|
|
|
|
$table->timestamps();
|
2023-03-03 15:43:38 +01:00
|
|
|
|
|
|
|
$table->index("date");
|
|
|
|
$table->index("clients_id");
|
|
|
|
});
|
|
|
|
|
|
|
|
Schema::table('commandes', function (Blueprint $table){
|
|
|
|
$table->foreign('clients_id')->references('id')->on('clients')->onUpdate('cascade')->onDelete('cascade');
|
2023-03-03 13:45:51 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*/
|
|
|
|
public function down(): void
|
|
|
|
{
|
2023-03-03 15:43:38 +01:00
|
|
|
Schema::dropIfExists('commandes');
|
2023-03-03 13:45:51 +01:00
|
|
|
}
|
|
|
|
};
|