Project

General

Profile

Migrating to postgresql

Added by Craig Efrein over 12 years ago

Hello all,

We are using the gem mysql2psql to migrate from MySQL to PostgreSQL. For some reason, about 10,000 rows in the journal table aren't being imported.

I have compared the structure of the table in both postgresql and mysql and they are identical.

Postgresql - journals

redmine=# \d journals
                                        Table "public.journals" 
      Column      |            Type             |                       Modifiers                       
------------------+-----------------------------+-------------------------------------------------------
 id               | integer                     | not null default nextval('journals_id_seq'::regclass)
 journalized_id   | integer                     | not null default 0
 journalized_type | character varying(30)       | not null default ''::character varying
 user_id          | integer                     | not null default 0
 notes            | text                        | 
 created_on       | timestamp without time zone | not null
Indexes:
    "journals_pkey" PRIMARY KEY, btree (id)
    "index_journals_on_created_on" btree (created_on)
    "index_journals_on_journalized_id" btree (journalized_id)
    "index_journals_on_user_id" btree (user_id)
    "journals_journalized_id" btree (journalized_id, journalized_type)

MySQL

mysql> explain journals;
+------------------+-------------+------+-----+---------+----------------+
| Field            | Type        | Null | Key | Default | Extra          |
+------------------+-------------+------+-----+---------+----------------+
| id               | int(11)     | NO   | PRI | NULL    | auto_increment | 
| journalized_id   | int(11)     | NO   | MUL | 0       |                | 
| journalized_type | varchar(30) | NO   |     |         |                | 
| user_id          | int(11)     | NO   | MUL | 0       |                | 
| notes            | text        | YES  |     | NULL    |                | 
| created_on       | datetime    | NO   | MUL | NULL    |                | 
+------------------+-------------+------+-----+---------+----------------+

Has anyone encountered the same problem or does anyone have an idea as to why so many rows aren't being imported? The rows that aren't being imported are older. Out of 41397 records in MySQL, I'm only showing 31397 in postgresql. Oddly enough, the records that aren't showing up have an id between 5135 and 15843. The last record id for journals is 42443. So the records I'm missing are in the middle.

Thanks,
Craig