Tablas simplificadas

This commit is contained in:
Alejandro Tasistro 2025-05-15 00:52:12 -03:00
parent fc367c05a3
commit f8b487cebd
4 changed files with 161 additions and 0 deletions

View file

@ -0,0 +1,45 @@
<?php
use App\User;
use App\UserRole;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class SimplificarUsers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->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();
}
}
}

View file

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class SimplificarBarrios extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('grupos_de_compra', function (Blueprint $table) {
$table->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');
});
}
}

View file

@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class SimplificarProductos extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('productos', function (Blueprint $table) {
$table->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();
});
}
}

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class SimplificarProductoSubpedido extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('producto_subpedido', function (Blueprint $table) {
$table->dropColumn('total');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('producto_subpedido', function (Blueprint $table) {
$table->double('total');
});
}
}