Migrating your data
To move from MySQL to Postgres, you need to:- Export your MySQL database (for example, using
mysqldump). - Use a tool like pgloader to import the data into your Serverless Postgres database.
Application implementation considerations
Keep in mind that although Postgres is very similar to MySQL, it is generally stricter in certain field definitions and usage. The following table lists common considerations that may be relevant to your application.| MySQL | Postgres | Considerations | |
|---|---|---|---|
| Boolean values | Stores as TINYINT | Stores as BOOLEAN | Boolean casting works in Laravel, but avoid direct 0 or 1 comparisons in raw queries. |
| Auto-increment IDs | Uses AUTO_INCREMENT | Uses SERIAL | Laravel handles this with $table->id() or increments(), but you may need to adjust raw SQL. |
| Unsigned integers | Supports unsignedInteger and unsignedBigInteger | Must use signed bigInteger or foreignId() | Laravel handles conversions in your migration files, but raw imports may reference UNSIGNED BIGINT columns. You will need to cast or redefine types on import. |
| UUIDs | Stores as strings | Has native UUID support | If 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 dates | Allows ‘0000-00-00’ | Invalid date | Use nullable() and avoid “zero dates.” Postgres throws an error on them. |
| JSON column | Supported, but is not validated. | Validates JSON on save. | Make sure the JSON you store is valid, or the Postgres save will fail. |
| Timestamp with timezone | timestamp does not store timezone detail | Supports timestamp with and without timezone | Laravel defaults to timestamp, so you must explicitly use $table->timestampTz() if you want time zone-aware behavior. |
| Implicit foreign key indexes | Foreign key columns automatically receive a corresponding index | Doesn’t create indexes automatically | Explicitly add ->index() to any foreignId() columns so Postgres creates their indexes. |

