45 lines
1.3 KiB
PHP
45 lines
1.3 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('lignes_commandes', function (Blueprint $table){
|
|
$table->engine = 'InnoDB';
|
|
|
|
$table->bigIncrements('id')->unsigned();
|
|
$table->bigInteger('commandes_id')->unsigned();
|
|
$table->bigInteger('produits_id')->unsigned();
|
|
$table->integer('quantite')->nullable();
|
|
$table->float("prix_vente")->nullable();
|
|
|
|
$table->timestamps();
|
|
|
|
$table->index("commandes_id");
|
|
$table->index("produits_id");
|
|
$table->index("quantite");
|
|
$table->index("prix_vente");
|
|
});
|
|
|
|
Schema::table('lignes_commandes', function (Blueprint $table){
|
|
$table->foreign('commandes_id')->references('id')->on('commandes')->onUpdate('cascade')->onDelete('cascade');
|
|
$table->foreign('produits_id')->references('id')->on('produits')->onUpdate('cascade')->onDelete('cascade');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('lignes_commandes');
|
|
}
|
|
};
|