title: Laravel 5.5 Migrations: cannot create foreign key
body: <p>So I have three Tables. Clients / Sites / Users. A Client Has Many Sites. A Client Has Many Users. A User / Site belongs to a Client. Pretty straight forward. Sadly we are importing the information for the Site / Client tables from someone who thought it would be a good idea to use string keys.</p>
  <p>Here are my migrations -</p>
  <p>This is the clients table:</p>
  <pre><code>Schema::create('clients', function (Blueprint $table) {
      $table-&gt;string('id', 25)-&gt;primary();
      $table-&gt;char('number', 6)-&gt;unique();
      $table-&gt;string('name', 50)-&gt;unique();
      $table-&gt;timestamps();
  });
  </code></pre>
  <p>This is the sites table:</p>
  <pre><code>public function up()
  {
      Schema::create('sites', function (Blueprint $table) {
          $table-&gt;string('id', 25)-&gt;primary();
          $table-&gt;string('name', 30)-&gt;unique();
          $table-&gt;string('number', 10)-&gt;unique();
          $table-&gt;string('address_1', 60);
          $table-&gt;string('address_2', 60)-&gt;nullable();
          $table-&gt;string('city', 30);
          $table-&gt;string('state', 3);
          $table-&gt;string('postal_code', 10);
          $table-&gt;string('country', 30);
          $table-&gt;string('weather_code')-&gt;nullable();
          $table-&gt;decimal('dimension', 18, 0)-&gt;nullable();
          $table-&gt;string('dimension_uom', 10)-&gt;nullable();
          $table-&gt;string('client_id', 25);
          $table-&gt;softDeletes();            
          $table-&gt;timestamps();
  
          // Belongs To Client
          $table-&gt;foreign('client_id')-&gt;references('id')-&gt;on('clients');
      });
  }
  </code></pre>
  <p>This is the users table:</p>
  <pre><code>public function up()
  {
      Schema::create('users', function (Blueprint $table) {
          $table-&gt;increments('id');
          $table-&gt;string('name');
          $table-&gt;string('email')-&gt;unique();
          $table-&gt;string('password');
          $table-&gt;string('client_id', 25);
          $table-&gt;rememberToken();
          $table-&gt;timestamps();
  
          // Belongs To Client
          $table-&gt;foreign('client_id')-&gt;references('id')-&gt;on('clients');
      });
  }
  </code></pre>
  <p>However when I run these I get the following error:</p>
  <blockquote>
  <p>SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table <code>users</code> add constraint <code>users_client_id_foreign</code> foreign key (<code>client_id</code>) references <code>clients</code> (<code>id</code>))</p>
  <p>SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint</p>
  </blockquote>
  <p>If I remove the foreign key attempt on users but keep the one in sites it works fine. I am doing exactly the same thing in both yet for some reason it works in sites and not in users. Any idea why?</p>