phppostgresqlpostgresql-9.1laravel

Error when running Laravel's artisan session:table with pgSQL


I just git cloned from the Laravel repo and setup the pgSQL database details. Next I tried using artisan to create the session table.

php artisan session:table

However that gives me the following error:

X-Powered-By: PHP/5.3.16
Content-type: text/html

<br />
<b>Fatal error</b>:  Uncaught exception 'Laravel\Database\Exception' with message 'SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation &quot;sessions&quot; does not exist
LINE 1: SELECT * FROM &quot;sessions&quot; WHERE &quot;id&quot; = $1 LIMIT 1
                      ^

SQL: SELECT * FROM &quot;sessions&quot; WHERE &quot;id&quot; = ? LIMIT 1

Bindings: array (
  0 =&gt; 'i8qwmexP1joUkSLDH7naRayJDiSrLFGQa4xeubgz',
)' in /home/dev/public_html/laravel/database/connection.php:263
Stack trace:
#0 /home/dev/public_html/laravel/database/connection.php(183): Laravel\Database\Connection-&gt;execute('SELECT * FROM &quot;...', Array)
#1 /home/dev/public_html/laravel/database/query.php(648): Laravel\Database\Connection-&gt;query('SELECT * FROM &quot;...', Array)
#2 /home/dev/public_html/laravel/database/query.php(592): Laravel\Database\Query-&gt;get(Array)
#3 /home/dev/public_html/laravel/database/query.php(563): Laravel\Database\Query-&gt;first(Array)
#4 /home/dev/public_html/laravel/session/drivers/database.php(36): Laravel\Database\Query-&gt;find('i8qwmexP1joUkSL...')
#5 /home/dev/public_html/laravel/session/dri in <b>/home/dev/public_html/laravel/database/connection.php</b> on line <b>263</b><br />

When I switched the database driver to mysql I get the following message:

X-Powered-By: PHP/5.3.16
Content-type: text/html

You forgot to provide the task name.

Executing the SQL query works though, while artisan does not.

CREATE TABLE `sessions` (
     `id` VARCHAR(40) NOT NULL,
     `last_activity` INT(10) NOT NULL,
     `data` TEXT NOT NULL,
     PRIMARY KEY (`id`)
);

How should I solve this error when pgSQL driver is used? Not sure what went wrong here.


Solution

  • Try removing the single quotes from your query:

    CREATE TABLE sessions (
        id VARCHAR(40) NOT NULL,
        last_activity INT(10) NOT NULL,
        data TEXT NOT NULL,
        PRIMARY KEY (id)
    );