golang bun orm embed struct but keep ID as first column

Viewed 18

I am using uptrace/bun as ORM for golang. I want to create a table for an existing struct Order by adding primary key ID and created columns. I am embedding struct as follows but want to keep ID as the first column in db. How can it be done?

type MyOrder struct {
    *Order
    ID        int64     `bun:",pk,autoincrement"`
    CreatedAt time.Time `bun:",nullzero,default:now()"`
}

This creates the table but id is second last column while listing records in db.

0 Answers
Related