Adding primary key with pt-online-schema-change fails

I am using the following command to add a primary key to a table that does not have one.

 pt-online-schema-change --execute --alter 'ADD Primary Key (image_id)' D=datastore,t=images --no-drop-old-table --port 3306 --user root --host --password xxx --alter-foreign-keys-method auto --no-version-check 

The error I am getting is

No slaves found.  See --recursion-method if host db400 has slaves.
Not checking slave lag because no slaves were found and --check-slave-lag was not specified.
Operation, tries, wait:
analyze_table, 10, 1
copy_rows, 10, 0.25
create_triggers, 10, 1
drop_triggers, 10, 1
swap_tables, 10, 1
update_foreign_keys, 10, 1
No foreign keys reference `datastore`.`images`; ignoring --alter-foreign-keys-method.
Altering `datastore`.`images`...
You are trying to add an unique key. This can result in data loss if the data is not unique.
Please read the documentation for the --check-unique-key-change parameter.
You can check if the column(s) contain duplicate content by running this/these query/queries:
       'Yes, the desired unique index currently contains only unique values',
       'No, the desired unique index contains duplicated values. There will be data loss'
) AS IsThereUniqueness FROM `datastore`.`images`;
Keep in mind that these queries could take a long time and consume a lot of resources
`datastore`.`images` was not altered.

The values in the table all unique but the table is not altered.

1 Like

I had to add --no-check-unique-key-change after I made sure there was no duplicates.

1 Like