<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.rixort.com/index.php?action=history&amp;feed=atom&amp;title=MySQL_to_PostgreSQL</id>
	<title>MySQL to PostgreSQL - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.rixort.com/index.php?action=history&amp;feed=atom&amp;title=MySQL_to_PostgreSQL"/>
	<link rel="alternate" type="text/html" href="https://wiki.rixort.com/index.php?title=MySQL_to_PostgreSQL&amp;action=history"/>
	<updated>2026-06-04T15:44:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.rixort.com/index.php?title=MySQL_to_PostgreSQL&amp;diff=12&amp;oldid=prev</id>
		<title>Paul at 15:06, 4 March 2018</title>
		<link rel="alternate" type="text/html" href="https://wiki.rixort.com/index.php?title=MySQL_to_PostgreSQL&amp;diff=12&amp;oldid=prev"/>
		<updated>2018-03-04T15:06:26Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:06, 4 March 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l2&quot;&gt;Line 2:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 2:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  #!/usr/bin/perl&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  #!/usr/bin/perl&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  use Modern::Perl;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  use Modern::Perl;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  use DBIx::Class::Schema::Loader qw/ make_schema_at /;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  use DBIx::Class::Schema::Loader qw/ make_schema_at /;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Paul</name></author>
	</entry>
	<entry>
		<id>https://wiki.rixort.com/index.php?title=MySQL_to_PostgreSQL&amp;diff=11&amp;oldid=prev</id>
		<title>Paul: Created page with &quot;Simple script for creating &lt;code&gt;Result&lt;/code&gt; classes from an existing MySQL database, then producing a PostgreSQL schema file from those classes:   #!/usr/bin/perl   use Mod...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.rixort.com/index.php?title=MySQL_to_PostgreSQL&amp;diff=11&amp;oldid=prev"/>
		<updated>2018-03-04T15:06:17Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Simple script for creating &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt; classes from an existing MySQL database, then producing a PostgreSQL schema file from those classes:   #!/usr/bin/perl   use Mod...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Simple script for creating &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt; classes from an existing MySQL database, then producing a PostgreSQL schema file from those classes:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/perl&lt;br /&gt;
&lt;br /&gt;
 use Modern::Perl;&lt;br /&gt;
 use DBIx::Class::Schema::Loader qw/ make_schema_at /;&lt;br /&gt;
 &lt;br /&gt;
 my $dsn = &amp;#039;dbi:mysql:dbname=database&amp;#039;;&lt;br /&gt;
 my $user = &amp;#039;&amp;#039;;&lt;br /&gt;
 my $pass = &amp;#039;&amp;#039;;&lt;br /&gt;
 &lt;br /&gt;
 make_schema_at(&lt;br /&gt;
   &amp;#039;MyDB::Schema&amp;#039;,&lt;br /&gt;
   { debug =&amp;gt; 1, dump_directory =&amp;gt; &amp;#039;./lib&amp;#039; },&lt;br /&gt;
   [ $dsn, $user, $pass&lt;br /&gt;
   ],&lt;br /&gt;
 );&lt;br /&gt;
 &lt;br /&gt;
 my $schema = MyDB::Schema-&amp;gt;connect($dsn, $user, $pass);&lt;br /&gt;
 $schema-&amp;gt;create_ddl_dir([&amp;#039;PostgreSQL&amp;#039;], &amp;#039;0.1&amp;#039;, &amp;#039;./&amp;#039;, undef, { add_drop_table =&amp;gt; 0 });&lt;br /&gt;
&lt;br /&gt;
== Pre-migration checks ==&lt;br /&gt;
&lt;br /&gt;
Two ways of testing to see whether data needs to be cleaned up before migrating:&lt;br /&gt;
&lt;br /&gt;
# Quick scan of tables for obvious &amp;#039;bad&amp;#039; values (e.g. DATE columns with &amp;#039;0000-00-00&amp;#039;) using WHERE clauses - i.e. a blacklist.&lt;br /&gt;
# Exhaustive checks of every row - i.e. a whitelist.&lt;br /&gt;
&lt;br /&gt;
Probably also a good idea to check foreign key relationships which have not explicitly been defined by the use of &amp;lt;code&amp;gt;REFERENCES&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Reasons for pre-migration checks include:&lt;br /&gt;
&lt;br /&gt;
* MySQL is not as strict as PostgreSQL about validating data (or at least, not with the default MySQL configuration).&lt;br /&gt;
* MySQL will usually enforce referential integrity if foreign keys are explicitly defined, but not all developers add the relevant &amp;lt;code&amp;gt;REFERENCES&amp;lt;/code&amp;gt; constraints to their schemas.&lt;br /&gt;
* Easier to identify and fix bad data whilst still using MySQL, and having a clean data set should make migration smoother.&lt;br /&gt;
&lt;br /&gt;
== Useful links ==&lt;br /&gt;
&lt;br /&gt;
* [http://tapoueh.org/blog/2013/08/08-MySQL-to-PostgreSQL.html Migrating from MySQL to PostgreSQL] - Blog article about tool for migration.&lt;br /&gt;
* [https://github.com/philipsoutham/py-mysql2pgsql py-mysql2pgsql] - Python module for converting MySQL to PostgreSQL. Did not work for me, but that may be due to my lack of Python knowledge and not having all the dependencies.&lt;br /&gt;
* [http://wiki.postgresql.org/wiki/How_to_make_a_proper_migration_from_MySQL_to_PostgreSQL How to make a proper migration from MySQL to PostgreSQL] - From 2009, so generic advice is useful but other parts may be out of date.&lt;br /&gt;
* [http://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL Converting from other Databases to PostgreSQL] - Starting point for jumping off to other sites.&lt;br /&gt;
* [http://stackoverflow.com/questions/4756825/mysql-to-postgresql-migration MySql to PostgreSql migration]&lt;br /&gt;
* [http://stackoverflow.com/questions/772111/switching-from-mysql-to-postgresql-tips-tricks-and-gotchas Switching from MySQL to PostgreSQL - tips, tricks and gotchas?] - Good list of things to watch out for.&lt;br /&gt;
* [http://stackoverflow.com/questions/724867/how-different-is-postgresql-to-mysql How different is PostgreSQL to MySQL?]&lt;br /&gt;
* [http://stackoverflow.com/questions/2831009/migrate-from-mysql-to-postgresql-on-linux-kubuntu/2831517 Migrate from MySQL to PostgreSQL on Linux (Kubuntu)]&lt;br /&gt;
* [http://www.xach.com/aolserver/mysql-to-postgresql.html Migrating from MySQL to PostgreSQL]&lt;br /&gt;
* [http://en.wikibooks.org/wiki/Converting_MySQL_to_PostgreSQL Converting MySQL to PostgreSQL]&lt;br /&gt;
&lt;br /&gt;
[[Category:MySQL]]&lt;/div&gt;</summary>
		<author><name>Paul</name></author>
	</entry>
</feed>