Laravel Migrate to AWS RDS using Lambda

474 Views Asked by At

I am looking to deploy a Laravel app on AWS Lambda. The app requires a PostgreSQL database access.

The idea is am using Bref to deploy on AWS Lambda. I created a RDS PostgreSQL database manually and updated the inbound rule and added the connection parameter to the .env file and serverless.yml template in the app.

After deploying the app I am receiving error SQLSTATE[42P01]: Undefined table. I belive the problem is that no migration occurred. So the question is how to migrate from Laravel/Lambda to RDS? Shall I use the artisan and the CLI? Or there is a way to create an automated way to migrate?

Thanks

1

There are 1 best solutions below

0
On

When you don't make a custom setting for Postgresql, by default the sql queries should be like this

SELECT * FROM database_name.table_name 

There are two options or you should specify the table names in all your laravel model files as below

protected $table = 'database_name.table';

or you should connect to rds postgresql via terminal and set the following

SET search_path TO database_name,public;

postgresql schemas