title: Laravel tries to seed column that is not asked for
body: <p>I have a strange problem and an hour of googling and searching through stackoverflow didn't get me any closer to a solution. What happens is that when I trye to seed a table (let's call it <code>my_table</code> for security purposes) the seeder seems to try to populate columns that I never asked to be seeded.</p>
  
  <p>So, first I run <code>php artisan migrate</code> to create my table using the following migration:</p>
  
  <pre><code>&lt;?php
  
  use Illuminate\Database\Migrations\Migration;
  use Illuminate\Database\Schema\Blueprint;
  use Illuminate\Support\Facades\Schema;
  
  class CreateMyTableTable extends Migration
  {
      /**
       * Run the migrations.
       */
      public function up(): void
      {
          Schema::create('my_table', function (Blueprint $table) {
              $table-&gt;increments('id');
  
              $table-&gt;integer('user_id')-&gt;unsigned();
              $table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('user');
  
              $table-&gt;tinyInteger('from_default')-&gt;nullable(false)-&gt;default(7);
              $table-&gt;tinyInteger('to_default')-&gt;nullable(false)-&gt;default(20);
              $table-&gt;timestamps();
  
              $table-&gt;unique('user_id');
          });
      }
  
      /**
       * Reverse the migrations.
       */
      public function down(): void
      {
          Schema::dropIfExists('my_table', function (Blueprint $table) {
              $table-&gt;dropUnique(['user_id']);
              $table-&gt;dropForeign(['user_id']);
          });
      }
  }
  </code></pre>
  
  <p>This works well, and when I do <code>DESCRIBE my_table</code> I get the following:</p>
  
  <pre><code>Field           Type                Null    Key     Default     Extra
  -------------------------------------------------------------------------------
  id              int(10) unsigned    NO      PRI                 auto_increment
  user_id         int(10) unsigned    NO      UNI     
  from_default    tinyint(4)          NO              7
  to_default      tinyint(4)          NO              20
  created_at      timestamp           YES
  updated_at      timestamp           YES
  </code></pre>
  
  <p>So you can see that the table is created with the exact fields that I want in my migration file. So, now I want to seed this table using the following seed:</p>
  
  <pre><code>&lt;?php
  
  use App\DomainLogic\Models\MyTable;
  use App\DomainLogic\Models\User;
  use Faker\Factory as FakerFactory;
  use Illuminate\Database\Seeder;
  
  class MyTableTableSeeder extends Seeder
  {
      /**
       * @var array list of MyTable Users
       */
      private $myTableUsers = [];
  
      /**
       * Run the database seeds.
       */
      public function run()
      {
          $this-&gt;createMyTableUsers();
          $myTableUsers = $this-&gt;getMyTableUsers();
          foreach ($myTableUsers as $myTableUser) {
              factory(MyTable::class)-&gt;create([
                  'user_id' =&gt; $myTableUser-&gt;getKey(),
                  'from_default' =&gt; 7,
                  'to_default' =&gt; 20,
              ]);
          }
      }
  
      private function getMyTableUsers(): array
      {
          return $this-&gt;myTableUsers;
      }
  
      private function createMyTableUsers()
      {
          $faker = FakerFactory::create();
  
          // My table
          $this-&gt;myTableUsers[] = factory(User::class)-&gt;create([
              'id' =&gt; 2,
              'first_name' =&gt; 'Kalle',
              'last_name' =&gt; 'Andersson',
              'email' =&gt; 'kalle.andersson@email.com',
              'password' =&gt; bcrypt('password', ['rounds' =&gt; 4]),
              'mobile_number' =&gt; $faker-&gt;e164PhoneNumber,
          ]);
          $this-&gt;myTableUsers[] = factory(User::class)-&gt;create([
              'id' =&gt; 3,
              'first_name' =&gt; 'Johan',
              'last_name' =&gt; 'Petterson',
              'email' =&gt; 'johan.petterson@email.com',
              'password' =&gt; bcrypt('password', ['rounds' =&gt; 4]),
              'mobile_number' =&gt; $faker-&gt;e164PhoneNumber,
          ]);
          $this-&gt;myTableUsers[] = factory(User::class)-&gt;create([
              'id' =&gt; 4,
              'first_name' =&gt; 'Krister',
              'last_name' =&gt; 'Johansson',
              'email' =&gt; 'krister.johansson@email.com',
              'password' =&gt; bcrypt('password', ['rounds' =&gt; 4]),
              'mobile_number' =&gt; $faker-&gt;e164PhoneNumber,
          ]);
          $this-&gt;myTableUsers[] = factory(User::class)-&gt;create([
              'id' =&gt; 5,
              'first_name' =&gt; 'Daniel',
              'last_name' =&gt; 'Eriksson',
              'email' =&gt; 'daniel.eriksson@email.com',
              'password' =&gt; bcrypt('password', ['rounds' =&gt; 4]),
              'mobile_number' =&gt; $faker-&gt;e164PhoneNumber,
          ]);
      }
  }
  </code></pre>
  
  <p>When running <code>php artisan db:seed</code> I get this error:</p>
  
  <pre><code>In Connection.php line 664:
  
    SQLSTATE[42S22]: Column not found: 1054 Unknown column 'starts_day_default' in 'field list' (SQL: insert into `my_table` (`user_id`, `starts_day_default`, `ends_day_default`, `from_default`, `to_default`) values (2, 07, 20, 7, 20))
  
  In PDOConnection.php line 82:
  
    SQLSTATE[42S22]: Column not found: 1054 Unknown column 'starts_day_default' in 'field list'
  
  In PDOConnection.php line 80:
  
    SQLSTATE[42S22]: Column not found: 1054 Unknown column 'starts_day_default' in 'field list'
  </code></pre>
  
  <p>So the strange thing is that as far as I see, I never try to populate a column called <code>starts_day_default</code> or <code>ends_day_default</code>. Because those columns don't exist and should not exist. The actual thing is that the columns were renamed <code>starts_day_default -&gt; from_default</code> and <code>ends _day_default -&gt; to_default</code>. The users are created correctly, I can see them in the users table, so that is not the problem. Here is also my model for MyTable:</p>
  
  <pre><code>&lt;?php
  
  namespace App\DomainLogic\Models;
  
  use DateTimeImmutable;
  use Illuminate\Database\Eloquent\Collection;
  use Illuminate\Database\Eloquent\Model;
  
  class MyTable extends Model
  {
      /**
       * Indicates if the model should be timestamped.
       *
       * @var bool
       */
      public $timestamps = false;
      /**
       * The table associated with the model.
       *
       * @var string
       */
      protected $table = 'my_table';
  
      /**
       * Creates personal trainer, if personal trainer with id exists.
       *
       * @param int $myTableId
       *
       * @return null|self
       */
      public static function createFromId(int $myTableId): ?self
      {
          $myTable = self::select('my_table.*')
              -&gt;join('user', 'user.id', '=', 'my_table.user_id')
              -&gt;where('my_table.id', '=', $myTableId)
              -&gt;whereNull('user.anonymized_at')
              -&gt;get()
              -&gt;first();
  
          return $myTable;
      }
  
      /**
       * Create personal trainer, if user_id exists.
       *
       * @param int $userId
       *
       * @return null|MyTable
       */
      public static function createFromUserId(int $userId): ?self
      {
          return self::where('user_id', $userId)-&gt;get()-&gt;first();
      }
  
      /**
       * Gets all personal trainers.
       *
       * @param bool $active
       *
       * @return Collection
       */
      public static function getMyTables(bool $active = null): Collection
      {
          $query = self::select('my_table.*')
              -&gt;join('user', 'user.id', '=', 'my_table.user_id')
              -&gt;whereNull('user.anonymized_at');
  
          if (isset($active)) {
              $query-&gt;where('user.active', '=', $active);
          }
  
          $myTables = $query-&gt;get();
  
          return $myTables;
      }
  
      /**
       * Gets user.
       */
      public function getUser(): User
      {
          $user = $this-&gt;belongsTo(User::class, 'user_id', 'id')-&gt;getResults();
  
          return $user;
      }
  
      /**
       * Check if personal trainers ids are valid.
       *
       * @param array $myTableIds
       *
       * @return bool
       */
      public static function areMyTableIdsValid(array $myTableIds): bool
      {
          $dbMyTableIds = self::select('my_table.id')
              -&gt;join('user', 'user.id', '=', 'my_table.user_id')
              -&gt;whereIn('my_table.id', $myTableIds)
              -&gt;whereNull('user.anonymized_at')
              -&gt;get()
              -&gt;pluck('id')
              -&gt;toArray();
  
          $dbMyTableIds = array_map('intval', $dbMyTableIds);
          sort($myTableIds);
          sort($dbMyTableIds);
  
          $result = false;
          if ($myTableIds === $dbMyTableIds) {
              $result = true;
          }
  
          return $result;
      }
  }
  </code></pre>
  
  <p>I have tried</p>
  
  <pre><code>php artisan view:clear
  
  php artisan cache:clear
  
  php artisan debugbar:clear
  
  composer dump-autoload
  </code></pre>
  
  <p>suggested in <a href="https://stackoverflow.com/questions/48847321/unknown-column-username-in-laravel">Unknown column &#39;username&#39; in Laravel</a> but that did not help. I have dropped all tables and rerun <code>php artisan migrate</code> but that did not help either.</p>
  
  <p>I have never seen this before, so my question is, can anyone see what my problem is?</p>