20 lines
372 B
Go
20 lines
372 B
Go
package migrations
|
|
|
|
import (
|
|
"github.com/uptrace/bun/dialect/feature"
|
|
)
|
|
|
|
type hasFeaturer interface {
|
|
HasFeature(feat feature.Feature) bool
|
|
}
|
|
|
|
func autoincrementIDColumn(f hasFeaturer) string {
|
|
if f.HasFeature(feature.GeneratedIdentity) {
|
|
// postgres
|
|
return "id bigint GENERATED BY DEFAULT AS IDENTITY primary key"
|
|
}
|
|
|
|
// sqlite
|
|
return "id INTEGER PRIMARY KEY"
|
|
}
|