Fix `created_at` default val in v4 migration for SQLite
This previously used a default timestamp value which caused the migration to fail for SQLite databases.
This commit is contained in:
parent
793380c1d9
commit
5b2612af54
|
@ -139,6 +139,15 @@ func (c *Column) SetDefault(value string) *Column {
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Column) SetDefaultCurrentTimestamp() *Column {
|
||||||
|
def := "NOW()"
|
||||||
|
if c.Dialect == DialectSQLite {
|
||||||
|
def = "CURRENT_TIMESTAMP"
|
||||||
|
}
|
||||||
|
c.Default = OptionalString{Set: true, Value: def}
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Column) SetType(t ColumnType) *Column {
|
func (c *Column) SetType(t ColumnType) *Column {
|
||||||
c.Type = t
|
c.Type = t
|
||||||
return c
|
return c
|
||||||
|
|
|
@ -29,7 +29,7 @@ func oauth(db *datastore) error {
|
||||||
SetIfNotExists(true).
|
SetIfNotExists(true).
|
||||||
Column(dialect.Column("state", wf_db.ColumnTypeVarChar, wf_db.OptionalInt{Set: true, Value: 255})).
|
Column(dialect.Column("state", wf_db.ColumnTypeVarChar, wf_db.OptionalInt{Set: true, Value: 255})).
|
||||||
Column(dialect.Column("used", wf_db.ColumnTypeBool, wf_db.UnsetSize)).
|
Column(dialect.Column("used", wf_db.ColumnTypeBool, wf_db.UnsetSize)).
|
||||||
Column(dialect.Column("created_at", wf_db.ColumnTypeDateTime, wf_db.UnsetSize).SetDefault("NOW()")).
|
Column(dialect.Column("created_at", wf_db.ColumnTypeDateTime, wf_db.UnsetSize).SetDefaultCurrentTimestamp()).
|
||||||
UniqueConstraint("state").
|
UniqueConstraint("state").
|
||||||
ToSQL()
|
ToSQL()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue