traduccion y creacion unidas + tablas agrupadas
This commit is contained in:
parent
73752f90de
commit
3b0ad4b4f0
|
@ -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 @@
|
|||
*/
|
||||
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');
|
||||
}
|
||||
};
|
|
@ -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');
|
||||
}
|
||||
};
|
|
@ -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']);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue