From f8b487cebd07707cda00034920fdb5b8f87c803b Mon Sep 17 00:00:00 2001 From: ale Date: Thu, 15 May 2025 00:52:12 -0300 Subject: [PATCH] Tablas simplificadas --- .../2025_05_15_033316_simplificar_users.php | 45 +++++++++++++++++++ .../2025_05_15_033711_simplificar_barrios.php | 40 +++++++++++++++++ ...025_05_15_034325_simplificar_productos.php | 44 ++++++++++++++++++ ..._034910_simplificar_producto_subpedido.php | 32 +++++++++++++ 4 files changed, 161 insertions(+) create mode 100644 database/migrations/2025_05_15_033316_simplificar_users.php create mode 100644 database/migrations/2025_05_15_033711_simplificar_barrios.php create mode 100644 database/migrations/2025_05_15_034325_simplificar_productos.php create mode 100644 database/migrations/2025_05_15_034910_simplificar_producto_subpedido.php diff --git a/database/migrations/2025_05_15_033316_simplificar_users.php b/database/migrations/2025_05_15_033316_simplificar_users.php new file mode 100644 index 0000000..b97e20a --- /dev/null +++ b/database/migrations/2025_05_15_033316_simplificar_users.php @@ -0,0 +1,45 @@ +dropColumn(['is_admin', 'is_compras']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->boolean('is_admin')->default(false); + $table->boolean('is_compras')->default(false); + }); + + $admin_barrio = UserRole::where('nombre', 'admin_barrio')->first(); + $comision = UserRole::where('nombre', 'comision')->first(); + foreach (User::all() as $user) { + if ($user->role_id == $admin_barrio->id) + $user->is_admin = true; + if ($user->role_id == $comision->id) + $user->is_compras = true; + $user->save(); + } + } +} diff --git a/database/migrations/2025_05_15_033711_simplificar_barrios.php b/database/migrations/2025_05_15_033711_simplificar_barrios.php new file mode 100644 index 0000000..f7d4e6e --- /dev/null +++ b/database/migrations/2025_05_15_033711_simplificar_barrios.php @@ -0,0 +1,40 @@ +dropColumn([ + 'cantidad_de_nucleos', + 'telefono', + 'correo', + 'referente_finanzas', + ]); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('grupos_de_compra', function (Blueprint $table) { + $table->double('cantidad_de_nucleos'); + $table->string('telefono'); + $table->string('correo'); + $table->string('referente_finanzas'); + }); + } +} diff --git a/database/migrations/2025_05_15_034325_simplificar_productos.php b/database/migrations/2025_05_15_034325_simplificar_productos.php new file mode 100644 index 0000000..079b389 --- /dev/null +++ b/database/migrations/2025_05_15_034325_simplificar_productos.php @@ -0,0 +1,44 @@ +dropColumn([ + 'presentacion', + 'stock', + 'imagen_id', + 'descripcion', + 'apto_veganxs', + 'apto_celiacxs', + ]); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('productos', function (Blueprint $table) { + $table->integer('presentacion')->nullable(); + $table->integer('stock')->nullable(); + $table->foreignId('imagen_id')->nullable(); + $table->string('descripcion')->nullable(); + $table->boolean('apto_veganxs')->nullable(); + $table->boolean('apto_celiacxs')->nullable(); + }); + } +} diff --git a/database/migrations/2025_05_15_034910_simplificar_producto_subpedido.php b/database/migrations/2025_05_15_034910_simplificar_producto_subpedido.php new file mode 100644 index 0000000..ce6245f --- /dev/null +++ b/database/migrations/2025_05_15_034910_simplificar_producto_subpedido.php @@ -0,0 +1,32 @@ +dropColumn('total'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('producto_subpedido', function (Blueprint $table) { + $table->double('total'); + }); + } +}