db seeder
This commit is contained in:
@@ -11,28 +11,25 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('produits', function (Blueprint $table) {
|
||||
Schema::create('produits', function (Blueprint $table){
|
||||
$table->engine = 'InnoDB';
|
||||
|
||||
$table->bigIncrements('id')->unsigned();
|
||||
$table->string('nom')->nullable();
|
||||
$table->string('taille')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->string('couleur')->nullable();
|
||||
$table->float('prix')->nullable();
|
||||
$table->boolean('en_stock')->nullable();
|
||||
$table->string("taille")->nullable();
|
||||
$table->text("description")->nullable();
|
||||
$table->string("couleur")->nullable();
|
||||
$table->float("prix")->nullable();
|
||||
$table->boolean("en_stock")->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
|
||||
$table->index("nom");
|
||||
$table->index("taille");
|
||||
$table->index("couleur");
|
||||
$table->index("prix");
|
||||
$table->index("en_stock");
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,6 +37,6 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfexists('produits');
|
||||
Schema::dropIfExists('produits');
|
||||
}
|
||||
};
|
||||
|
@@ -11,7 +11,7 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('categories', function (Blueprint $table) {
|
||||
Schema::create('categories', function (Blueprint $table){
|
||||
$table->engine = 'InnoDB';
|
||||
|
||||
$table->bigIncrements('id')->unsigned();
|
||||
@@ -28,6 +28,6 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfexists('categories');
|
||||
Schema::dropIfExists('categories');
|
||||
}
|
||||
};
|
||||
|
@@ -12,17 +12,16 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('clients', function (Blueprint $table) {
|
||||
Schema::create('clients', function (Blueprint $table){
|
||||
$table->engine = 'InnoDB';
|
||||
|
||||
$table->bigIncrements('id')->unsigned();
|
||||
$table->string('nom')->nullable();
|
||||
$table->string('prenom')->nullable();
|
||||
$table->json('adresse')->default(new Expression('(JSON_OBJECT())'));
|
||||
$table->string("prenom")->nullable();
|
||||
$table->json("adresse")->default(new Expression('(JSON_OBJECT())'));
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
|
||||
$table->index("nom");
|
||||
$table->index("prenom");
|
||||
});
|
||||
@@ -33,6 +32,6 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfexists('clients');
|
||||
Schema::dropIfExists('clients');
|
||||
}
|
||||
};
|
||||
|
@@ -11,17 +11,20 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('produits_categories', function (Blueprint $table) {
|
||||
Schema::create('produits_categories', function (Blueprint $table){
|
||||
$table->engine = 'InnoDB';
|
||||
|
||||
$table->bigInteger('products_id')->unsigned();
|
||||
$table->bigInteger('produits_id')->unsigned();
|
||||
$table->bigInteger('categories_id')->unsigned();
|
||||
|
||||
$table->primary(['products_id', 'categories_id']);
|
||||
|
||||
$table->primary(['produits_id', 'categories_id']);
|
||||
|
||||
$table->index("produits_id");
|
||||
$table->index("categories_id");
|
||||
});
|
||||
|
||||
Schema::table('produits_categories', function (Blueprint $table) {
|
||||
$table->foreign('products_id')->references('id')->on('produits')->onUpdate('cascade')->onDelete('cascade');
|
||||
Schema::table('produits_categories', function (Blueprint $table){
|
||||
$table->foreign('produits_id')->references('id')->on('produits')->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreign('categories_id')->references('id')->on('categories')->onUpdate('cascade')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
@@ -31,6 +34,6 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfexists('produits_categories');
|
||||
Schema::dropIfExists('produits_categories');
|
||||
}
|
||||
};
|
||||
|
@@ -12,14 +12,22 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('commandes', function (Blueprint $table) {
|
||||
Schema::create('commandes', function (Blueprint $table){
|
||||
$table->engine = 'InnoDB';
|
||||
|
||||
$table->bigIncrements('id')->unsigned();
|
||||
$table->date('date')->nullable();
|
||||
$table->json('adresse')->default(new Expression('(JSON_OBJECT())'));
|
||||
$table->date('date');
|
||||
$table->bigInteger('clients_id')->unsigned();
|
||||
$table->json("adresse")->default(new Expression('(JSON_OBJECT())'));
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$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');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,6 +36,6 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfexists('commandes');
|
||||
Schema::dropIfExists('commandes');
|
||||
}
|
||||
};
|
||||
|
@@ -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');
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user