If you’re moving to Laravel Cloud and want your database to support hibernation, you’ll need to migrate from MySQL to PostgreSQL.

Laravel Serverless Postgres supports automatic hibernation — meaning your database can pause when idle, and you won’t be billed for unused compute time.

In contrast, Laravel MySQL databases are always-on with fixed compute and storage sizes and do not currently support hibernation.

Migrating Your Data

To move from MySQL to Postgres, you will need to:

  • Export your MySQL database (e.g., using mysqldump).
  • Use a tool like pgloader to import the data into your Serverless Postgres database.

pgloader is specifically designed to convert MySQL databases to Postgres and handles much of the transformation automatically. Some tweaks may be needed depending on your schema, but many Laravel applications migrate cleanly with minimal effort.

If you need more guidance, our database partner, Neon, has a helpful step-by-step guide: Migrate from MySQL to Neon Postgres.

Application Implementation Considerations

Keep in mind that although Postgres is very similar to MySQL, it is generally more strict in certain field definitions and usage. Below are common considerations which may be relevant to your application.

MySQLPostgresConsiderations
Boolean ValuesStores as TINYINTStores as BOOLEANBoolean casting works in Laravel, but avoid direct 0/1 comparisons in raw queries.
Auto-Increment IDsUses AUTO_INCREMENTUses SERIALLaravel handles this with $table->id() or increments(), but raw SQL may need to be adjusted.
Unsigned IntegersSupports unsignedInteger and unsignedBigIntegerMust use signed bigInteger / foreignId()Although Laravel will silently handle conversions in your migration files, executing raw imports may reference UNSIGNED BIGINT columns. You will need to cast or redefine types on import.
UUIDsStores as stringsHas native UUID supportIf you have a custom UUID definition that does not match the specification, it will fail in Postgres. Use Laravel’s Str::uuid() helper to stay compatible.
Zero DatesAllows ‘0000-00-00’Invalid DateUse nullable() and avoid “zero dates”; Postgres will throw an error.
JSON ColumnSupported, but is not validated.Validates JSON on save.Ensure the JSON you store is valid, else Postgres save will fail.
Timestamp with Timezonetimestamp does not store timezone detailSupports timestamp with and without timezoneLaravel defaults to timestamp, so you must explicitly use $table->timestampTz() if you want time zone-aware behavior.
Implicit Foreign Key IndexesForeign key columns automatically receive corresponding indexIndexes are not automatically createdExplicitly add ->index() to any foreignId() columns to ensure indexes are created.