2023-12-20 07:03:03 +00:00
|
|
|
package migrations
|
|
|
|
|
2024-01-04 10:44:36 +00:00
|
|
|
import (
|
|
|
|
"github.com/uptrace/bun/dialect/feature"
|
|
|
|
)
|
2023-12-20 07:03:03 +00:00
|
|
|
|
|
|
|
type hasFeaturer interface {
|
|
|
|
HasFeature(feat feature.Feature) bool
|
|
|
|
}
|
|
|
|
|
2024-01-04 10:44:36 +00:00
|
|
|
func autoincrementIDColumn(f hasFeaturer) string {
|
2023-12-20 07:03:03 +00:00
|
|
|
if f.HasFeature(feature.GeneratedIdentity) {
|
2024-01-04 10:44:36 +00:00
|
|
|
// postgres
|
|
|
|
return "id bigint GENERATED BY DEFAULT AS IDENTITY primary key"
|
2023-12-20 07:03:03 +00:00
|
|
|
}
|
2024-01-04 10:44:36 +00:00
|
|
|
|
|
|
|
// sqlite
|
|
|
|
return "id INTEGER PRIMARY KEY"
|
2023-12-20 07:03:03 +00:00
|
|
|
}
|