dialect/sql/schema: support setting default value expressions on id fields (#3089)

This commit is contained in:
Ariel Mashraki
2022-11-13 18:55:04 +02:00
committed by GitHub
parent 53bdc325c0
commit 891fc8fecf
24 changed files with 1839 additions and 9 deletions

View File

@@ -8,6 +8,7 @@ import (
"context"
stdsql "database/sql"
"fmt"
"reflect"
"strconv"
"strings"
@@ -473,8 +474,12 @@ func (d *SQLite) atImplicitIndexName(idx *Index, t1 *Table, c1 *Column) bool {
return err == nil && i > 0
}
func (d *SQLite) atIncrementC(_ *schema.Table, c *schema.Column) {
c.AddAttrs(&sqlite.AutoIncrement{})
func (d *SQLite) atIncrementC(t *schema.Table, c *schema.Column) {
if c.Default != nil {
t.Attrs = removeAttr(t.Attrs, reflect.TypeOf(&sqlite.AutoIncrement{}))
} else {
c.AddAttrs(&sqlite.AutoIncrement{})
}
}
func (d *SQLite) atIncrementT(t *schema.Table, v int64) {