feature/columna-totales #4
					 7 changed files with 34 additions and 169 deletions
				
			
		|  | @ -1,28 +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('regiones', function (Blueprint $table) { |  | ||||||
|             $table->id(); |  | ||||||
|             $table->string('name', 100); |  | ||||||
|             $table->timestamps(); |  | ||||||
|         }); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * Reverse the migrations. |  | ||||||
|      */ |  | ||||||
|     public function down(): void |  | ||||||
|     { |  | ||||||
|         Schema::dropIfExists('regiones'); |  | ||||||
|     } |  | ||||||
| }; |  | ||||||
|  | @ -1,28 +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('categorias', function (Blueprint $table) { |  | ||||||
|             $table->id(); |  | ||||||
|             $table->string('name', 100); |  | ||||||
|             $table->timestamps(); |  | ||||||
|         }); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * Reverse the migrations. |  | ||||||
|      */ |  | ||||||
|     public function down(): void |  | ||||||
|     { |  | ||||||
|         Schema::dropIfExists('categorias'); |  | ||||||
|     } |  | ||||||
| }; |  | ||||||
|  | @ -1,38 +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('caracteristicas', function (Blueprint $table) { |  | ||||||
|             $table->id(); |  | ||||||
|             $table->string('name', 100); |  | ||||||
|             $table->string('key', 100); |  | ||||||
|             $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'); |  | ||||||
|         }); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * Reverse the migrations. |  | ||||||
|      */ |  | ||||||
|     public function down(): void |  | ||||||
|     { |  | ||||||
|         Schema::dropIfExists('producto_caracteristica'); |  | ||||||
|         Schema::dropIfExists('caracteristicas'); |  | ||||||
|     } |  | ||||||
| }; |  | ||||||
|  | @ -1,62 +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::table('barrios', function (Blueprint $table) { |  | ||||||
|             $table->renameColumn('name', 'nombre'); |  | ||||||
|         }); |  | ||||||
|         Schema::table('categorias', function (Blueprint $table) { |  | ||||||
|             $table->renameColumn('name', 'nombre'); |  | ||||||
|         }); |  | ||||||
|         Schema::table('pedidos', function (Blueprint $table) { |  | ||||||
|             $table->renameColumn('name', 'nombre'); |  | ||||||
|         }); |  | ||||||
|         Schema::table('regiones', function (Blueprint $table) { |  | ||||||
|             $table->renameColumn('name', 'nombre'); |  | ||||||
|         }); |  | ||||||
|         Schema::table('caracteristicas', function (Blueprint $table) { |  | ||||||
|             $table->renameColumn('name', 'nombre'); |  | ||||||
|             $table->renameColumn('key', 'codigo'); |  | ||||||
|         }); |  | ||||||
|         Schema::table('productos', function (Blueprint $table) { |  | ||||||
|             $table->renameColumn('name', 'nombre'); |  | ||||||
|             $table->renameColumn('price', 'precio'); |  | ||||||
|         }); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * Reverse the migrations. |  | ||||||
|      */ |  | ||||||
|     public function down(): void |  | ||||||
|     { |  | ||||||
|         Schema::table('barrios', function (Blueprint $table) { |  | ||||||
|             $table->renameColumn('nombre', 'name'); |  | ||||||
|         }); |  | ||||||
|         Schema::table('categorias', function (Blueprint $table) { |  | ||||||
|             $table->renameColumn('nombre', 'name'); |  | ||||||
|         }); |  | ||||||
|         Schema::table('pedidos', function (Blueprint $table) { |  | ||||||
|             $table->renameColumn('nombre', 'name'); |  | ||||||
|         }); |  | ||||||
|         Schema::table('regiones', function (Blueprint $table) { |  | ||||||
|             $table->renameColumn('nombre', 'name'); |  | ||||||
|         }); |  | ||||||
|         Schema::table('caracteristicas', function (Blueprint $table) { |  | ||||||
|             $table->renameColumn('nombre', 'name'); |  | ||||||
|             $table->renameColumn('codigo', 'key'); |  | ||||||
|         }); |  | ||||||
|         Schema::table('productos', function (Blueprint $table) { |  | ||||||
|             $table->renameColumn('nombre', 'name'); |  | ||||||
|             $table->renameColumn('precio', 'price'); |  | ||||||
|         }); |  | ||||||
|     } |  | ||||||
| }; |  | ||||||
|  | @ -11,9 +11,15 @@ return new class extends Migration | ||||||
|      */ |      */ | ||||||
|     public function up(): void |     public function up(): void | ||||||
|     { |     { | ||||||
|  |         Schema::create('regiones', function (Blueprint $table) { | ||||||
|  |             $table->id(); | ||||||
|  |             $table->string('nombre', 100); | ||||||
|  |             $table->timestamps(); | ||||||
|  |         }); | ||||||
|  | 
 | ||||||
|         Schema::create('barrios', function (Blueprint $table) { |         Schema::create('barrios', function (Blueprint $table) { | ||||||
|             $table->id(); |             $table->id(); | ||||||
|             $table->string('name', 100);     |             $table->string('nombre', 100);     | ||||||
|             $table->unsignedBigInteger('region_id'); |             $table->unsignedBigInteger('region_id'); | ||||||
|             $table->timestamps(); |             $table->timestamps(); | ||||||
|             $table->foreign('region_id')->references('id')->on('regiones'); |             $table->foreign('region_id')->references('id')->on('regiones'); | ||||||
|  | @ -25,6 +31,7 @@ return new class extends Migration | ||||||
|      */ |      */ | ||||||
|     public function down(): void |     public function down(): void | ||||||
|     { |     { | ||||||
|  |         Schema::dropIfExists('regiones'); | ||||||
|         Schema::dropIfExists('barrios'); |         Schema::dropIfExists('barrios'); | ||||||
|     } |     } | ||||||
| }; | }; | ||||||
|  | @ -11,10 +11,23 @@ return new class extends Migration | ||||||
|      */ |      */ | ||||||
|     public function up(): void |     public function up(): void | ||||||
|     { |     { | ||||||
|  |         Schema::create('categorias', function (Blueprint $table) { | ||||||
|  |             $table->id(); | ||||||
|  |             $table->string('nombre', 100); | ||||||
|  |             $table->timestamps(); | ||||||
|  |         }); | ||||||
|  | 
 | ||||||
|  |         Schema::create('caracteristicas', function (Blueprint $table) { | ||||||
|  |             $table->id(); | ||||||
|  |             $table->string('nombre', 100); | ||||||
|  |             $table->string('codigo', 100); | ||||||
|  |             $table->timestamps(); | ||||||
|  |         }); | ||||||
|  | 
 | ||||||
|         Schema::create('productos', function (Blueprint $table) { |         Schema::create('productos', function (Blueprint $table) { | ||||||
|             $table->id(); |             $table->id(); | ||||||
|             $table->string('name', 200); |             $table->string('nombre', 200); | ||||||
|             $table->double('price', 15, 2); |             $table->double('precio', 15, 2); | ||||||
|             $table->unsignedBigInteger('categoria_id'); |             $table->unsignedBigInteger('categoria_id'); | ||||||
|             $table->boolean('solidario'); |             $table->boolean('solidario'); | ||||||
|             $table->boolean('bono'); |             $table->boolean('bono'); | ||||||
|  | @ -25,14 +38,12 @@ return new class extends Migration | ||||||
|             $table->foreign('barrio_id')->references('id')->on('barrios'); |             $table->foreign('barrio_id')->references('id')->on('barrios'); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         Schema::create('pedido_producto', function (Blueprint $table) { |         Schema::create('producto_caracteristica', function (Blueprint $table) { | ||||||
|             $table->unsignedBigInteger('pedido_id'); |  | ||||||
|             $table->unsignedBigInteger('producto_id'); |             $table->unsignedBigInteger('producto_id'); | ||||||
|             $table->unsignedInteger('cantidad'); |             $table->unsignedBigInteger('caracteristica_id'); | ||||||
|             $table->timestamps(); |             $table->primary(['producto_id','caracteristica_id']); | ||||||
|             $table->primary(['pedido_id','producto_id']); |  | ||||||
|             $table->foreign('pedido_id')->references('id')->on('pedidos'); |  | ||||||
|             $table->foreign('producto_id')->references('id')->on('productos'); |             $table->foreign('producto_id')->references('id')->on('productos'); | ||||||
|  |             $table->foreign('caracteristica_id')->references('id')->on('caracteristicas'); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -41,7 +52,9 @@ return new class extends Migration | ||||||
|      */ |      */ | ||||||
|     public function down(): void |     public function down(): void | ||||||
|     { |     { | ||||||
|         Schema::dropIfExists('pedido_producto'); |         Schema::dropIfExists('producto_caracteristica'); | ||||||
|         Schema::dropIfExists('productos'); |         Schema::dropIfExists('productos'); | ||||||
|  |         Schema::dropIfExists('caracteristicas'); | ||||||
|  |         Schema::dropIfExists('categorias'); | ||||||
|     } |     } | ||||||
| }; | }; | ||||||
|  | @ -13,12 +13,13 @@ return new class extends Migration | ||||||
|     { |     { | ||||||
|         Schema::create('pedidos', function (Blueprint $table) { |         Schema::create('pedidos', function (Blueprint $table) { | ||||||
|             $table->id(); |             $table->id(); | ||||||
|             $table->string('name', 100); |             $table->string('nombre', 100); | ||||||
|             $table->boolean('confirmed')->default(false); |             $table->boolean('terminado')->default(false); | ||||||
|  |             $table->boolean('pagado')->default(false); | ||||||
|             $table->unsignedBigInteger('barrio_id'); |             $table->unsignedBigInteger('barrio_id'); | ||||||
|             $table->timestamps(); |             $table->timestamps(); | ||||||
|             $table->foreign('barrio_id')->references('id')->on('barrios'); |             $table->foreign('barrio_id')->references('id')->on('barrios'); | ||||||
|             $table->unique(['barrio_id','name']); |             $table->unique(['barrio_id','nombre']); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue