Files
construprogress/database/migrations/2026_05_13_075321_create_companies_table.php
T
javier 9bd6fd898d refactor(migrations): consolidar add_* en sus create_* (49 → 28)
Pliega las migraciones de "añadir/modificar columna" dentro de la migración create
de cada tabla, con esquema final idéntico (verificado por diff normalizado de columnas
+ índices y suite completa):
- users (locale, notes), projects (reference/external_reference_1/country),
  companies (apodo/estado/logo_path), layers (color; sin geojson_data),
  phases (fechas), features (status/responsible_user_id + sync + softDeletes),
  inspection_templates (phase_id), inspections (workflow + sync + softDeletes),
  issues (type + sync), progress_updates/media (sync), issue_tasks (overdue),
  permissions (group/description) y roles (description); soft-deletes en sus creates.
- Se mantienen las que dependen de orden/FK: add_profile_fields (users.company_id → companies)
  y update_inspections_feature_id_foreign (feature_id → features).
- Eliminado database/schema/mysql-schema.sql (obsoleto): las instalaciones nuevas
  ejecutan las migraciones; las BD existentes no se tocan. Regenerable con schema:dump.

Suite 75 passing. Esquema SQLite idéntico antes/después.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 18:40:54 +02:00

39 lines
1.2 KiB
PHP

<?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('companies', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('apodo')->nullable();
$table->enum('estado', ['activo', 'inactivo', 'suspendido'])->default('activo');
$table->string('tax_id')->nullable()->unique();
$table->string('address')->nullable();
$table->string('phone')->nullable();
$table->string('email')->nullable();
$table->string('website')->nullable();
$table->enum('type', ['owner', 'constructor', 'subcontractor', 'consultant', 'supplier', 'other'])->default('other');
$table->text('notes')->nullable();
$table->string('logo_path')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('companies');
}
};