I’m fairy new to Laravel. I have created a migration file named: create_notes_table and when running command php artisan migrate this error message pops up.
my create_notes_table file content
class CreateNotesTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('notes', function (Blueprint $table) { $table->increments('id'); $table->number('card_id'); $table->body('string'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('notes'); } }
Advertisement
Answer
As the error message states there is no body()
method in migrations.
https://laravel.com/docs/8.x/migrations#columns
Change your function up()
to :
public function up() { Schema::create('notes', function (Blueprint $table) { $table->increments('id'); $table->integer('card_id'); $table->string('body'); $table->timestamps(); }); }
While we’re at it, number()
also doesn’t exist, changed it to integer()
Edit: changed number
to integer