db seeder

This commit is contained in:
2023-03-03 15:43:38 +01:00
parent 3d13369e05
commit 798996b615
7 changed files with 124 additions and 39 deletions

View File

@@ -11,21 +11,26 @@ return new class extends Migration
*/
public function up(): void
{
Schema::create('lignes_commandes', function (Blueprint $table) {
Schema::create('lignes_commandes', function (Blueprint $table){
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->bigInteger('commandes_id')->unsigned();
$table->bigInteger('produits_id')->unsigned()->nullable();
$table->bigInteger('produits_id')->unsigned();
$table->integer('quantite')->nullable();
$table->float('prix_vente')->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) {
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('set null');
$table->foreign('produits_id')->references('id')->on('produits')->onUpdate('cascade')->onDelete('cascade');
});
}
@@ -34,6 +39,6 @@ return new class extends Migration
*/
public function down(): void
{
Schema::dropIfexists('lignes_commandes');
Schema::dropIfExists('lignes_commandes');
}
};