#45498: remove updated/created columns in `file_meta` table

pull/45534/head
Artur Wierzbicki 4 years ago
parent 656643203c
commit eb7a9bd351
  1. 17
      pkg/infra/filestorage/db_filestorage.go
  2. 2
      pkg/services/sqlstore/migrations/db_file_storage.go

@ -22,11 +22,9 @@ type file struct {
} }
type fileMeta struct { type fileMeta struct {
Path string `xorm:"path"` Path string `xorm:"path"`
Key string `xorm:"key"` Key string `xorm:"key"`
Value string `xorm:"value"` Value string `xorm:"value"`
Updated time.Time `xorm:"updated"`
Created time.Time `xorm:"created"`
} }
type dbFileStorage struct { type dbFileStorage struct {
@ -213,16 +211,13 @@ func upsertProperty(sess *sqlstore.DBSession, now time.Time, path string, key st
} }
if exists { if exists {
existing.Updated = now
existing.Value = val existing.Value = val
_, err = sess.Where("path = ? AND key = ?", strings.ToLower(path), key).Update(existing) _, err = sess.Where("path = ? AND key = ?", strings.ToLower(path), key).Update(existing)
} else { } else {
_, err = sess.Insert(&fileMeta{ _, err = sess.Insert(&fileMeta{
Path: strings.ToLower(path), Path: strings.ToLower(path),
Key: key, Key: key,
Value: val, Value: val,
Updated: now,
Created: now,
}) })
} }
return err return err

@ -28,8 +28,6 @@ func addDbFileStorageMigration(mg *migrator.Migrator) {
{Name: "path", Type: migrator.DB_NVarchar, Length: 1024, Nullable: false}, {Name: "path", Type: migrator.DB_NVarchar, Length: 1024, Nullable: false},
{Name: "key", Type: migrator.DB_NVarchar, Length: 1024, Nullable: false}, {Name: "key", Type: migrator.DB_NVarchar, Length: 1024, Nullable: false},
{Name: "value", Type: migrator.DB_NVarchar, Length: 1024, Nullable: false}, {Name: "value", Type: migrator.DB_NVarchar, Length: 1024, Nullable: false},
{Name: "updated", Type: migrator.DB_DateTime, Nullable: false},
{Name: "created", Type: migrator.DB_DateTime, Nullable: false},
}, },
Indices: []*migrator.Index{ Indices: []*migrator.Index{
{Cols: []string{"path", "key"}, Type: migrator.UniqueIndex}, {Cols: []string{"path", "key"}, Type: migrator.UniqueIndex},

Loading…
Cancel
Save