From 3b0ad4b4f0008f51dffb476cff87073530d40a93 Mon Sep 17 00:00:00 2001 From: ale Date: Wed, 3 Jul 2024 19:58:59 -0300 Subject: [PATCH] traduccion y creacion unidas + tablas agrupadas --- ...024_03_11_205603_create_regiones_table.php | 28 --------- ...4_03_11_223553_create_categorias_table.php | 28 --------- ...12_201127_create_caracteristicas_table.php | 38 ------------ .../2024_07_03_215823_traduccion.php | 62 ------------------- ..._07_03_224916_tablas_regiones_barrios.php} | 9 ++- ..._categorias_caracteristicas_productos.php} | 31 +++++++--- ...hp => 2024_07_03_225341_tabla_pedidos.php} | 7 ++- 7 files changed, 34 insertions(+), 169 deletions(-) delete mode 100644 database/migrations/2024_03_11_205603_create_regiones_table.php delete mode 100644 database/migrations/2024_03_11_223553_create_categorias_table.php delete mode 100644 database/migrations/2024_03_12_201127_create_caracteristicas_table.php delete mode 100644 database/migrations/2024_07_03_215823_traduccion.php rename database/migrations/{2024_03_11_210402_create_barrios_table.php => 2024_07_03_224916_tablas_regiones_barrios.php} (70%) rename database/migrations/{2024_03_11_224041_create_productos_table.php => 2024_07_03_225114_tablas_categorias_caracteristicas_productos.php} (55%) rename database/migrations/{2024_03_11_221942_create_pedidos_table.php => 2024_07_03_225341_tabla_pedidos.php} (76%) diff --git a/database/migrations/2024_03_11_205603_create_regiones_table.php b/database/migrations/2024_03_11_205603_create_regiones_table.php deleted file mode 100644 index 8417e86..0000000 --- a/database/migrations/2024_03_11_205603_create_regiones_table.php +++ /dev/null @@ -1,28 +0,0 @@ -id(); - $table->string('name', 100); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('regiones'); - } -}; diff --git a/database/migrations/2024_03_11_223553_create_categorias_table.php b/database/migrations/2024_03_11_223553_create_categorias_table.php deleted file mode 100644 index f67f14c..0000000 --- a/database/migrations/2024_03_11_223553_create_categorias_table.php +++ /dev/null @@ -1,28 +0,0 @@ -id(); - $table->string('name', 100); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('categorias'); - } -}; diff --git a/database/migrations/2024_03_12_201127_create_caracteristicas_table.php b/database/migrations/2024_03_12_201127_create_caracteristicas_table.php deleted file mode 100644 index 0aaf24a..0000000 --- a/database/migrations/2024_03_12_201127_create_caracteristicas_table.php +++ /dev/null @@ -1,38 +0,0 @@ -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'); - } -}; diff --git a/database/migrations/2024_07_03_215823_traduccion.php b/database/migrations/2024_07_03_215823_traduccion.php deleted file mode 100644 index 926a361..0000000 --- a/database/migrations/2024_07_03_215823_traduccion.php +++ /dev/null @@ -1,62 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2024_03_11_210402_create_barrios_table.php b/database/migrations/2024_07_03_224916_tablas_regiones_barrios.php similarity index 70% rename from database/migrations/2024_03_11_210402_create_barrios_table.php rename to database/migrations/2024_07_03_224916_tablas_regiones_barrios.php index ea8018e..e87c33c 100644 --- a/database/migrations/2024_03_11_210402_create_barrios_table.php +++ b/database/migrations/2024_07_03_224916_tablas_regiones_barrios.php @@ -11,9 +11,15 @@ */ public function up(): void { + Schema::create('regiones', function (Blueprint $table) { + $table->id(); + $table->string('nombre', 100); + $table->timestamps(); + }); + Schema::create('barrios', function (Blueprint $table) { $table->id(); - $table->string('name', 100); + $table->string('nombre', 100); $table->unsignedBigInteger('region_id'); $table->timestamps(); $table->foreign('region_id')->references('id')->on('regiones'); @@ -25,6 +31,7 @@ public function up(): void */ public function down(): void { + Schema::dropIfExists('regiones'); Schema::dropIfExists('barrios'); } }; diff --git a/database/migrations/2024_03_11_224041_create_productos_table.php b/database/migrations/2024_07_03_225114_tablas_categorias_caracteristicas_productos.php similarity index 55% rename from database/migrations/2024_03_11_224041_create_productos_table.php rename to database/migrations/2024_07_03_225114_tablas_categorias_caracteristicas_productos.php index 4557bce..441f5d8 100644 --- a/database/migrations/2024_03_11_224041_create_productos_table.php +++ b/database/migrations/2024_07_03_225114_tablas_categorias_caracteristicas_productos.php @@ -11,10 +11,23 @@ */ 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) { $table->id(); - $table->string('name', 200); - $table->double('price', 15, 2); + $table->string('nombre', 200); + $table->double('precio', 15, 2); $table->unsignedBigInteger('categoria_id'); $table->boolean('solidario'); $table->boolean('bono'); @@ -25,14 +38,12 @@ public function up(): void $table->foreign('barrio_id')->references('id')->on('barrios'); }); - Schema::create('pedido_producto', function (Blueprint $table) { - $table->unsignedBigInteger('pedido_id'); + Schema::create('producto_caracteristica', function (Blueprint $table) { $table->unsignedBigInteger('producto_id'); - $table->unsignedInteger('cantidad'); - $table->timestamps(); - $table->primary(['pedido_id','producto_id']); - $table->foreign('pedido_id')->references('id')->on('pedidos'); + $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'); }); } @@ -41,7 +52,9 @@ public function up(): void */ public function down(): void { - Schema::dropIfExists('pedido_producto'); + Schema::dropIfExists('producto_caracteristica'); Schema::dropIfExists('productos'); + Schema::dropIfExists('caracteristicas'); + Schema::dropIfExists('categorias'); } }; diff --git a/database/migrations/2024_03_11_221942_create_pedidos_table.php b/database/migrations/2024_07_03_225341_tabla_pedidos.php similarity index 76% rename from database/migrations/2024_03_11_221942_create_pedidos_table.php rename to database/migrations/2024_07_03_225341_tabla_pedidos.php index f8cd7c1..cfcdf95 100644 --- a/database/migrations/2024_03_11_221942_create_pedidos_table.php +++ b/database/migrations/2024_07_03_225341_tabla_pedidos.php @@ -13,12 +13,13 @@ public function up(): void { Schema::create('pedidos', function (Blueprint $table) { $table->id(); - $table->string('name', 100); - $table->boolean('confirmed')->default(false); + $table->string('nombre', 100); + $table->boolean('terminado')->default(false); + $table->boolean('pagado')->default(false); $table->unsignedBigInteger('barrio_id'); $table->timestamps(); $table->foreign('barrio_id')->references('id')->on('barrios'); - $table->unique(['barrio_id','name']); + $table->unique(['barrio_id','nombre']); }); }