[DBIx-Class-Devel] [dbsrgits/sql-translator] Avoid creating clashing index names (#121)

davel notifications at github.com
Thu Dec 12 12:32:57 GMT 2019


This is to resolve a problem in which a ```CREATE TABLE``` is generated that MySQL rejects with a duplicate key name error.

When we create a foreign key constraint for MySQL we also create an index if there is not already an index beginning with the field in question. UNIQUEness constraints are implemented by indices, and so we can skip adding an index if one already exists.

To avoid changing existing working schemas, this change only skips index creation if one with the same name already exists. This case currently fails with a duplicate key error in MySQL, eg.,

```ERROR 1061 (42000): Duplicate key name 'foo'```
You can view, comment on, or merge this pull request online at:

  https://github.com/dbsrgits/sql-translator/pull/121

-- Commit Summary --

  * Assert current behaviour with clashing index names
  * Avoid index name clashing with UNIQUE KEY

-- File Changes --

    M lib/SQL/Translator/Producer/MySQL.pm (10)
    M t/38-mysql-producer.t (45)

-- Patch Links --

https://github.com/dbsrgits/sql-translator/pull/121.patch
https://github.com/dbsrgits/sql-translator/pull/121.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/dbsrgits/sql-translator/pull/121
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class-devel/attachments/20191212/75a57811/attachment.htm>


More information about the DBIx-Class-Devel mailing list