Más chanchullos con migraciones
This commit is contained in:
		
							parent
							
								
									2add96ecb0
								
							
						
					
					
						commit
						9155f974b6
					
				
					 4 changed files with 21 additions and 62 deletions
				
			
		| 
						 | 
					@ -23,6 +23,17 @@ return new class extends Migration
 | 
				
			||||||
            $table->foreign('categoria_id')->references('id')->on('categorias');
 | 
					            $table->foreign('categoria_id')->references('id')->on('categorias');
 | 
				
			||||||
            $table->foreign('barrio_id')->references('id')->on('barrios');
 | 
					            $table->foreign('barrio_id')->references('id')->on('barrios');
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::create('producto_pedido', function (Blueprint $table) {
 | 
				
			||||||
 | 
					            $table->unsignedBigInteger('pedido_id');
 | 
				
			||||||
 | 
					            $table->unsignedBigInteger('producto_id');
 | 
				
			||||||
 | 
					            $table->unsignedInteger('cantidad');
 | 
				
			||||||
 | 
					            $table->unsignedDecimal('total', 15, 8);
 | 
				
			||||||
 | 
					            $table->timestamps();
 | 
				
			||||||
 | 
					            $table->primary(['pedido_id','producto_id']);
 | 
				
			||||||
 | 
					            $table->foreign('pedido_id')->references('id')->on('pedidos');
 | 
				
			||||||
 | 
					            $table->foreign('producto_id')->references('id')->on('productos');
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					@ -30,6 +41,7 @@ return new class extends Migration
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function down(): void
 | 
					    public function down(): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        Schema::dropIfExists('producto_pedido');
 | 
				
			||||||
        Schema::dropIfExists('productos');
 | 
					        Schema::dropIfExists('productos');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,32 +0,0 @@
 | 
				
			||||||
<?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('productos_pedidos', function (Blueprint $table) {
 | 
					 | 
				
			||||||
            $table->unsignedBigInteger('pedido_id');
 | 
					 | 
				
			||||||
            $table->unsignedBigInteger('producto_id');
 | 
					 | 
				
			||||||
            $table->unsignedInteger('ammount');
 | 
					 | 
				
			||||||
            $table->timestamps();
 | 
					 | 
				
			||||||
            $table->primary(['pedido_id','producto_id']);
 | 
					 | 
				
			||||||
            $table->foreign('pedido_id')->references('id')->on('pedidos');
 | 
					 | 
				
			||||||
            $table->foreign('producto_id')->references('id')->on('productos');
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Reverse the migrations.
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public function down(): void
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        Schema::dropIfExists('productos_pedidos');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
| 
						 | 
					@ -17,6 +17,14 @@ return new class extends Migration
 | 
				
			||||||
            $table->string('key', 100);
 | 
					            $table->string('key', 100);
 | 
				
			||||||
            $table->timestamps();
 | 
					            $table->timestamps();
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Schema::create('producto_caracteristica', function (Blueprint $table) {
 | 
				
			||||||
 | 
					            $table->unsignedBigInteger('producto_id');
 | 
				
			||||||
 | 
					            $table->unsignedBigInteger('caracteristica_id');
 | 
				
			||||||
 | 
					            $table->primary(['producto_id','caracteristica_id']);
 | 
				
			||||||
 | 
					            $table->foreign('producto_id')->references('id')->on('productos');
 | 
				
			||||||
 | 
					            $table->foreign('caracteristica_id')->references('id')->on('caracteristicas');
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					@ -24,6 +32,7 @@ return new class extends Migration
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function down(): void
 | 
					    public function down(): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        Schema::dropIfExists('producto_caracteristica');
 | 
				
			||||||
        Schema::dropIfExists('caracteristicas');
 | 
					        Schema::dropIfExists('caracteristicas');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,30 +0,0 @@
 | 
				
			||||||
<?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('productos_caracteristicas', function (Blueprint $table) {
 | 
					 | 
				
			||||||
            $table->unsignedBigInteger('producto_id');
 | 
					 | 
				
			||||||
            $table->unsignedBigInteger('caracteristica_id');
 | 
					 | 
				
			||||||
            $table->primary(['producto_id','caracteristica_id']);
 | 
					 | 
				
			||||||
            $table->foreign('producto_id')->references('id')->on('productos');
 | 
					 | 
				
			||||||
            $table->foreign('caracteristica_id')->references('id')->on('caracteristicas');
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Reverse the migrations.
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public function down(): void
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        Schema::dropIfExists('productos_caracteristicas');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue