title: Promote index to primary key
body: <p>I have a table in a MariaDB database for which no primary key is defined. However, it has an index. I'd like to add a primary key with the same definition as that index. The naïve way might be:</p>
  
  <pre><code>alter table `foo` add primary key (`bar`, `baz`),
                    drop index `qux`;
  </code></pre>
  
  <p>...but that will take a very long time and seems wasteful. (The table is tens of gigabytes in size and is running on a machine with less free disk space than the total size of the table.) I realize an index and a primary key aren't the same thing (at the very least, the primary key includes a uniqueness constraint which must be checked during the creation process), but is there any way to use the index to “bootstrap” the primary key?</p>