feat: support pg serial type for auto_increment (#1563)
* add correct example for pg's url * 🐞 fix: merge * 🐞 fix: pg default port * ✨ feat: support serial type Co-authored-by: kurimi1 <d0n41df@gmail.com>
This commit is contained in:
@@ -690,7 +690,7 @@ var commands = []cli.Command{
|
|||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "url",
|
Name: "url",
|
||||||
Usage: `the data source of database,like "postgres://root:password@127.0.0.1:54332/database?sslmode=disable"`,
|
Usage: `the data source of database,like "postgres://root:password@127.0.0.1:5432/database?sslmode=disable"`,
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "table, t",
|
Name: "table, t",
|
||||||
|
|||||||
@@ -120,9 +120,15 @@ func (m *PostgreSqlModel) getColumns(schema, table string, in []*PostgreColumn)
|
|||||||
isNullAble = "NO"
|
isNullAble = "NO"
|
||||||
}
|
}
|
||||||
|
|
||||||
extra := "auto_increment"
|
extra := ""
|
||||||
if e.IdentityIncrement.Int32 != 1 {
|
// when identity is true, the column is auto increment
|
||||||
extra = ""
|
if e.IdentityIncrement.Int32 == 1 {
|
||||||
|
extra = "auto_increment"
|
||||||
|
}
|
||||||
|
|
||||||
|
// when type is serial, it's auto_increment. and the default value is tablename_columnname_seq
|
||||||
|
if strings.Contains(e.ColumnDefault.String, table+"_"+e.Field.String+"_seq") {
|
||||||
|
extra = "auto_increment"
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(index[e.Field.String]) > 0 {
|
if len(index[e.Field.String]) > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user