Estructura de base de datos, migraciones, factories y seeders
This commit is contained in:
@@ -14,7 +14,7 @@ return new class extends Migration
|
||||
Schema::create('bajas', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->text('motivo')->nullable();
|
||||
$table->text('descripcion');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -25,15 +25,12 @@ return new class extends Migration
|
||||
$table->foreignId('credencialprofesional_id')
|
||||
->constrained('credencialesprofesionales');
|
||||
|
||||
$table->foreignId('estadoprofesional_id')
|
||||
->constrained('estadosprofesionales');
|
||||
|
||||
$table->foreignId('persona_id')
|
||||
->constrained('personas');
|
||||
|
||||
$table->foreignId('baja_id')
|
||||
->nullable()
|
||||
->constrained('bajas');
|
||||
->default(1)
|
||||
->constrained('bajas');
|
||||
|
||||
$table->unique(['profesion_id', 'matricula']);
|
||||
});
|
||||
|
||||
@@ -26,8 +26,9 @@ return new class extends Migration
|
||||
->constrained('personas')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreignId('baja_id')->nullable()
|
||||
->constrained('bajas')
|
||||
$table->foreignId('baja_id')
|
||||
->default(1)
|
||||
->constrained('bajas')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->unique(['dni','correo']);
|
||||
|
||||
@@ -14,7 +14,6 @@ return new class extends Migration
|
||||
Schema::create('diasdeatenciones', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->string('descripcion');
|
||||
$table->foreignId('agenda_id')
|
||||
->constrained('agendas')
|
||||
->onDelete('cascade');
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::table('bajas')->updateOrInsert(
|
||||
['id' => 1],
|
||||
[
|
||||
'descripcion' => 'Activo',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]
|
||||
);
|
||||
|
||||
DB::table('bajas')->updateOrInsert(
|
||||
['id' => 2],
|
||||
[
|
||||
'descripcion' => 'Baja',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]
|
||||
);
|
||||
|
||||
DB::statement('ALTER TABLE profesionales MODIFY baja_id BIGINT UNSIGNED NOT NULL DEFAULT 1');
|
||||
DB::statement('ALTER TABLE clientes MODIFY baja_id BIGINT UNSIGNED NOT NULL DEFAULT 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::statement('ALTER TABLE profesionales MODIFY baja_id BIGINT UNSIGNED NOT NULL');
|
||||
DB::statement('ALTER TABLE clientes MODIFY baja_id BIGINT UNSIGNED NOT NULL');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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
|
||||
{
|
||||
if (!Schema::hasColumn('servicios', 'visibleenweb')) {
|
||||
Schema::table('servicios', function (Blueprint $table) {
|
||||
$table->text('visibleenweb')->default('si');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (Schema::hasColumn('servicios', 'visibleenweb')) {
|
||||
Schema::table('servicios', function (Blueprint $table) {
|
||||
$table->dropColumn('visibleenweb');
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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('profesionales_profesiones', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreignId('profesional_id')
|
||||
->constrained('profesionales')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreignId('profesion_id')
|
||||
->constrained('profesiones')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->unique(['profesional_id', 'profesion_id'], 'profesionales_profesiones_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('profesionales_profesiones');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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('faq_asistentes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('intencion', 100)->nullable();
|
||||
$table->json('palabras_clave')->nullable();
|
||||
$table->text('respuesta');
|
||||
$table->unsignedSmallInteger('orden')->default(0);
|
||||
$table->boolean('activo')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('faq_asistentes');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('contenidoswebs', function (Blueprint $table) {
|
||||
$table->string('version')->default('1.0.0')->after('quienessomos');
|
||||
});
|
||||
|
||||
DB::table('contenidoswebs')->update([
|
||||
'version' => '1.0.0',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('contenidoswebs', function (Blueprint $table) {
|
||||
$table->dropColumn('version');
|
||||
});
|
||||
}
|
||||
};
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?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
|
||||
{
|
||||
if (Schema::hasColumn('diasdeatenciones', 'descripcion')) {
|
||||
Schema::table('diasdeatenciones', function (Blueprint $table) {
|
||||
$table->dropColumn('descripcion');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (!Schema::hasColumn('diasdeatenciones', 'descripcion')) {
|
||||
Schema::table('diasdeatenciones', function (Blueprint $table) {
|
||||
$table->string('descripcion')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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
|
||||
{
|
||||
if (!Schema::hasColumn('turnos', 'celular')) {
|
||||
Schema::table('turnos', function (Blueprint $table) {
|
||||
$table->string('celular')->nullable()->after('correo');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (Schema::hasColumn('turnos', 'celular')) {
|
||||
Schema::table('turnos', function (Blueprint $table) {
|
||||
$table->dropColumn('celular');
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
<?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
|
||||
{
|
||||
if (Schema::hasTable('credencialesclientes') && !Schema::hasColumn('credencialesclientes', 'session_id')) {
|
||||
Schema::table('credencialesclientes', function (Blueprint $table) {
|
||||
$table->string('session_id')->nullable()->after('token');
|
||||
});
|
||||
}
|
||||
|
||||
if (Schema::hasTable('credencialesprofesionales') && !Schema::hasColumn('credencialesprofesionales', 'session_id')) {
|
||||
Schema::table('credencialesprofesionales', function (Blueprint $table) {
|
||||
$table->string('session_id')->nullable()->after('token');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (Schema::hasTable('credencialesclientes') && Schema::hasColumn('credencialesclientes', 'session_id')) {
|
||||
Schema::table('credencialesclientes', function (Blueprint $table) {
|
||||
$table->dropColumn('session_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (Schema::hasTable('credencialesprofesionales') && Schema::hasColumn('credencialesprofesionales', 'session_id')) {
|
||||
Schema::table('credencialesprofesionales', function (Blueprint $table) {
|
||||
$table->dropColumn('session_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('notificaciones', function (Blueprint $table) {
|
||||
$table->bigIncrements('notificacion_id');
|
||||
$table->string('tipo');
|
||||
$table->text('mensaje_inicio');
|
||||
$table->text('mensaje_final');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('notificaciones');
|
||||
}
|
||||
};
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('credencialesclientes', function (Blueprint $table) {
|
||||
$table->string('reset_token')->nullable()->after('token');
|
||||
$table->datetime('reset_expira_en')->nullable()->after('reset_token');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('credencialesclientes', function (Blueprint $table) {
|
||||
$table->dropColumn(['reset_token', 'reset_expira_en']);
|
||||
});
|
||||
}
|
||||
};
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('credencialesprofesionales', function (Blueprint $table) {
|
||||
$table->string('reset_token')->nullable()->after('token');
|
||||
$table->datetime('reset_expira_en')->nullable()->after('reset_token');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('credencialesprofesionales', function (Blueprint $table) {
|
||||
$table->dropColumn(['reset_token', 'reset_expira_en']);
|
||||
});
|
||||
}
|
||||
};
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('administradores', function (Blueprint $table) {
|
||||
$table->string('pregunta_secreta_hash')->nullable()->after('correo');
|
||||
$table->string('respuesta_secreta_hash')->nullable()->after('pregunta_secreta_hash');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('administradores', function (Blueprint $table) {
|
||||
$table->dropColumn(['pregunta_secreta_hash', 'respuesta_secreta_hash']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('formularios', function (Blueprint $table) {
|
||||
$table->string('ip_origen', 45)->nullable()->after('celular');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('formularios', function (Blueprint $table) {
|
||||
$table->dropColumn('ip_origen');
|
||||
});
|
||||
}
|
||||
};
|
||||
+5
-5
@@ -11,10 +11,8 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('estadosprofesionales', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->string('descripcion')->default('Activo');
|
||||
Schema::table('servicios', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('foto_id')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,6 +21,8 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('estadosprofesionales');
|
||||
Schema::table('servicios', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('foto_id')->nullable(false)->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('logseguridades', function (Blueprint $table) {
|
||||
$table->string('accion_descripcion')->nullable()->after('accion_id');
|
||||
$table->string('responsable_nombre')->nullable()->after('persona_id');
|
||||
});
|
||||
|
||||
DB::statement(<<<'SQL'
|
||||
UPDATE logseguridades AS logs
|
||||
LEFT JOIN accioneslogs AS acciones ON acciones.id = logs.accion_id
|
||||
LEFT JOIN personas AS personas ON personas.id = logs.persona_id
|
||||
SET
|
||||
logs.accion_descripcion = COALESCE(logs.accion_descripcion, acciones.descripcion),
|
||||
logs.responsable_nombre = COALESCE(
|
||||
logs.responsable_nombre,
|
||||
NULLIF(TRIM(CONCAT(COALESCE(personas.nombre, ''), ' ', COALESCE(personas.apellido, ''))), '')
|
||||
)
|
||||
SQL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('logseguridades', function (Blueprint $table) {
|
||||
$table->dropColumn(['accion_descripcion', 'responsable_nombre']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::table('accioneslogs')->updateOrInsert(
|
||||
['descripcion' => 'Edito los datos del administrador'],
|
||||
[
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::table('accioneslogs')
|
||||
->where('descripcion', 'Edito los datos del administrador')
|
||||
->delete();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('asistente_sin_respuesta', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->text('consulta');
|
||||
$table->boolean('revisado')->default(false);
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('asistente_sin_respuesta');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user