title: Laravel create table if doesn't exist on production environment
body: <p>I need to use a database to store my sessions with Laravel 4, when the environment is set to production. When it's local the standard file drive system can be used.</p>
  
  <p>I do not have access to the command line, so I'm unable to run any migrations, artisan commands (CloudFoundry setup). So my idea is that in my <code>app/start/global.php</code> file I'd add a check:</p>
  
  <pre><code>if (App::environment('production'))
  {
      if(! Schema::hasTable( Config::get('session.table') )) {
  
          Schema::create( Config::get('session.table'), function($table)
          {
              $table-&gt;string('id')-&gt;unique();
              $table-&gt;text('payload');
              $table-&gt;integer('last_activity');
          });
  
      }
  }
  </code></pre>
  
  <p>If it's currently in production mode (this bit works), then check if there is a table with the name defined in my <code>app/config/session.php</code> file. If not, then create this table with that given name. I noticed the <code>hasTable</code> from the api (<a href="http://laravel.com/api/4.1/Illuminate/Database/Schema/Builder.html#method_hasTable" rel="nofollow">http://laravel.com/api/4.1/Illuminate/Database/Schema/Builder.html#method_hasTable</a>).</p>
  
  <p>However, when my app loads, I get the error:</p>
  
  <p><code>RuntimeException: PDOException was thrown when trying to read the session data: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'table_name.sessions' doesn't exist</code></p>
  
  <p>Is this because of the lifecycle of the app? How else could I do this...</p>