volatiletech / sqlboiler

Generate a Go ORM tailored to your database schema.
BSD 3-Clause "New" or "Revised" License
6.73k stars 544 forks source link

[Question] How to get complex unique key and primary key infromation. #564

Closed bannzai closed 5 years ago

bannzai commented 5 years ago

What version of SQLBoiler are you using (sqlboiler --version)?

$ sqlboiler --version
SQLBoiler v3.4.0

Question

Hi, I have a question. How to get information for complex unique key and complex primary key from sqlboiler?

I want to use complex unique key and primary key informations. But I do not found these information from mysql-driver and Table struct.

Here is an example mysql Create Tables SQL for my question. So, I want to extract user_id and hash paris from sqlboiler. (like { .UniqueInfos })

CREATE TABLE `user_id_hash` (
  `user_id` int(10) unsigned NOT NULL,
  `hash` varchar(32) NOT NULL,
  `name` varchar(40) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  PRIMARY KEY (`user_id`,`hash`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

Thank you.

aarondl commented 5 years ago

It's in the PrimaryKey part of the Table struct you linked. As for compound unique keys, we don't deal with those at the moment and so sqlboiler has no accounting of it.