Laravel Firebase Studio Neon connection error: `relation 'sessions' does not exist`
I'm using Firebase Studio laravel template and trying to connect to Neon. I added the Parameters Only connection snippet to my
.env
and the following to config/database.php
:
I run it and got this error: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "sessions" does not exist LINE 1: select * from "sessions" where "id" = $1 limit 1 ^ (Connection: neondb, SQL: select * from "sessions" where "id" = rp69Vabcd1234tKkHyLgW2h7f5eVt1mZYhcTk limit 1)
I read Neon's documentation about it on here and here and found that I had to do some workarounds. But, I am a complete newbie in web development and databases. I think the answer is there but I don't understand it. What should I do? Thank you in advance.
Edit: Just now I tried php artisan migrate
and in my neondb I can see there is now amigrations
table, which means the connection was a success. But there's no users
, job_batches
, and other default tables from laravel. I also got this error: SQLSTATE[25P02]: In failed sql transaction: 7 ERROR: current transaction is aborted, commands ignored until end of transaction block (Connection: neondb, SQL: alter table "users" add constraint "users_email_unique" unique ("email"))
.Neon
Connection errors - Neon Docs
This topic describes how to resolve connection errors you may encounter when using Neon. The errors covered include The endpoint ID is not specified Password authentication failed for user Couldn't co...
Neon
About Connection pooling - Neon Docs
Neon uses PgBouncer to support connection pooling, enabling up to 10,000 concurrent connections. PgBouncer is a lightweight connection pooler for Postgres. How to use connection pooling. To use connec...
5 Replies
complex-teal•3w ago
You're connected to the database, so that's not the issue. Looks like you're trying to query against a 'session` table that doesn't exist. Have you run the migration to add the session table, given you're using your DB as the session driver?
If not, this documentation should help you :
https://laravel.com/docs/12.x/session#database
HTTP Session - Laravel 12.x - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
automatic-azureOP•3w ago
Thank you Sam for the quick answer. Yes, I hadn't run the default migrations. I ran it just now and I've edited the post to add yet another error I've encountered. Next up I'll try changing the session driver config.
complex-teal•3w ago
Sounds like you're missing the other 2 tables that the initial migration file creates. Do you have a
0001_01_01_000000_create_users_table.php
file?
Since you don't have any data in your database, try running php artisan migrate:fresh
(Note that once you have users or data in your DB, do not run this, since it drops everything, then reruns the migration)automatic-azureOP•3w ago
Yes I have the other 2 default migration files. I haven't touched anything else from this laravel template. I ran
php artisan migrate:fresh
and encountered the same current transaction is aborted
error. The other 2 tables is still missing.complex-teal•3w ago
Try switching out connection string for the non-pooled one, and run the migration in verbose mode
php artisan migrate:fresh -v