Reputation: 43
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');
}
}
Upvotes: 1
Views: 6120
Reputation: 21
While method "body" doesn't exist, instead it try this. To know for sureI it shoud be in the DB
// Use the string() method
$table->string('body');
Upvotes: 2
Reputation:
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
Upvotes: 5