Ad
Laravel Migrations Run With No Error But Integer Field Is Not Created
I'm trying to migrate a migration file. Some integer fields triggered an error:
$table->integer('age',11)->default('0');
There were a few of those. After reading other posts, and trying a few things, I changed it to:
$table->integer('age',11)->default(0)->change();
This time, no error raised, but the created table miss and those fields!
Please find the whole file below:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateReservationAnniversairesTable extends Migration
{
public function up()
{
Schema::create('reservation_anniversaires', function (Blueprint $table) {
$table->increments('id',11);
$table->string('nom',50)->nullable()->default('NULL');
$table->string('gsm',30)->nullable()->default('NULL');
$table->string('prenom',50)->nullable()->default('NULL');
$table->string('email',100);
$table->integer('age',11)->default(0)->change();
$table->time('heure_debut');
$table->time('heure_fin');
$table->string('gateau',100)->nullable()->default('NULL');
$table->string('impression',100)->nullable()->default('NULL');
$table->integer('nbre_enfants',11)->default(0)->change();
$table->integer('acompte',11)->default(0)->change();
$table->text('remarques');
$table->tinyInteger('salle',4)->default(0)->change();
$table->time('heure_gouter');
$table->date('date');
$table->string('formule',50)->nullable()->default('NULL');
$table->integer('actif',11)->default(1)->change();
$table->string('couleur',30)->nullable()->default('NULL');
$table->integer('rappel',11)->default(0)->change();
$table->integer('confirm',11)->default(0)->change();
$table->integer('pizzas',11)->default(0)->change();
$table->integer('sandwiches',11)->default(0)->change();
$table->string('options')->nullable()->default('NULL');
$table->integer('annif_confirme',11)->default(0)->change();
$table->string('created',30);
$table->string('modified',30);
$table->tinyInteger('confirm_enfants',1)->default(0)->change();
$table->tinyInteger('invitations',1)->default(0)->change();
$table->string('adresse')->nullable()->default('NULL');
$table->integer('invitsEnvoyees',11)->default(0)->change();
$table->float('paiement')->default(0)->change();
$table->string('paiement_methode',50)->nullable()->default('NULL');
$table->integer('enfants_presents',11)->default(0)->change();
$table->integer('parts_gateau',11)->default(0)->change();
$table->float('options_montant')->default(0)->change();
$table->string('deco_salle',50)->nullable()->default('NULL');
$table->string('formule_theme',50)->nullable()->default('NULL');
$table->string('photos',50)->nullable()->default('NULL');
$table->string('grimage',50)->nullable()->default('NULL');
$table->string('clown',50)->nullable()->default('NULL');
$table->string('sculpture',50)->nullable()->default('NULL');
});
}
public function down()
{
Schema::dropIfExists('reservation_anniversaires');
}
}
Ad
Answer
You can't set length, but you can use different types of integer:
$table->bigInteger()
$table->mediumInteger()
$table->integer()
$table->smallInteger()
$table->tinyInteger()
You can check documentation as well.
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms
Ad