I am just starting to use the Laravel framework and its command prompt. I'm having trouble with the migration and seeding features, however.
I am developing on a WAMP server on a Windows 7 64-bit OS.
The database name is 'laravel', with the following two tables:
The users table contains the following columns:
I used the command line to generate a migration stored in app\database\migrations\2014_06_24_221654_test.php
. I also created the migration and batch fields in the migration table.
I then want to seed an email to that table, so I used DatabaseSeeder.php
in the database\seeds folder.
<?php class DatabaseSeeder extends Seeder {
public function run()
{
$this->call('UserTableSeeder');
$this->command->info('User table seeded!');
}
}
class UserTableSeeder extends Seeder {
protected $fillable = array('email');
public function run()
{
User::create(array('email' => '[email protected]'));
}
}
?>
I then used the following command to seed the database
php artisan db:seed
However, I got the following exception:
[Illuminate\Database\QueryException]
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field
list' (SQL: insert into `users` (`email`, `updated_at`, `created_at`) values (ji
[email protected], 2014-06-25 00:23:48, 2014-06-25 00:23:48))
How can I solve this? Do I need a model?
Thats because your User model use timestamps fields.
Check your User model file.
You could find something like this $this->timestamps = true
in your constructor. Change it to false
and try again. If you don't find something like this, then add this attribute to the class:
public $timestamps = false;
I hope it works fine for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With