Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gorm:primaryKey not being taken into consideration by auto migrator #68

Open
prajjwaldimri opened this issue Nov 21, 2022 · 3 comments
Open
Assignees

Comments

@prajjwaldimri
Copy link

Hi.

I am trying to create a table in the clickhouse database using gorm's auto migrator. I have defined the struct as below:

type Cost struct {
	InfraId    string    `json:"infra_id" gorm:"primaryKey,index:idx_primary"`
	Timestamp  time.Time `json:"timestamp" gorm:"primaryKey,index:idx_primary"`
	HourlyCost string    `json:"hourly_cost"`
}

When the automigrator runs, it sends the following SQL statement to the clickhouse DB.

CREATE TABLE `costs`(`infra_id` String,`timestamp` DateTime64(3),`hourly_cost` String  ) ENGINE=MergeTree() ORDER BY tuple()

As you can see, for some reason, it doesn't send any information about the primary keys. I have verified that it actually doesn't create any primary keys on the DB too. Why might this be happening?

Thanks.

@xiyichan
Copy link

I have same problem.

@zyjblockchain
Copy link

I have same problem

@zyjblockchain
Copy link

https://github.com/go-gorm/clickhouse/blob/master/migrator.go#L130

this function alse is a todo list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants