by seanharr11 on 8/16/17, 7:44 PM
I wrote an open source tool that migrates between any 2 relational databases.
https://github.com/seanharr11/etlalchemy
This includes automatic migration of the schema, constraints, indexes and obviously data. It leverages fast bulk loading tools like mysqlimport, and PostgreSQL's COPY FROM. It doesn't need any config. Just plug and play.
The tool uses SQLAlchemy to abstract column types, and handles various column type conversions between any flavor of SQL.
The one thing it needs are tests, and scalability support for tables bigger than a few GB!
by willcodeforfoo on 8/16/17, 3:05 PM
I'm working on migrating an app right now (just one MySQL database) but can highly recommend [pgloader](
http://pgloader.io/). It has a bunch of built-in and configurable rules to cast different column types to PostgreSQL and the developer has been very responsive in helping me make weird column types work, too.
by sigi45 on 8/16/17, 8:33 PM
I like the approach and think something like this is fun but i don't understand the businsess case at all.
I would have migrated MySQL 5.5 to 5.6 first, than cleaned the shit out of it, normalized everything, added a few indezes and suddently realize that there is not much left to do.
I like to work with postgresql but if you have 1,2k dbs which are more or less not claned up and crappy, what are they used anyway?
by SOLAR_FIELDS on 8/16/17, 2:02 PM
One thing author did not touch on: since the tables were denormalized-ish in the original MySQL DB, did his application lose significant performance by having to perform the joins for every single query in the renormalized PostGres instance? Or were the DB's small enough and indexed properly enough so it didn't really matter?
Might have been worthy of testing this to see if it was worth it to materialize certain views and refresh them every 15-30 minutes or so.
by berns on 8/16/17, 2:35 PM
One thing that Postgres lacks is accent insensitive collations. Having clients with databases in Spanish, this is one of the reasons I wouldn't consider migrating to Postgres. I know I can use the unaccent extension, but I consider it a poor substitute to proper collations. I guess this isn't a problem for most people because it's never mentioned.
by medius on 8/16/17, 5:18 PM
If you are migrating to AWS RDS, I recommend AWS Data Migration service. I migrated my live database (~50GB) from Mysql to Postgres (both RDS) with zero downtime.
I used AWS Schema Conversion Tool for initial PG schema. I customized the generated schema for my specific needs.
by seanharr11 on 8/16/17, 2:07 PM
by tkyjonathan on 8/16/17, 6:32 PM
I'm not against the idea of using postgres, but I have a sneaky suspicion, that you could have gotten that 30% speed benefit from MySQL, if you did some performance work on it. Or in other words, I don't feel that migrating from one relational database to another similar relational database was worth that much trouble.
by aidos on 8/16/17, 2:11 PM
I went through a similar process a few years ago (4k dbs into a single db, all mysql). You'll get something working fairly quickly and then spend days debugging data anomalies that have crept in over the years.
We ended up with a frankenstein mixture of bash scripts, a sequence of sql transformations, some python and some php to decode some of the data that had been stored in pickled / php encoded packages.
It's not something I want to repeat any time soon :-)
by JelteF on 8/16/17, 2:25 PM
One of the main things I ran into when migrating from MySQL to postgres was that the default text columns (TEXT, VARCHAR, etc) behave differently when searching. MySQL matches text case insensitive, while postgres matches it case sensitive. This resulted in searches for content suddenly not returning data. Luckily there's an official CITEXT extension for postgres [1], which matches text case insensitive and adds the correct indices for doing so efficiently.
[1] https://www.postgresql.org/docs/9.1/static/citext.html
by ehxcaet on 8/16/17, 7:26 PM
I'm not entirely sure what the technical reason for this change was. Of course, cleaning up your DBs and whatnot is a good thing. But why did they move it to Postgres instead of simply clean?
by noir_lord on 8/16/17, 1:51 PM
Would love to do this to the monstrosity I inherited in new job but it's a sispheyan task.
One day.
by TekMol on 8/16/17, 3:11 PM
Is it an universally accepted truth now that it's generally better to use Postgres then to use MySql?
Would anybody here use MySql for a new project? If so, why?
by nrmitchi on 8/16/17, 2:50 PM
> Now is when one of the main reasons to take Postgres as our new database server. Postgres allows the use of Views(include link) supporting INSERT, UPDATE and DELETE meanwhile the relation between views and tables are one to one, ....isn’t it awesome?
Just a heads up, I think you missed a link in there
by ibejoeb on 8/17/17, 2:08 AM
When talking about replaying live activity on the test system:
>We took the third option because the other two options were quite intrusive and they might interfere at the normal use of our app because in both cases they were going to be in between our users request and our app
One of those two rejected options was goreplay. It is passive, like tcpdump. Right from the docs:
"Gor is not a proxy: you do not need to put 3-rd party tool to your critical path. Instead Gor just silently analyzes the traffic of your application and does not affect it anyhow."
by StreamBright on 8/16/17, 6:22 PM
Now that is what I call a proper migration. Great content! I was wondering how could somebody end up with corrupt data, I guess it was due to MySQL not strict enforcing the types probably.
by ris on 8/16/17, 7:58 PM
by adrianlmm on 8/16/17, 7:19 PM
I tried to migrate from Firebird to Postgres once and I failed, it needs more administration than Firebird.
by ZeusNuts on 8/17/17, 8:51 PM
What was the reason to first migrate and then repair data? Repair scripts could've been ran against the old setup too and you would've had less stuff to migrate.