Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/alber1802/AvaluoVehicular/llms.txt

Use this file to discover all available pages before exploring further.

Avalúo Vehicular uses SQLite as its sole database engine in both development and production. There is no MySQL, PostgreSQL, or external database server to provision — the entire schema lives in a single file at database/database.sqlite. This design keeps the infrastructure footprint minimal: one SQLite file handles application data, sessions, cache, and background job queues simultaneously. In the Docker production environment the file is mounted as a persistent volume so it survives container restarts and re-deployments.

Setup

1

Create the SQLite file

Laravel requires the database file to exist before it can run migrations. Create it with:
touch database/database.sqlite
On Windows (PowerShell) use:
New-Item database/database.sqlite -ItemType File
2

Configure the database connection

Open your .env file and ensure the following variables are set. When DB_DATABASE is omitted, Laravel automatically resolves the path to database/database.sqlite relative to the project root:
DB_CONNECTION=sqlite
# DB_DATABASE is optional in development — Laravel resolves it automatically.
# In Docker production, set an absolute path:
# DB_DATABASE=/var/www/html/database/database.sqlite
3

Run all migrations

Apply the full migration history to create every table:
php artisan migrate
After migrations complete, AppServiceProvider automatically calls php artisan app:sync-permissions to seed the Spatie role/permission definitions.
During development, use php artisan migrate:fresh --seed to wipe the database, re-run all migrations from scratch, and execute all seeders in one step. This is the fastest way to reset to a known state when iterating on the schema.
php artisan migrate:fresh drops every table and destroys all data before rebuilding the schema. Never run it against a production database. For production schema changes, always use incremental php artisan migrate.

Migration Reference

Migrations run in the order shown below. Each file is idempotent — running php artisan migrate on an already-migrated database is safe.

Core Laravel Tables

Migration FileTables CreatedPurpose
0001_01_01_000000_create_users_table.phpusers, password_reset_tokens, sessionsAuthentication foundation: user accounts with email verification, password reset tokens, and database-backed sessions
0001_01_01_000001_create_cache_table.phpcache, cache_locksDatabase-backed cache store used when CACHE_STORE=database
0001_01_01_000002_create_jobs_table.phpjobs, job_batches, failed_jobsDatabase-backed queue driver used when QUEUE_CONNECTION=database

Vehicle Domain Tables

Migration FileTablePurpose
2024_01_01_000001_create_marca_vehiculo_table.phpmarca_vehiculoVehicle brands/makes, each storing the depreciation rate (tasa_k) and residual value used in appraisal calculations, linked to the creating user
2024_01_01_000002_create_vehiculos_table.phpvehiculosCore vehicle records: entity, evaluation date, location, type, fuel, brand, model, year, plate, engine serial, chassis, colour, origin, mileage, and reference price; soft-deleted
2024_01_01_000003_create_avaluo_table.phpavaluoThe appraisal result for each vehicle: replacement factor, final estimation, currency, and the three depreciation percentages (model, mileage, inspection); soft-deleted
2024_01_01_000004_create_condicion_general_table.phpcondicion_generalGeneral condition assessment per vehicle: operational state, overall state, and observations; soft-deleted
2024_01_01_000005_create_sistemas_table.phpsistemasVehicle system components (engine, transmission, etc.) with per-component JSON state, valuation, and observations; soft-deleted
2024_01_01_000007_create_inspeccion_table.phpinspeccionIndividual inspection line items per vehicle: feature name, characteristic, presence flag, valuation weight, and observations; soft-deleted
2024_01_01_000011_create_archivos_table.phparchivosAttached documents per vehicle (PDFs, spreadsheets, etc.) with file type, URL, comment, and date; soft-deleted
2024_01_01_000012_create_vehiculo_imagen_table.phpvehiculo_imagenVehicle photographs keyed by side (front, rear, left, right), with URL, description, and date; soft-deleted

Feature & Permission Tables

Migration FileTablePurpose
2025_08_26_100418_add_two_factor_columns_to_users_table.phpusers (altered)Adds two_factor_secret, two_factor_recovery_codes, and two_factor_confirmed_at columns to support Laravel Fortify 2FA
2026_01_02_115331_create_avaluo_compartidos_table.phpavaluo_compartidoShared appraisal links: token, validity window (fecha_inicio/fecha_fin), status (activo, vencido, renovado), view counter, and reason for sharing; soft-deleted
2026_01_14_103816_create_permission_tables.phppermissions, roles, model_has_permissions, model_has_roles, role_has_permissionsSpatie Laravel Permission tables for role-based access control (RBAC)

Inspection Section Templates

These tables store reusable section definitions that are loaded when initialising a new appraisal:
Migration FileTablePurpose
2026_03_23_135348_create_seccion_fallas_table.phpseccion_fallasTemplate fault-section entries: component title, component name, and depreciation valuation weight
2026_03_23_135348_create_seccion_tecnicas_table.phpseccion_tecnicasTemplate technical-section entries: component with a JSON opciones array mapping rating labels (e.g. “Bueno”, “Requiere cambio”) to numeric values
2026_03_23_135349_create_accesorios_table.phpaccesoriosPer-vehicle accessory records with applicability flag, condition state (bueno, aceptable, dañado), and observations; soft-deleted
2026_03_23_135349_create_seccion_accesorios_table.phpseccion_accesoriosTemplate accessory-section entries: component name and default state; state field later changed to JSON by a follow-up migration
2026_06_21_192538_change_estado_to_json_in_seccion_accesorios_table.phpseccion_accesorios (altered)Changes the estado column from string to json, allowing multiple state values to be stored per accessory template entry

Artisan Database Commands

# Apply all pending migrations
php artisan migrate

# Roll back the most recent batch of migrations
php artisan migrate:rollback

# Roll back all migrations, then re-run from scratch (preserves data)
php artisan migrate:refresh

# Drop all tables and re-run every migration (destroys all data)
php artisan migrate:fresh

# Drop all tables, re-run every migration, then run all seeders
php artisan migrate:fresh --seed

# Show the status of every migration (ran / pending)
php artisan migrate:status

Docker Persistence

In the Docker production environment, the SQLite file is exposed outside the container via a bind mount or named volume so that data is not lost when the container is rebuilt or restarted. A typical docker-compose.yml fragment looks like:
services:
  app:
    image: avaluo-vehicular:latest
    volumes:
      - ./database/database.sqlite:/var/www/html/database/database.sqlite
    environment:
      DB_CONNECTION: sqlite
      DB_DATABASE: /var/www/html/database/database.sqlite
The absolute path /var/www/html/database/database.sqlite must match the DB_DATABASE value in .env.docker. Create an empty file on the host before the first docker compose up:
touch database/database.sqlite
docker compose up -d
docker compose exec app php artisan migrate

Build docs developers (and LLMs) love