Before beginning your migration, we recommend running the PlanetScale Discovery Tool on your database to assess compatibility and ease of migration.
Write-Ahead Logging (WAL) streaming provides a near-zero downtime migration method by continuously replicating changes from your source PostgreSQL database to PlanetScale Postgres using logical replication.
Want expert guidance for your migration? PlanetScale’s migration services are available to help you plan and execute a smooth, successful move.
PostgreSQL 10+ on the source database (logical replication support)
Administrative access to source database configuration
Network connectivity between source and PlanetScale Postgres
Connection details for your PlanetScale Postgres database from the console
Ensure the disk on your PlanetScale database has at least 150% of the capacity of your source database.
If you are migrating to a PlanetScale database backed by network-attached storage, you can resize your disk manually by setting the “Minimum disk size.”
If you are using Metal, you will need to select a size when first creating your database.
For example, if your source database is 330GB, you should have at least 500GB of storage available on PlanetScale.
Understanding of your application’s write patterns for cutover planning
Connect to your source database and create a replication user:
Report incorrect code
Copy
Ask AI
-- Create replication userCREATE USER replication_user WITH REPLICATION LOGIN;-- Grant necessary permissionsGRANT CONNECT ON DATABASE your_database TO replication_user;GRANT USAGE ON SCHEMA public TO replication_user;GRANT SELECT ON ALL TABLES IN SCHEMA public TO replication_user;-- Grant permissions for future tablesALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO replication_user;
Create a publication for the tables you want to replicate:
Report incorrect code
Copy
Ask AI
-- Create publication for all tablesCREATE PUBLICATION planetscale_migration FOR ALL TABLES;-- Or create publication for specific tablesCREATE PUBLICATION planetscale_migration FOR TABLE table1, table2, table3;-- Verify publicationSELECT * FROM pg_publication;
-- On source databaseSELECT * FROM pg_replication_slots;-- On PlanetScale databaseSELECT subname, received_lsn, latest_end_lsn, latest_end_timeFROM pg_stat_subscription;
-- Compare row counts between source and target-- Run on both databasesSELECT schemaname, tablename, n_tup_ins as estimated_rowsFROM pg_stat_user_tablesORDER BY schemaname, tablename;
Set up monitoring and alerting for the new database
4
Plan for ongoing maintenance and optimization
For simpler migrations or if you don’t have administrative access to your source database, consider the pg_dump/restore method. For more complex scenarios, explore Amazon DMS.If you encounter issues during migration, please reach out to support for assistance.