Assess your PostgreSQL database and cloud infrastructure before migrating to PlanetScale Postgres.
The PlanetScale Discovery Tool analyzes your existing PostgreSQL database and cloud infrastructure to help plan your migration to PlanetScale Postgres. It collects metadata about your database configuration, schema structure, performance characteristics, security settings, and cloud resources. It never reads or stores actual table data.The tool produces a structured JSON report that PlanetScale uses to provide migration guidance tailored to your environment.
The discovery tool is open source and available on GitHub. The documentation below covers the essentials. See the full documentation in the repository for advanced usage, troubleshooting, and detailed reference.
Create a dedicated read-only user for the discovery tool. Connect to your database as a superuser or privileged role and run the following:
-- Create a dedicated user for database discoveryCREATE USER planetscale_discovery WITH PASSWORD 'secure_password_here';-- Grant basic connection and usage permissionsGRANT CONNECT ON DATABASE your_database TO planetscale_discovery;GRANT USAGE ON SCHEMA public TO planetscale_discovery;GRANT USAGE ON SCHEMA information_schema TO planetscale_discovery;-- Grant read access to all tables and viewsGRANT SELECT ON ALL TABLES IN SCHEMA public TO planetscale_discovery;GRANT SELECT ON ALL TABLES IN SCHEMA information_schema TO planetscale_discovery;GRANT SELECT ON ALL TABLES IN SCHEMA pg_catalog TO planetscale_discovery;-- Grant permissions for system catalogs and statisticsGRANT SELECT ON pg_stat_database TO planetscale_discovery;GRANT SELECT ON pg_stat_user_tables TO planetscale_discovery;GRANT SELECT ON pg_stat_user_indexes TO planetscale_discovery;GRANT SELECT ON pg_stat_activity TO planetscale_discovery;GRANT SELECT ON pg_stat_replication TO planetscale_discovery;GRANT SELECT ON pg_settings TO planetscale_discovery;GRANT SELECT ON pg_database TO planetscale_discovery;GRANT SELECT ON pg_user TO planetscale_discovery;GRANT SELECT ON pg_roles TO planetscale_discovery;GRANT SELECT ON pg_user_mappings TO planetscale_discovery;-- For foreign data wrapper analysisGRANT SELECT ON pg_foreign_server TO planetscale_discovery;GRANT SELECT ON pg_foreign_data_wrapper TO planetscale_discovery;-- For advanced performance analysis (if pg_stat_statements is enabled)GRANT SELECT ON pg_stat_statements TO planetscale_discovery;-- For replication analysisGRANT SELECT ON pg_stat_wal_receiver TO planetscale_discovery;GRANT SELECT ON pg_stat_subscription TO planetscale_discovery;-- For PostgreSQL 10+ enhanced privileges (recommended)GRANT pg_read_all_stats TO planetscale_discovery;GRANT pg_read_all_settings TO planetscale_discovery;
If your database has additional schemas beyond public, repeat the GRANT USAGE ON SCHEMA and GRANT SELECT ON ALL TABLES IN SCHEMA statements for each schema you want analyzed.
After discovery is complete, remove the planetscale_discovery user from your database. This user has read access to your schema and system catalogs and should not be left in place.
DROP USER IF EXISTS planetscale_discovery;
If the user owns any objects, reassign ownership first:
REASSIGN OWNED BY planetscale_discovery TO postgres;DROP OWNED BY planetscale_discovery;DROP USER planetscale_discovery;
The tool produces a planetscale_discovery_results.json file in your configured output directory. Share this report with PlanetScale for migration planning assistance.
Once the discovery is complete, remember to clean up the planetscale_discovery user you created on your source database.
Each cloud provider requires specific credentials and permissions. Below is a summary of what you need for each. For detailed instructions including IAM policies and API enablement steps, see the provider documentation.
The tool discovers Heroku Postgres add-ons across all your apps, including plan details, database sizes, replica configurations, and connection pooling.Authentication:
The default database analyzers are safe to run against production databases. They use read-only queries against system catalogs and statistics views, with very low performance impact.
The optional data size analyzer performs sampling queries against actual tables and can have a significant performance impact on large databases. If you need this analysis, consider running it against a read replica and starting with a low sampling percentage. This analyzer is disabled by default and must be explicitly opted into via configuration.
The discovery tool runs entirely on your infrastructure. No data is sent to external services during analysis.Collected: Schema metadata, database configuration, usage statistics, infrastructure topology, and role names.Not collected: Table contents, row data, application queries, passwords, or secrets. Passwords are used only to establish the database connection and are never included in the output.
Once you have your discovery report, share it with us if you want tailored migration guidance. You can also follow one of our migration guides on your own: