mysql2sqlite icon indicating copy to clipboard operation
mysql2sqlite copied to clipboard

Double primary key statement in create table with autoincrement fields

Open frankiejol opened this issue 8 years ago • 1 comments

At the create table, fields with auto_increment are turned into primary key autoincrement. This is fine but if the field has already the primary key it ends up with two, like this:

`id` integer NOT NULL PRIMARY KEY PRIMARY KEY AUTOINCREMENT

frankiejol avatar Nov 11 '16 09:11 frankiejol

I fixed it adding the line 99, that removes any previous primary key. Hope this helps.

 97   if ( match( $0, /[^"`]AUTO_INCREMENT|auto_increment[^"`]/)) {
 98     aInc = 1;
 99     gsub( /PRIMARY KEY/, "" )
100     gsub( /AUTO_INCREMENT|auto_increment/, "PRIMARY KEY AUTOINCREMENT" )
101   }

frankiejol avatar Nov 11 '16 09:11 frankiejol