Moving from MySQL to PostgreSQL is rarely a weekend job, and it is rarely as simple as "export, import, done". Most of the work is in the details: data types, SQL dialect quirks, application code, cutover planning and compliance.
This guide covers what UK teams need to know before hiring a migration service or attempting the move in-house.
Why UK Teams Are Moving to PostgreSQL
The reasons are usually practical rather than fashionable:
-
Richer features: window functions, CTEs, partial indexes,
JSONB, full-text search and extensions like PostGIS and pgvector. - Stricter data integrity: PostgreSQL enforces constraints and types more rigorously, which reduces silent data corruption.
- Licensing and governance: PostgreSQL's permissive licence and community governance appeal to teams wary of vendor lock-in.
- Managed service choice: Amazon RDS/Aurora, Google Cloud SQL and Azure Database for PostgreSQL all offer UK regions.
- Analytics on operational data: PostgreSQL handles complex queries well, so you can often drop a separate reporting stack.
If none of these apply and your MySQL setup is healthy, migrating may not be worth the effort. A good provider will tell you that up front.
What a Migration Service Should Actually Cover
A credible service covers the whole lifecycle, not just moving rows:
- Assessment: inventory of schemas, stored procedures, triggers, views, users, replication setup and application queries.
- Schema conversion: translating data types, indexes, constraints and sequences.
- Code remediation: rewriting incompatible SQL in your application and ORM layer.
- Data migration: bulk load plus ongoing replication to keep systems in sync.
- Validation: row counts, checksums, query result comparisons and performance benchmarks.
- Cutover and rollback planning: a rehearsed plan, not a hopeful one.
-
Post-migration tuning:
VACUUM, indexing, connection pooling and monitoring.
If a quote skips assessment or validation, treat it as a warning sign.
Where MySQL and PostgreSQL Differ
Most migration pain comes from small differences that add up. Here are the ones that catch teams out.
Data types
-
TINYINT(1)is commonly used as a boolean in MySQL. In PostgreSQL, useBOOLEAN. -
AUTO_INCREMENTbecomesGENERATED ... AS IDENTITY(orSERIALin older code). -
DATETIMEandTIMESTAMPbehave differently. Decide deliberately betweentimestampandtimestamptz. -
ENUMtypes exist in both, but they are managed differently. - MySQL's "zero dates" such as
0000-00-00are invalid in PostgreSQL and must be cleaned.
Syntax
-- MySQL
SELECT `order_id`, `total` FROM `orders` LIMIT 10;
INSERT INTO users (id, email) VALUES (1, 'a@example.com')
ON DUPLICATE KEY UPDATE email = VALUES(email);
-- PostgreSQL
SELECT "order_id", "total" FROM "orders" LIMIT 10;
INSERT INTO users (id, email) VALUES (1, 'a@example.com')
ON CONFLICT (id) DO UPDATE SET email = EXCLUDED.email;
Behavioural differences
- Case sensitivity: PostgreSQL folds unquoted identifiers to lowercase, and string comparisons are case-sensitive by default. Queries that relied on MySQL's case-insensitive collations may return different results.
-
GROUP BYstrictness: MySQL historically allowed non-aggregated columns. PostgreSQL does not. - Implicit casting: PostgreSQL is stricter, so sloppy comparisons will error rather than quietly succeed.
-
Character sets:
utf8mb4maps toUTF8in PostgreSQL, but check collations and emoji handling. - Stored procedures: MySQL routines usually need a full rewrite into PL/pgSQL.
A Practical Migration Approach
Here is a typical low-risk sequence:
1. Audit and scope. List every database object and every application that touches the database. Include cron jobs, BI tools and third-party integrations, since these are the things people forget.
2. Convert the schema. Tools like pgloader can automate much of this. Review the output by hand, because automated conversion is a starting point, not a finished product.
pgloader mysql://user:pass@mysql-host/appdb \
postgresql://user:pass@pg-host/appdb
3. Fix the application. Update queries, ORM configuration and migrations. Run your test suite against PostgreSQL in CI as early as possible.
4. Migrate the data. For small databases, a bulk load in a maintenance window is fine. For larger or busy systems, use change data capture (for example AWS DMS or Debezium) to replicate continuously while you validate.
5. Validate. Compare row counts and checksums, run representative queries on both systems, and load test PostgreSQL with production-like traffic.
6. Rehearse the cutover. Do at least one full dry run. Agree a rollback trigger in advance, such as "if error rate exceeds X% within 30 minutes, revert".
7. Cut over and monitor. Switch traffic, keep MySQL read-only for a defined period, and watch query performance closely. Plans that work well on MySQL sometimes need new indexes on PostgreSQL.
UK-Specific Considerations
Data protection. If your database holds personal data, UK GDPR and the Data Protection Act 2018 apply. Confirm where migration staff and tooling will access data, and make sure a proper data processing agreement is in place with any provider.
Data residency. Many UK organisations prefer UK-hosted infrastructure, such as AWS London (eu-west-2) or Azure UK South. Check that any replication or backup tooling does not move data outside your chosen region.
Security standards. Public sector, healthcare and financial services clients often require Cyber Essentials, ISO 27001 or NCSC-aligned practices from suppliers. Ask for evidence rather than assurances.
Timing. UK retail, ticketing and payroll systems have predictable peaks such as Black Friday, tax year end and bank holiday weekends. Schedule cutovers well away from them.
Costs and Timelines
Every estate is different, so treat these as rough ballparks rather than quotes:
- Small application (single database, simple schema): a few weeks and a modest five-figure budget at most, often less.
- Mid-sized platform (multiple services, some stored logic): one to three months.
- Complex or regulated estate (heavy stored procedures, strict uptime, many integrations): three to six months or longer, with a correspondingly larger budget.
The biggest cost drivers are stored procedures, the amount of application SQL to rewrite, the downtime you can tolerate, and how much testing you need. Fixed-price quotes are only sensible after an assessment phase.
Choosing a Migration Provider
Look for:
- Named, relevant experience with MySQL to PostgreSQL specifically, not generic "database migration".
- A paid discovery phase that produces a written plan and risk register.
- Clear ownership of validation, rollback and post-go-live support.
- Transparent tooling with no black-box scripts you cannot inspect or reuse.
- Knowledge transfer so your team can run PostgreSQL confidently afterwards.
Be cautious of anyone promising zero downtime and zero risk without seeing your workload, or quoting a fixed price on a call.
Frequently Asked Questions
1. How long does a MySQL to PostgreSQL migration take?
Small, straightforward databases can move in two to four weeks including testing. Larger systems with stored procedures and multiple dependent applications typically take two to six months. Assessment findings, not the size of the data, are the best predictor of duration.
2. Can we migrate with zero downtime?
Near-zero downtime is achievable using change data capture to keep PostgreSQL in sync with MySQL, followed by a brief switchover. True zero downtime is difficult, and any claim of it should come with a detailed cutover plan and a rollback strategy.
3. Will our application code need to change?
Almost always, at least a little. Backtick quoting, ON DUPLICATE KEY UPDATE, GROUP BY behaviour, date handling and case-insensitive comparisons are common areas for change. ORMs reduce the work but rarely eliminate it, so run your full test suite against PostgreSQL early.
4. Is it safe to migrate personal data under UK GDPR?
Yes, provided you handle it lawfully. Use a data processing agreement with any provider, restrict access on a least-privilege basis, encrypt data in transit and at rest, and keep data within approved regions. Your data protection officer should sign off the plan before work starts.
5. Should we use a managed PostgreSQL service after migrating?
For most teams, yes. Managed services such as Amazon RDS, Aurora PostgreSQL, Google Cloud SQL and Azure Database for PostgreSQL handle backups, patching and failover, and all offer UK regions. Self-hosting makes sense mainly when you need extensions or configuration that managed services do not permit.
Final Thoughts
A good MySQL to PostgreSQL migration is boring: thorough assessment, careful conversion, repeated testing, a rehearsed cutover and a clear rollback. The teams that run into trouble are usually the ones that skipped straight to moving data.
Whether you hire a specialist or do it in-house, plan for the application changes, respect the UK compliance requirements, and validate everything before you switch off MySQL.
Work with eSparks IT Solutions
Planning a project around this? We help businesses across the USA, UK, Canada, Australia and the GCC ship it. See how we work with clients in the USA. Explore our Mobile Development services and portfolio, estimate your project cost, or book a free call.
Top comments (0)