Re: Duplicate entry '0' for key 'PRIMARY'

From: J.O. Aho <user_at_example.net>
Date: Sun, 16 Apr 2017 09:34:04 +0200
Message-ID: <elgl3dFft6mU1_at_mid.individual.net>


On 04/16/17 03:19, Peter H. Coffin wrote:
> On Sat, 15 Apr 2017 19:33:01 +0200, Thomas 'PointedEars' Lahn wrote:
>

>> But they SHOULD NOT be related in this case in any practical sense of
>> the word. There SHOULD NOT be any records in the first table referring
>> to the second one because the second one is EMPTY. (Foreign key
>> constraints can make sure of that in operation, but not with MyISAM;
>> InnoDb is recommended.)

>
> Remember the original post. This is not a everyday load. This is a
> restoration from a dump. Even though the rows are not in the table yet,
> they represent a state of a database, very likely with proper
> interrelationships set up. Though clearly Something Happened that this
> restore is not going smoothly, but my answer actually addresses that.
>
From his other thread which he created afterwards:

Subject: data migrations after changing table structure

I'm using rails schema:load to create mysql databases After they're created I get duplicate entry 0 for primary key error when i import data
How do I set default engine in my.cnf so when i create tables the engine is set to InnoDB, the primary key is set to id and autoincrement is on for primary key
I was told I needed to alter the tables in this way but I wanna set it in my.cnf and rebuild the database again after

---

So he has made a change to the object in Rails, rails has created the
new database and he tries to restore the old data to this new database.
I would say that a column which didn't use to be a primary key has been
altered to be a primary key.

[Quoted] He has two rows in the table which has id 0, which he has to fix before
he can import the data, sure he can remove the primary key restraint,
which will leads to his rail application may not work.

-- 

 //Aho
Received on Sun Apr 16 2017 - 09:34:04 CEST

Original text of this message