Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/keving5726/megacreative/llms.txt

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

Mega Creative ships eight migration files that build the complete database schema from scratch. Because the estudiantes table declares six foreign keys that point at earlier tables, the migration files must execute in a strict order — running them out of sequence will cause a foreign key constraint failure. Artisan handles this automatically by running migrations in filename-timestamp order.

Running Migrations

1

Configure your database connection

Open your .env file and confirm the MySQL connection variables are set correctly:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=megacreative
DB_USERNAME=root
DB_PASSWORD=secret
2

Run all pending migrations

From the project root, execute:
php artisan migrate
Artisan reads the migrations table (creating it on first run), identifies which files have not yet run, and executes them in ascending timestamp order. All eight tables are created in a single command.
3

Verify the result

Connect to MySQL and confirm the tables exist:
php artisan tinker
>>> \DB::select('SHOW TABLES');

Migration Files

The eight files are listed below in the exact order Artisan executes them. Dependencies between tables are noted where they exist.
#FileCreatesDepends on
12019_08_19_000000_create_failed_jobs_tablefailed_jobs — Laravel queue failure log
22019_09_09_171010_create_statuses_tablestatuses — enrollment / program status lookup
32019_09_09_171011_create_sexos_tablesexos — sex options lookup
42019_09_09_171012_create_carreras_tablecarreras — academic programsstatuses
52019_09_09_171013_create_paises_tablepaises — countries lookup
62019_09_09_171014_create_estados_tableestados — states / provinces lookup
72019_09_09_171015_create_ciudades_tableciudades — cities lookup
82019_09_09_171016_create_estudiantes_tableestudiantes — student recordssexos, carreras, statuses, paises, estados, ciudades

Rolling Back

Laravel provides several Artisan commands for rolling back or resetting the schema during development.
# Undoes the most recent batch of migrations
php artisan migrate:rollback
migrate:rollback only reverses the last batch, which may be fewer than all eight migrations if you ran them in multiple batches. Use migrate:fresh during local development when you want a guaranteed clean slate. Avoid migrate:fresh on any database that holds real data — it drops every table unconditionally.

The CreateEstudiantesTable Migration

The most complex migration is the one for estudiantes. It defines all six foreign key constraints and the unique index on email. The full up() method is reproduced below exactly as it appears in the source:
public function up()
{
    Schema::create('estudiantes', function (Blueprint $table) {
        $table->bigIncrements('id');

        // Nombres del estudiante
        $table->string('nombres', 100);

        // Apellidos del estudiante
        $table->string('apellidos', 100);

        // Sexo del estudiante
        $table->unsignedTinyInteger('sexo_id');

        // Fecha de nacimiento del estudiante
        $table->date('fecha_de_nacimiento');

        // Correo electronico del estudiante
        $table->string('email', 100);

        // Carrera que cursa del estudiante
        $table->unsignedTinyInteger('carrera_id');

        // Disponibilidad del estudiante
        $table->unsignedTinyInteger('status_id');

        // Pais donde vive el estudiante
        $table->unsignedTinyInteger('pais_id');

        // Estado donde vive el estudiante
        $table->unsignedTinyInteger('estado_id');

        // Ciudad donde vive el estudiante
        $table->unsignedTinyInteger('ciudad_id');

        $table->timestamps();
        $table->unique('email');
        $table->foreign('sexo_id')->references('id')->on('sexos');
        $table->foreign('carrera_id')->references('id')->on('carreras')->onDelete('cascade');
        $table->foreign('status_id')->references('id')->on('statuses');
        $table->foreign('pais_id')->references('id')->on('paises');
        $table->foreign('estado_id')->references('id')->on('estados');
        $table->foreign('ciudad_id')->references('id')->on('ciudades');
    });
}
Notice that carrera_id is the only foreign key declared with ->onDelete('cascade'). All other foreign keys use MySQL’s default behaviour (RESTRICT), which prevents deletion of a referenced row while child rows exist.

Build docs developers (and LLMs) love