Posted in

Migraciones en Laravel 4.2

Crear tabla migrations

php artisan migrate:install

Crear archivo migration con dos columnas por defecto

php artisan migrate:make create_table_users --create "users"

Ejemplo del tipo de contenido del archivo migration que podemos añadir según el tipo de campo:

$table->increments('id');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->string('email')->unique();
$table->string('password', 60);
$table->enum('type', ['admin', 'user']);
$table->boolean('active')->default(false);
$table->date('date');
$table->text('info');
table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->timestamp('updated_at');

Deixa un comentari

L'adreça electrònica no es publicarà. Els camps necessaris estan marcats amb *


The reCAPTCHA verification period has expired. Please reload the page.