mirror of
https://github.com/writefreely/writefreely
synced 2024-11-10 11:24:13 +00:00
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
2 changed files with 10 additions and 1 deletions
|
@ -139,6 +139,15 @@ func (c *Column) SetDefault(value string) *Column {
|
|||
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 {
|
||||
c.Type = t
|
||||
return c
|
||||
|
|
|
@ -29,7 +29,7 @@ func oauth(db *datastore) error {
|
|||
SetIfNotExists(true).
|
||||
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("created_at", wf_db.ColumnTypeDateTime, wf_db.UnsetSize).SetDefault("NOW()")).
|
||||
Column(dialect.Column("created_at", wf_db.ColumnTypeDateTime, wf_db.UnsetSize).SetDefaultCurrentTimestamp()).
|
||||
UniqueConstraint("state").
|
||||
ToSQL()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue