From 9bd6fd898dcec444fbb42ddff2230ce0fe5a4d43 Mon Sep 17 00:00:00 2001 From: javier Date: Fri, 19 Jun 2026 18:40:54 +0200 Subject: [PATCH] =?UTF-8?q?refactor(migrations):=20consolidar=20add=5F*=20?= =?UTF-8?q?en=20sus=20create=5F*=20(49=20=E2=86=92=2028)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../0001_01_01_000000_create_users_table.php | 2 + ...026_04_27_095918_create_projects_table.php | 4 + .../2026_04_27_095919_create_phases_table.php | 5 + .../2026_04_27_095920_create_layers_table.php | 3 +- ...7_095921_create_progress_updates_table.php | 2 + ..._04_27_095926_create_permission_tables.php | 3 + ...0208_create_inspection_templates_table.php | 2 + ..._04_28_090218_create_inspections_table.php | 8 + ...026_05_06_122423_create_features_table.php | 5 + ...6_125429_drop_geojson_data_from_layers.php | 28 -- ...05_06_172557_add_color_to_layers_table.php | 28 -- .../2026_05_09_210000_create_media_table.php | 2 + ...05_09_220000_add_locale_to_users_table.php | 22 - ...2_add_phase_id_to_inspection_templates.php | 30 -- ...26_05_13_075321_create_companies_table.php | 3 + ...15830_add_logo_path_to_companies_table.php | 28 -- ...dd_apodo_and_estado_to_companies_table.php | 29 -- ...26_06_16_000001_add_status_to_features.php | 31 -- ..._16_000002_add_workflow_to_inspections.php | 43 -- .../2026_06_16_000003_add_dates_to_phases.php | 25 -- .../2026_06_16_000004_add_soft_deletes.php | 34 -- .../2026_06_16_000005_create_issues_table.php | 4 + ..._06_16_113943_add_notes_to_users_table.php | 25 -- ...eference_and_country_to_projects_table.php | 25 -- ...0_change_locale_default_in_users_table.php | 29 -- ..._170000_add_description_to_roles_table.php | 30 -- ...p_and_description_to_permissions_table.php | 35 -- ..._sync_fields_to_progress_updates_table.php | 31 -- ...070200_add_reference_to_projects_table.php | 37 -- ...000_add_sync_fields_to_syncable_tables.php | 37 -- ..._080000_add_sync_fields_to_media_table.php | 31 -- ..._06_18_120000_create_issue_tasks_table.php | 1 + ...erdue_notified_at_to_issue_tasks_table.php | 22 - ..._06_18_140000_add_type_to_issues_table.php | 22 - database/schema/mysql-schema.sql | 419 ------------------ 35 files changed, 43 insertions(+), 1042 deletions(-) delete mode 100644 database/migrations/2026_05_06_125429_drop_geojson_data_from_layers.php delete mode 100644 database/migrations/2026_05_06_172557_add_color_to_layers_table.php delete mode 100644 database/migrations/2026_05_09_220000_add_locale_to_users_table.php delete mode 100644 database/migrations/2026_05_11_115552_add_phase_id_to_inspection_templates.php delete mode 100644 database/migrations/2026_05_26_115830_add_logo_path_to_companies_table.php delete mode 100644 database/migrations/2026_05_26_135412_add_apodo_and_estado_to_companies_table.php delete mode 100644 database/migrations/2026_06_16_000001_add_status_to_features.php delete mode 100644 database/migrations/2026_06_16_000002_add_workflow_to_inspections.php delete mode 100644 database/migrations/2026_06_16_000003_add_dates_to_phases.php delete mode 100644 database/migrations/2026_06_16_000004_add_soft_deletes.php delete mode 100644 database/migrations/2026_06_16_113943_add_notes_to_users_table.php delete mode 100644 database/migrations/2026_06_16_121135_add_reference_and_country_to_projects_table.php delete mode 100644 database/migrations/2026_06_16_150140_change_locale_default_in_users_table.php delete mode 100644 database/migrations/2026_06_17_170000_add_description_to_roles_table.php delete mode 100644 database/migrations/2026_06_17_180000_add_group_and_description_to_permissions_table.php delete mode 100644 database/migrations/2026_06_18_070100_add_sync_fields_to_progress_updates_table.php delete mode 100644 database/migrations/2026_06_18_070200_add_reference_to_projects_table.php delete mode 100644 database/migrations/2026_06_18_073000_add_sync_fields_to_syncable_tables.php delete mode 100644 database/migrations/2026_06_18_080000_add_sync_fields_to_media_table.php delete mode 100644 database/migrations/2026_06_18_130100_add_overdue_notified_at_to_issue_tasks_table.php delete mode 100644 database/migrations/2026_06_18_140000_add_type_to_issues_table.php delete mode 100644 database/schema/mysql-schema.sql diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index 05fb5d9..dcbf994 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -18,6 +18,8 @@ return new class extends Migration $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->rememberToken(); + $table->string('locale', 5)->default('es'); + $table->text('notes')->nullable(); $table->timestamps(); }); diff --git a/database/migrations/2026_04_27_095918_create_projects_table.php b/database/migrations/2026_04_27_095918_create_projects_table.php index 69a3b2a..b15d93b 100644 --- a/database/migrations/2026_04_27_095918_create_projects_table.php +++ b/database/migrations/2026_04_27_095918_create_projects_table.php @@ -10,8 +10,11 @@ return new class extends Migration { Schema::create('projects', function (Blueprint $table) { $table->id(); + $table->string('reference')->nullable(); + $table->string('external_reference_1')->nullable(); $table->string('name'); $table->text('address'); + $table->char('country', 2)->nullable(); $table->decimal('lat', 10, 8); $table->decimal('lng', 11, 8); $table->date('start_date'); @@ -19,6 +22,7 @@ return new class extends Migration $table->enum('status', ['planning', 'in_progress', 'paused', 'completed'])->default('planning'); $table->foreignId('created_by')->constrained('users'); $table->timestamps(); + $table->softDeletes(); }); } diff --git a/database/migrations/2026_04_27_095919_create_phases_table.php b/database/migrations/2026_04_27_095919_create_phases_table.php index 4fc6d53..a844d43 100644 --- a/database/migrations/2026_04_27_095919_create_phases_table.php +++ b/database/migrations/2026_04_27_095919_create_phases_table.php @@ -16,7 +16,12 @@ return new class extends Migration $table->integer('order')->default(0); $table->string('color', 7)->default('#3b82f6'); // hex color $table->integer('progress_percent')->default(0); + $table->date('planned_start')->nullable(); + $table->date('planned_end')->nullable(); + $table->date('actual_start')->nullable(); + $table->date('actual_end')->nullable(); $table->timestamps(); + $table->softDeletes(); }); } diff --git a/database/migrations/2026_04_27_095920_create_layers_table.php b/database/migrations/2026_04_27_095920_create_layers_table.php index ad1ee60..4d3f313 100644 --- a/database/migrations/2026_04_27_095920_create_layers_table.php +++ b/database/migrations/2026_04_27_095920_create_layers_table.php @@ -13,10 +13,11 @@ return new class extends Migration $table->foreignId('project_id')->constrained()->onDelete('cascade'); $table->foreignId('phase_id')->nullable()->constrained()->onDelete('set null'); $table->string('name'); - $table->json('geojson_data'); // GeoJSON geometry collection + $table->string('color', 7)->default('#3b82f6'); $table->string('original_file')->nullable(); // path to original uploaded file $table->foreignId('uploaded_by')->constrained('users'); $table->timestamps(); + $table->softDeletes(); }); } diff --git a/database/migrations/2026_04_27_095921_create_progress_updates_table.php b/database/migrations/2026_04_27_095921_create_progress_updates_table.php index 8344e19..f0a8aba 100644 --- a/database/migrations/2026_04_27_095921_create_progress_updates_table.php +++ b/database/migrations/2026_04_27_095921_create_progress_updates_table.php @@ -10,11 +10,13 @@ return new class extends Migration { Schema::create('progress_updates', function (Blueprint $table) { $table->id(); + $table->uuid('uuid')->nullable()->unique(); $table->foreignId('phase_id')->constrained()->onDelete('cascade'); $table->foreignId('user_id')->constrained(); $table->integer('progress_percent'); $table->text('comment')->nullable(); $table->json('location')->nullable(); // GPS point from mobile + $table->timestamp('client_updated_at')->nullable(); $table->timestamps(); }); } diff --git a/database/migrations/2026_04_27_095926_create_permission_tables.php b/database/migrations/2026_04_27_095926_create_permission_tables.php index 66ce1f9..86ba641 100644 --- a/database/migrations/2026_04_27_095926_create_permission_tables.php +++ b/database/migrations/2026_04_27_095926_create_permission_tables.php @@ -24,6 +24,8 @@ return new class extends Migration // $table->engine('InnoDB'); $table->bigIncrements('id'); // permission id $table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format) + $table->string('group')->nullable(); + $table->string('description')->nullable(); $table->string('guard_name'); // For MyISAM use string('guard_name', 25); $table->timestamps(); @@ -38,6 +40,7 @@ return new class extends Migration $table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index'); } $table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format) + $table->string('description')->nullable(); $table->string('guard_name'); // For MyISAM use string('guard_name', 25); $table->timestamps(); if ($teams || config('permission.testing')) { diff --git a/database/migrations/2026_04_28_090208_create_inspection_templates_table.php b/database/migrations/2026_04_28_090208_create_inspection_templates_table.php index 2f62f33..3092741 100644 --- a/database/migrations/2026_04_28_090208_create_inspection_templates_table.php +++ b/database/migrations/2026_04_28_090208_create_inspection_templates_table.php @@ -16,7 +16,9 @@ return new class extends Migration $table->string('name'); $table->text('description')->nullable(); $table->foreignId('project_id')->nullable()->constrained()->onDelete('cascade'); + $table->foreignId('phase_id')->nullable()->constrained('phases')->onDelete('set null'); $table->json('fields'); // [{name, label, type, options, required}] + $table->index('phase_id'); $table->timestamps(); }); } diff --git a/database/migrations/2026_04_28_090218_create_inspections_table.php b/database/migrations/2026_04_28_090218_create_inspections_table.php index f74ea62..9200e1d 100644 --- a/database/migrations/2026_04_28_090218_create_inspections_table.php +++ b/database/migrations/2026_04_28_090218_create_inspections_table.php @@ -13,13 +13,21 @@ return new class extends Migration { Schema::create('inspections', function (Blueprint $table) { $table->id(); + $table->uuid('uuid')->nullable()->unique(); $table->foreignId('project_id')->constrained()->onDelete('cascade'); $table->foreignId('layer_id')->constrained()->onDelete('cascade'); $table->string('feature_id'); // ID del elemento GeoJSON $table->foreignId('template_id')->nullable()->constrained('inspection_templates')->onDelete('set null'); $table->foreignId('user_id')->constrained(); $table->json('data'); // Valores de los campos del template + $table->enum('status', ['pending', 'in_progress', 'completed', 'approved', 'rejected'])->default('pending'); + $table->foreignId('inspector_user_id')->nullable()->constrained('users')->nullOnDelete(); + $table->timestamp('completed_at')->nullable(); + $table->enum('result', ['pass', 'fail', 'conditional'])->nullable(); + $table->text('notes')->nullable(); + $table->timestamp('client_updated_at')->nullable(); $table->timestamps(); + $table->softDeletes(); }); } diff --git a/database/migrations/2026_05_06_122423_create_features_table.php b/database/migrations/2026_05_06_122423_create_features_table.php index 2c028e9..2af66d8 100644 --- a/database/migrations/2026_05_06_122423_create_features_table.php +++ b/database/migrations/2026_05_06_122423_create_features_table.php @@ -13,14 +13,19 @@ return new class extends Migration { Schema::create('features', function (Blueprint $table) { $table->id(); + $table->uuid('uuid')->nullable()->unique(); $table->foreignId('layer_id')->constrained()->onDelete('cascade'); $table->string('name')->nullable(); $table->json('geometry'); // GeoJSON geometry object (Point, LineString, Polygon) $table->json('properties')->nullable(); // propiedades extra (progreso, responsable, etc.) $table->foreignId('template_id')->nullable()->constrained('inspection_templates'); $table->integer('progress')->default(0); + $table->enum('status', ['planned', 'started', 'in_progress', 'completed', 'verified'])->default('planned'); $table->string('responsible')->nullable(); + $table->foreignId('responsible_user_id')->nullable()->constrained('users')->nullOnDelete(); + $table->timestamp('client_updated_at')->nullable(); $table->timestamps(); + $table->softDeletes(); }); } diff --git a/database/migrations/2026_05_06_125429_drop_geojson_data_from_layers.php b/database/migrations/2026_05_06_125429_drop_geojson_data_from_layers.php deleted file mode 100644 index e1e5745..0000000 --- a/database/migrations/2026_05_06_125429_drop_geojson_data_from_layers.php +++ /dev/null @@ -1,28 +0,0 @@ -dropColumn('geojson_data'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('layers', function (Blueprint $table) { - $table->json('geojson_data'); // GeoJSON geometry collection - }); - } -}; diff --git a/database/migrations/2026_05_06_172557_add_color_to_layers_table.php b/database/migrations/2026_05_06_172557_add_color_to_layers_table.php deleted file mode 100644 index fed2524..0000000 --- a/database/migrations/2026_05_06_172557_add_color_to_layers_table.php +++ /dev/null @@ -1,28 +0,0 @@ -string('color', 7)->default('#3b82f6')->after('name'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('layers', function (Blueprint $table) { - $table->dropColumn('color'); - }); - } -}; diff --git a/database/migrations/2026_05_09_210000_create_media_table.php b/database/migrations/2026_05_09_210000_create_media_table.php index 0acf9d3..2893ce8 100644 --- a/database/migrations/2026_05_09_210000_create_media_table.php +++ b/database/migrations/2026_05_09_210000_create_media_table.php @@ -10,6 +10,7 @@ return new class extends Migration { Schema::create('media', function (Blueprint $table) { $table->id(); + $table->uuid('uuid')->nullable()->unique(); $table->morphs('mediable'); // project, phase, layer, feature $table->string('name'); $table->string('file_path'); @@ -20,6 +21,7 @@ return new class extends Migration $table->text('description')->nullable(); $table->json('metadata')->nullable(); // EXIF, GPS coords, etc. $table->foreignId('uploaded_by')->constrained('users'); + $table->timestamp('client_updated_at')->nullable(); $table->timestamps(); }); } diff --git a/database/migrations/2026_05_09_220000_add_locale_to_users_table.php b/database/migrations/2026_05_09_220000_add_locale_to_users_table.php deleted file mode 100644 index e985039..0000000 --- a/database/migrations/2026_05_09_220000_add_locale_to_users_table.php +++ /dev/null @@ -1,22 +0,0 @@ -string('locale', 5)->default('en')->after('remember_token'); - }); - } - - public function down() - { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('locale'); - }); - } -}; \ No newline at end of file diff --git a/database/migrations/2026_05_11_115552_add_phase_id_to_inspection_templates.php b/database/migrations/2026_05_11_115552_add_phase_id_to_inspection_templates.php deleted file mode 100644 index c567cd7..0000000 --- a/database/migrations/2026_05_11_115552_add_phase_id_to_inspection_templates.php +++ /dev/null @@ -1,30 +0,0 @@ -foreignId('phase_id')->nullable()->constrained('phases')->onDelete('set null'); - $table->index('phase_id'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('inspection_templates', function (Blueprint $table) { - $table->dropForeign(['phase_id']); - $table->dropColumn('phase_id'); - }); - } -}; diff --git a/database/migrations/2026_05_13_075321_create_companies_table.php b/database/migrations/2026_05_13_075321_create_companies_table.php index de80105..0f9350b 100644 --- a/database/migrations/2026_05_13_075321_create_companies_table.php +++ b/database/migrations/2026_05_13_075321_create_companies_table.php @@ -14,6 +14,8 @@ return new class extends Migration 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(); @@ -21,6 +23,7 @@ return new class extends Migration $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(); }); diff --git a/database/migrations/2026_05_26_115830_add_logo_path_to_companies_table.php b/database/migrations/2026_05_26_115830_add_logo_path_to_companies_table.php deleted file mode 100644 index d3b6455..0000000 --- a/database/migrations/2026_05_26_115830_add_logo_path_to_companies_table.php +++ /dev/null @@ -1,28 +0,0 @@ -string('logo_path')->nullable()->after('notes'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('companies', function (Blueprint $table) { - $table->dropColumn('logo_path'); - }); - } -}; \ No newline at end of file diff --git a/database/migrations/2026_05_26_135412_add_apodo_and_estado_to_companies_table.php b/database/migrations/2026_05_26_135412_add_apodo_and_estado_to_companies_table.php deleted file mode 100644 index a73ff95..0000000 --- a/database/migrations/2026_05_26_135412_add_apodo_and_estado_to_companies_table.php +++ /dev/null @@ -1,29 +0,0 @@ -string('apodo')->nullable()->after('name'); - $table->enum('estado', ['activo', 'inactivo', 'suspendido'])->default('activo')->after('apodo'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('companies', function (Blueprint $table) { - $table->dropColumn(['apodo', 'estado']); - }); - } -}; \ No newline at end of file diff --git a/database/migrations/2026_06_16_000001_add_status_to_features.php b/database/migrations/2026_06_16_000001_add_status_to_features.php deleted file mode 100644 index 32e8214..0000000 --- a/database/migrations/2026_06_16_000001_add_status_to_features.php +++ /dev/null @@ -1,31 +0,0 @@ -enum('status', ['planned', 'started', 'in_progress', 'completed', 'verified']) - ->default('planned') - ->after('progress'); - - $table->foreignId('responsible_user_id') - ->nullable() - ->constrained('users') - ->nullOnDelete() - ->after('responsible'); - }); - } - - public function down(): void - { - Schema::table('features', function (Blueprint $table) { - $table->dropForeign(['responsible_user_id']); - $table->dropColumn(['status', 'responsible_user_id']); - }); - } -}; diff --git a/database/migrations/2026_06_16_000002_add_workflow_to_inspections.php b/database/migrations/2026_06_16_000002_add_workflow_to_inspections.php deleted file mode 100644 index 29d4810..0000000 --- a/database/migrations/2026_06_16_000002_add_workflow_to_inspections.php +++ /dev/null @@ -1,43 +0,0 @@ -enum('status', ['pending', 'in_progress', 'completed', 'approved', 'rejected']) - ->default('pending') - ->after('data'); - - $table->foreignId('inspector_user_id') - ->nullable() - ->constrained('users') - ->nullOnDelete() - ->after('status'); - - $table->timestamp('completed_at') - ->nullable() - ->after('inspector_user_id'); - - $table->enum('result', ['pass', 'fail', 'conditional']) - ->nullable() - ->after('completed_at'); - - $table->text('notes') - ->nullable() - ->after('result'); - }); - } - - public function down(): void - { - Schema::table('inspections', function (Blueprint $table) { - $table->dropForeign(['inspector_user_id']); - $table->dropColumn(['status', 'inspector_user_id', 'completed_at', 'result', 'notes']); - }); - } -}; diff --git a/database/migrations/2026_06_16_000003_add_dates_to_phases.php b/database/migrations/2026_06_16_000003_add_dates_to_phases.php deleted file mode 100644 index 6b13466..0000000 --- a/database/migrations/2026_06_16_000003_add_dates_to_phases.php +++ /dev/null @@ -1,25 +0,0 @@ -date('planned_start')->nullable()->after('progress_percent'); - $table->date('planned_end')->nullable()->after('planned_start'); - $table->date('actual_start')->nullable()->after('planned_end'); - $table->date('actual_end')->nullable()->after('actual_start'); - }); - } - - public function down(): void - { - Schema::table('phases', function (Blueprint $table) { - $table->dropColumn(['planned_start', 'planned_end', 'actual_start', 'actual_end']); - }); - } -}; diff --git a/database/migrations/2026_06_16_000004_add_soft_deletes.php b/database/migrations/2026_06_16_000004_add_soft_deletes.php deleted file mode 100644 index e61fe08..0000000 --- a/database/migrations/2026_06_16_000004_add_soft_deletes.php +++ /dev/null @@ -1,34 +0,0 @@ -softDeletes(); - }); - } - } - } - - public function down(): void - { - $tables = ['projects', 'phases', 'layers', 'features', 'inspections']; - - foreach ($tables as $table) { - if (Schema::hasColumn($table, 'deleted_at')) { - Schema::table($table, function (Blueprint $t) { - $t->dropSoftDeletes(); - }); - } - } - } -}; diff --git a/database/migrations/2026_06_16_000005_create_issues_table.php b/database/migrations/2026_06_16_000005_create_issues_table.php index 6f63f08..d254834 100644 --- a/database/migrations/2026_06_16_000005_create_issues_table.php +++ b/database/migrations/2026_06_16_000005_create_issues_table.php @@ -10,6 +10,7 @@ return new class extends Migration { Schema::create('issues', function (Blueprint $table) { $table->id(); + $table->uuid('uuid')->nullable()->unique(); $table->foreignId('project_id') ->constrained('projects') @@ -34,6 +35,8 @@ return new class extends Migration $table->enum('priority', ['low', 'medium', 'high', 'critical']) ->default('medium'); + $table->string('type', 30)->default('other'); + $table->foreignId('reported_by') ->constrained('users'); @@ -44,6 +47,7 @@ return new class extends Migration $table->timestamp('resolved_at')->nullable(); $table->text('resolution_notes')->nullable(); + $table->timestamp('client_updated_at')->nullable(); $table->timestamps(); $table->softDeletes(); diff --git a/database/migrations/2026_06_16_113943_add_notes_to_users_table.php b/database/migrations/2026_06_16_113943_add_notes_to_users_table.php deleted file mode 100644 index 398d1d9..0000000 --- a/database/migrations/2026_06_16_113943_add_notes_to_users_table.php +++ /dev/null @@ -1,25 +0,0 @@ -text('notes')->nullable()->after('address'); - }); - } - - public function down(): void - { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('notes'); - }); - } -}; diff --git a/database/migrations/2026_06_16_121135_add_reference_and_country_to_projects_table.php b/database/migrations/2026_06_16_121135_add_reference_and_country_to_projects_table.php deleted file mode 100644 index 2e3a7fe..0000000 --- a/database/migrations/2026_06_16_121135_add_reference_and_country_to_projects_table.php +++ /dev/null @@ -1,25 +0,0 @@ -char('country', 2)->nullable()->after('address'); - }); - } - - public function down(): void - { - Schema::table('projects', function (Blueprint $table) { - $table->dropColumn('country'); - }); - } -}; diff --git a/database/migrations/2026_06_16_150140_change_locale_default_in_users_table.php b/database/migrations/2026_06_16_150140_change_locale_default_in_users_table.php deleted file mode 100644 index 60fdd0b..0000000 --- a/database/migrations/2026_06_16_150140_change_locale_default_in_users_table.php +++ /dev/null @@ -1,29 +0,0 @@ -string('locale', 5)->default('es')->change(); - }); - - // Reset all users still on the old default so they load in Spanish. - // Users that explicitly chose 'en' keep their preference. - DB::table('users')->where('locale', 'en')->update(['locale' => 'es']); - } - - public function down(): void - { - DB::table('users')->where('locale', 'es')->update(['locale' => 'en']); - - Schema::table('users', function (Blueprint $table) { - $table->string('locale', 5)->default('en')->change(); - }); - } -}; diff --git a/database/migrations/2026_06_17_170000_add_description_to_roles_table.php b/database/migrations/2026_06_17_170000_add_description_to_roles_table.php deleted file mode 100644 index bfdcf51..0000000 --- a/database/migrations/2026_06_17_170000_add_description_to_roles_table.php +++ /dev/null @@ -1,30 +0,0 @@ -getTable(), 'description')) { - $table->string('description')->nullable()->after('name'); - } - }); - } - - public function down(): void - { - $table = config('permission.table_names.roles', 'roles'); - - Schema::table($table, function (Blueprint $table) { - if (Schema::hasColumn($table->getTable(), 'description')) { - $table->dropColumn('description'); - } - }); - } -}; diff --git a/database/migrations/2026_06_17_180000_add_group_and_description_to_permissions_table.php b/database/migrations/2026_06_17_180000_add_group_and_description_to_permissions_table.php deleted file mode 100644 index 34950f9..0000000 --- a/database/migrations/2026_06_17_180000_add_group_and_description_to_permissions_table.php +++ /dev/null @@ -1,35 +0,0 @@ -getTable(), 'group')) { - $table->string('group')->nullable()->after('name'); - } - if (! Schema::hasColumn($table->getTable(), 'description')) { - $table->string('description')->nullable()->after('group'); - } - }); - } - - public function down(): void - { - $table = config('permission.table_names.permissions', 'permissions'); - - Schema::table($table, function (Blueprint $table) { - foreach (['group', 'description'] as $col) { - if (Schema::hasColumn($table->getTable(), $col)) { - $table->dropColumn($col); - } - } - }); - } -}; diff --git a/database/migrations/2026_06_18_070100_add_sync_fields_to_progress_updates_table.php b/database/migrations/2026_06_18_070100_add_sync_fields_to_progress_updates_table.php deleted file mode 100644 index 9b1d714..0000000 --- a/database/migrations/2026_06_18_070100_add_sync_fields_to_progress_updates_table.php +++ /dev/null @@ -1,31 +0,0 @@ -uuid('uuid')->nullable()->unique()->after('id'); - } - if (! Schema::hasColumn('progress_updates', 'client_updated_at')) { - $table->timestamp('client_updated_at')->nullable()->after('location'); - } - }); - } - - public function down(): void - { - Schema::table('progress_updates', function (Blueprint $table) { - foreach (['uuid', 'client_updated_at'] as $col) { - if (Schema::hasColumn('progress_updates', $col)) { - $table->dropColumn($col); - } - } - }); - } -}; diff --git a/database/migrations/2026_06_18_070200_add_reference_to_projects_table.php b/database/migrations/2026_06_18_070200_add_reference_to_projects_table.php deleted file mode 100644 index 4bba0d6..0000000 --- a/database/migrations/2026_06_18_070200_add_reference_to_projects_table.php +++ /dev/null @@ -1,37 +0,0 @@ -string('reference')->nullable()->after('id'); - } - if (! Schema::hasColumn('projects', 'external_reference_1')) { - $table->string('external_reference_1')->nullable()->after('reference'); - } - }); - } - - public function down(): void - { - Schema::table('projects', function (Blueprint $table) { - foreach (['reference', 'external_reference_1'] as $col) { - if (Schema::hasColumn('projects', $col)) { - $table->dropColumn($col); - } - } - }); - } -}; diff --git a/database/migrations/2026_06_18_073000_add_sync_fields_to_syncable_tables.php b/database/migrations/2026_06_18_073000_add_sync_fields_to_syncable_tables.php deleted file mode 100644 index 2ca0fef..0000000 --- a/database/migrations/2026_06_18_073000_add_sync_fields_to_syncable_tables.php +++ /dev/null @@ -1,37 +0,0 @@ -tables as $name) { - Schema::table($name, function (Blueprint $table) use ($name) { - if (! Schema::hasColumn($name, 'uuid')) { - $table->uuid('uuid')->nullable()->unique()->after('id'); - } - if (! Schema::hasColumn($name, 'client_updated_at')) { - $table->timestamp('client_updated_at')->nullable(); - } - }); - } - } - - public function down(): void - { - foreach ($this->tables as $name) { - Schema::table($name, function (Blueprint $table) use ($name) { - foreach (['uuid', 'client_updated_at'] as $col) { - if (Schema::hasColumn($name, $col)) { - $table->dropColumn($col); - } - } - }); - } - } -}; diff --git a/database/migrations/2026_06_18_080000_add_sync_fields_to_media_table.php b/database/migrations/2026_06_18_080000_add_sync_fields_to_media_table.php deleted file mode 100644 index 3dc22f7..0000000 --- a/database/migrations/2026_06_18_080000_add_sync_fields_to_media_table.php +++ /dev/null @@ -1,31 +0,0 @@ -uuid('uuid')->nullable()->unique()->after('id'); - } - if (! Schema::hasColumn('media', 'client_updated_at')) { - $table->timestamp('client_updated_at')->nullable(); - } - }); - } - - public function down(): void - { - Schema::table('media', function (Blueprint $table) { - foreach (['uuid', 'client_updated_at'] as $col) { - if (Schema::hasColumn('media', $col)) { - $table->dropColumn($col); - } - } - }); - } -}; diff --git a/database/migrations/2026_06_18_120000_create_issue_tasks_table.php b/database/migrations/2026_06_18_120000_create_issue_tasks_table.php index 4aa50cc..cf496f9 100644 --- a/database/migrations/2026_06_18_120000_create_issue_tasks_table.php +++ b/database/migrations/2026_06_18_120000_create_issue_tasks_table.php @@ -17,6 +17,7 @@ return new class extends Migration $table->foreignId('done_by')->nullable()->constrained('users')->nullOnDelete(); $table->foreignId('assigned_to')->nullable()->constrained('users')->nullOnDelete(); $table->date('due_date')->nullable(); + $table->timestamp('overdue_notified_at')->nullable(); $table->integer('order')->default(0); // Offline sync diff --git a/database/migrations/2026_06_18_130100_add_overdue_notified_at_to_issue_tasks_table.php b/database/migrations/2026_06_18_130100_add_overdue_notified_at_to_issue_tasks_table.php deleted file mode 100644 index 94f7036..0000000 --- a/database/migrations/2026_06_18_130100_add_overdue_notified_at_to_issue_tasks_table.php +++ /dev/null @@ -1,22 +0,0 @@ -timestamp('overdue_notified_at')->nullable()->after('due_date'); - }); - } - - public function down(): void - { - Schema::table('issue_tasks', function (Blueprint $table) { - $table->dropColumn('overdue_notified_at'); - }); - } -}; diff --git a/database/migrations/2026_06_18_140000_add_type_to_issues_table.php b/database/migrations/2026_06_18_140000_add_type_to_issues_table.php deleted file mode 100644 index 695a2cb..0000000 --- a/database/migrations/2026_06_18_140000_add_type_to_issues_table.php +++ /dev/null @@ -1,22 +0,0 @@ -string('type', 30)->default('other')->after('priority'); - }); - } - - public function down(): void - { - Schema::table('issues', function (Blueprint $table) { - $table->dropColumn('type'); - }); - } -}; diff --git a/database/schema/mysql-schema.sql b/database/schema/mysql-schema.sql deleted file mode 100644 index be317e3..0000000 --- a/database/schema/mysql-schema.sql +++ /dev/null @@ -1,419 +0,0 @@ -/*M!999999\- enable the sandbox mode */ -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -DROP TABLE IF EXISTS `cache`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `cache` ( - `key` varchar(255) NOT NULL, - `value` mediumtext NOT NULL, - `expiration` int(11) NOT NULL, - PRIMARY KEY (`key`), - KEY `cache_expiration_index` (`expiration`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `cache_locks`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `cache_locks` ( - `key` varchar(255) NOT NULL, - `owner` varchar(255) NOT NULL, - `expiration` int(11) NOT NULL, - PRIMARY KEY (`key`), - KEY `cache_locks_expiration_index` (`expiration`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `failed_jobs`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `failed_jobs` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `uuid` varchar(255) NOT NULL, - `connection` text NOT NULL, - `queue` text NOT NULL, - `payload` longtext NOT NULL, - `exception` longtext NOT NULL, - `failed_at` timestamp NOT NULL DEFAULT current_timestamp(), - PRIMARY KEY (`id`), - UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `features`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `features` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `layer_id` bigint(20) unsigned NOT NULL, - `name` varchar(255) DEFAULT NULL, - `geometry` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`geometry`)), - `properties` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`properties`)), - `template_id` bigint(20) unsigned DEFAULT NULL, - `progress` int(11) NOT NULL DEFAULT 0, - `responsible` varchar(255) DEFAULT NULL, - `created_at` timestamp NULL DEFAULT NULL, - `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `features_layer_id_foreign` (`layer_id`), - KEY `features_template_id_foreign` (`template_id`), - CONSTRAINT `features_layer_id_foreign` FOREIGN KEY (`layer_id`) REFERENCES `layers` (`id`) ON DELETE CASCADE, - CONSTRAINT `features_template_id_foreign` FOREIGN KEY (`template_id`) REFERENCES `inspection_templates` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `inspection_templates`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `inspection_templates` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `description` text DEFAULT NULL, - `project_id` bigint(20) unsigned DEFAULT NULL, - `fields` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`fields`)), - `created_at` timestamp NULL DEFAULT NULL, - `updated_at` timestamp NULL DEFAULT NULL, - `phase_id` bigint(20) unsigned DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `inspection_templates_project_id_foreign` (`project_id`), - KEY `inspection_templates_phase_id_index` (`phase_id`), - CONSTRAINT `inspection_templates_phase_id_foreign` FOREIGN KEY (`phase_id`) REFERENCES `phases` (`id`) ON DELETE SET NULL, - CONSTRAINT `inspection_templates_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `inspections`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `inspections` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `project_id` bigint(20) unsigned NOT NULL, - `layer_id` bigint(20) unsigned NOT NULL, - `template_id` bigint(20) unsigned DEFAULT NULL, - `user_id` bigint(20) unsigned NOT NULL, - `data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`data`)), - `created_at` timestamp NULL DEFAULT NULL, - `updated_at` timestamp NULL DEFAULT NULL, - `feature_id` bigint(20) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `inspections_project_id_foreign` (`project_id`), - KEY `inspections_layer_id_foreign` (`layer_id`), - KEY `inspections_template_id_foreign` (`template_id`), - KEY `inspections_user_id_foreign` (`user_id`), - KEY `inspections_feature_id_foreign` (`feature_id`), - CONSTRAINT `inspections_feature_id_foreign` FOREIGN KEY (`feature_id`) REFERENCES `features` (`id`) ON DELETE CASCADE, - CONSTRAINT `inspections_layer_id_foreign` FOREIGN KEY (`layer_id`) REFERENCES `layers` (`id`) ON DELETE CASCADE, - CONSTRAINT `inspections_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE, - CONSTRAINT `inspections_template_id_foreign` FOREIGN KEY (`template_id`) REFERENCES `inspection_templates` (`id`) ON DELETE SET NULL, - CONSTRAINT `inspections_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `job_batches`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `job_batches` ( - `id` varchar(255) NOT NULL, - `name` varchar(255) NOT NULL, - `total_jobs` int(11) NOT NULL, - `pending_jobs` int(11) NOT NULL, - `failed_jobs` int(11) NOT NULL, - `failed_job_ids` longtext NOT NULL, - `options` mediumtext DEFAULT NULL, - `cancelled_at` int(11) DEFAULT NULL, - `created_at` int(11) NOT NULL, - `finished_at` int(11) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `jobs`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `jobs` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `queue` varchar(255) NOT NULL, - `payload` longtext NOT NULL, - `attempts` tinyint(3) unsigned NOT NULL, - `reserved_at` int(10) unsigned DEFAULT NULL, - `available_at` int(10) unsigned NOT NULL, - `created_at` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `jobs_queue_index` (`queue`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `layers`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `layers` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `project_id` bigint(20) unsigned NOT NULL, - `phase_id` bigint(20) unsigned DEFAULT NULL, - `name` varchar(255) NOT NULL, - `color` varchar(7) NOT NULL DEFAULT '#3b82f6', - `original_file` varchar(255) DEFAULT NULL, - `uploaded_by` bigint(20) unsigned NOT NULL, - `created_at` timestamp NULL DEFAULT NULL, - `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `layers_project_id_foreign` (`project_id`), - KEY `layers_phase_id_foreign` (`phase_id`), - KEY `layers_uploaded_by_foreign` (`uploaded_by`), - CONSTRAINT `layers_phase_id_foreign` FOREIGN KEY (`phase_id`) REFERENCES `phases` (`id`) ON DELETE SET NULL, - CONSTRAINT `layers_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE, - CONSTRAINT `layers_uploaded_by_foreign` FOREIGN KEY (`uploaded_by`) REFERENCES `users` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `media`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `media` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `mediable_type` varchar(255) NOT NULL, - `mediable_id` bigint(20) unsigned NOT NULL, - `name` varchar(255) NOT NULL, - `file_path` varchar(255) NOT NULL, - `file_type` varchar(255) NOT NULL, - `file_extension` varchar(10) NOT NULL, - `file_size` int(10) unsigned NOT NULL, - `category` enum('image','document','other') NOT NULL DEFAULT 'image', - `description` text DEFAULT NULL, - `metadata` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`metadata`)), - `uploaded_by` bigint(20) unsigned NOT NULL, - `created_at` timestamp NULL DEFAULT NULL, - `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `media_mediable_type_mediable_id_index` (`mediable_type`,`mediable_id`), - KEY `media_uploaded_by_foreign` (`uploaded_by`), - CONSTRAINT `media_uploaded_by_foreign` FOREIGN KEY (`uploaded_by`) REFERENCES `users` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `migrations`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `migrations` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `migration` varchar(255) NOT NULL, - `batch` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `model_has_permissions`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `model_has_permissions` ( - `permission_id` bigint(20) unsigned NOT NULL, - `model_type` varchar(255) NOT NULL, - `model_id` bigint(20) unsigned NOT NULL, - PRIMARY KEY (`permission_id`,`model_id`,`model_type`), - KEY `model_has_permissions_model_id_model_type_index` (`model_id`,`model_type`), - CONSTRAINT `model_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `model_has_roles`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `model_has_roles` ( - `role_id` bigint(20) unsigned NOT NULL, - `model_type` varchar(255) NOT NULL, - `model_id` bigint(20) unsigned NOT NULL, - PRIMARY KEY (`role_id`,`model_id`,`model_type`), - KEY `model_has_roles_model_id_model_type_index` (`model_id`,`model_type`), - CONSTRAINT `model_has_roles_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `password_reset_tokens`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `password_reset_tokens` ( - `email` varchar(255) NOT NULL, - `token` varchar(255) NOT NULL, - `created_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`email`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `pending_syncs`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `pending_syncs` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `user_id` bigint(20) unsigned NOT NULL, - `action` varchar(255) NOT NULL, - `payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`payload`)), - `synced_at` timestamp NULL DEFAULT NULL, - `created_at` timestamp NULL DEFAULT NULL, - `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `pending_syncs_user_id_foreign` (`user_id`), - CONSTRAINT `pending_syncs_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `permissions`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `permissions` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `guard_name` varchar(255) NOT NULL, - `created_at` timestamp NULL DEFAULT NULL, - `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `permissions_name_guard_name_unique` (`name`,`guard_name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `phases`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `phases` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `project_id` bigint(20) unsigned NOT NULL, - `name` varchar(255) NOT NULL, - `description` text DEFAULT NULL, - `order` int(11) NOT NULL DEFAULT 0, - `color` varchar(7) NOT NULL DEFAULT '#3b82f6', - `progress_percent` int(11) NOT NULL DEFAULT 0, - `created_at` timestamp NULL DEFAULT NULL, - `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `phases_project_id_foreign` (`project_id`), - CONSTRAINT `phases_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `progress_updates`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `progress_updates` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `phase_id` bigint(20) unsigned NOT NULL, - `user_id` bigint(20) unsigned NOT NULL, - `progress_percent` int(11) NOT NULL, - `comment` text DEFAULT NULL, - `location` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`location`)), - `created_at` timestamp NULL DEFAULT NULL, - `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `progress_updates_phase_id_foreign` (`phase_id`), - KEY `progress_updates_user_id_foreign` (`user_id`), - CONSTRAINT `progress_updates_phase_id_foreign` FOREIGN KEY (`phase_id`) REFERENCES `phases` (`id`) ON DELETE CASCADE, - CONSTRAINT `progress_updates_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `project_user`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `project_user` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `project_id` bigint(20) unsigned NOT NULL, - `user_id` bigint(20) unsigned NOT NULL, - `role_in_project` varchar(255) NOT NULL, - `created_at` timestamp NULL DEFAULT NULL, - `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `project_user_project_id_foreign` (`project_id`), - KEY `project_user_user_id_foreign` (`user_id`), - CONSTRAINT `project_user_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE, - CONSTRAINT `project_user_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `projects`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `projects` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `address` text NOT NULL, - `lat` decimal(10,8) NOT NULL, - `lng` decimal(11,8) NOT NULL, - `start_date` date NOT NULL, - `end_date_estimated` date DEFAULT NULL, - `status` enum('planning','in_progress','paused','completed') NOT NULL DEFAULT 'planning', - `created_by` bigint(20) unsigned NOT NULL, - `created_at` timestamp NULL DEFAULT NULL, - `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `projects_created_by_foreign` (`created_by`), - CONSTRAINT `projects_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `role_has_permissions`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `role_has_permissions` ( - `permission_id` bigint(20) unsigned NOT NULL, - `role_id` bigint(20) unsigned NOT NULL, - PRIMARY KEY (`permission_id`,`role_id`), - KEY `role_has_permissions_role_id_foreign` (`role_id`), - CONSTRAINT `role_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE, - CONSTRAINT `role_has_permissions_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `roles`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `roles` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `guard_name` varchar(255) NOT NULL, - `created_at` timestamp NULL DEFAULT NULL, - `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `roles_name_guard_name_unique` (`name`,`guard_name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `sessions`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `sessions` ( - `id` varchar(255) NOT NULL, - `user_id` bigint(20) unsigned DEFAULT NULL, - `ip_address` varchar(45) DEFAULT NULL, - `user_agent` text DEFAULT NULL, - `payload` longtext NOT NULL, - `last_activity` int(11) NOT NULL, - PRIMARY KEY (`id`), - KEY `sessions_user_id_index` (`user_id`), - KEY `sessions_last_activity_index` (`last_activity`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `users`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8mb4 */; -CREATE TABLE `users` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `email` varchar(255) NOT NULL, - `email_verified_at` timestamp NULL DEFAULT NULL, - `password` varchar(255) NOT NULL, - `remember_token` varchar(100) DEFAULT NULL, - `locale` varchar(5) NOT NULL DEFAULT 'en', - `created_at` timestamp NULL DEFAULT NULL, - `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `users_email_unique` (`email`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - -/*M!999999\- enable the sandbox mode */ -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (1,'0001_01_01_000000_create_users_table',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (2,'0001_01_01_000001_create_cache_table',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (3,'0001_01_01_000002_create_jobs_table',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (4,'2026_04_27_095918_create_projects_table',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (5,'2026_04_27_095919_create_phases_table',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (6,'2026_04_27_095920_create_layers_table',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (7,'2026_04_27_095921_create_progress_updates_table',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (8,'2026_04_27_095925_create_pending_syncs_table',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (9,'2026_04_27_095925_create_project_user_table',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (10,'2026_04_27_095926_create_permission_tables',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (11,'2026_04_28_090208_create_inspection_templates_table',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (12,'2026_04_28_090218_create_inspections_table',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (13,'2026_05_06_122423_create_features_table',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (14,'2026_05_06_122711_update_inspections_feature_id_foreign',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (15,'2026_05_06_125429_drop_geojson_data_from_layers',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (16,'2026_05_06_172557_add_color_to_layers_table',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (17,'2026_05_09_210000_create_media_table',2); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (18,'2026_05_09_220000_add_locale_to_users_table',3); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (19,'2026_05_11_115552_add_phase_id_to_inspection_templates',4);