Fix null values in DB (#2840)

* Fix album image_files being null.

* Fix small nitpick.

* Use ExecContext instead of Exec.

* Change more columns to not null and set default values.

* Remove columns that don't need to be changed from migration.

* Fix typo.

* Remove unnecessary select statements.

* Remove duplicate code.

* Do not apply changes to radio table.

* Do not apply changes full_text columns and respective indexes.

* Fix musicbrainz columns.

* Rename migration.

* Make ExternalInfoUpdatedAt nullable

* Make Share's timestamps nullable

---------

Co-authored-by: Deluan Quintão <deluan@navidrome.org>
This commit is contained in:
Caio Cotts
2024-02-07 17:45:08 -08:00
committed by GitHub
parent ac4ceab143
commit bf2bcb1279
11 changed files with 693 additions and 84 deletions
+2 -1
View File
@@ -13,6 +13,7 @@ import (
"github.com/navidrome/navidrome/core/auth"
"github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/server"
. "github.com/navidrome/navidrome/utils/gg"
)
func ImageURL(r *http.Request, artID model.ArtworkID, size int) string {
@@ -66,6 +67,6 @@ func encodeMediafileShare(s model.Share, id string) string {
if s.MaxBitRate != 0 {
claims["b"] = s.MaxBitRate
}
token, _ := auth.CreateExpiringPublicToken(s.ExpiresAt, claims)
token, _ := auth.CreateExpiringPublicToken(V(s.ExpiresAt), claims)
return token
}
+5 -4
View File
@@ -9,6 +9,7 @@ import (
"github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/server/public"
"github.com/navidrome/navidrome/server/subsonic/responses"
. "github.com/navidrome/navidrome/utils/gg"
"github.com/navidrome/navidrome/utils/req"
)
@@ -34,8 +35,8 @@ func (api *Router) buildShare(r *http.Request, share model.Share) responses.Shar
Description: share.Description,
Username: share.Username,
Created: share.CreatedAt,
Expires: &share.ExpiresAt,
LastVisited: share.LastVisitedAt,
Expires: share.ExpiresAt,
LastVisited: V(share.LastVisitedAt),
VisitCount: int32(share.VisitCount),
}
if resp.Description == "" {
@@ -62,7 +63,7 @@ func (api *Router) CreateShare(r *http.Request) (*responses.Subsonic, error) {
repo := api.share.NewRepository(r.Context())
share := &model.Share{
Description: description,
ExpiresAt: expires,
ExpiresAt: &expires,
ResourceIDs: strings.Join(ids, ","),
}
@@ -95,7 +96,7 @@ func (api *Router) UpdateShare(r *http.Request) (*responses.Subsonic, error) {
share := &model.Share{
ID: id,
Description: description,
ExpiresAt: expires,
ExpiresAt: &expires,
}
err = repo.(rest.Persistable).Update(id, share)