SQLite model refactoring, part 2 (#3839)

* Treat empty image input as null
* Add validation to models.Date
* Allow zero dates in database
* Make scene_markers.scene_id non-nullable
* Drop scraped_items table
* Remove movie/studio checksum
* Add migration notes
---------
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
DingDongSoLong4
2023-07-13 04:15:02 +02:00
committed by GitHub
parent 67d4f9729a
commit 5580525c2d
74 changed files with 520 additions and 807 deletions

View File

@@ -15,7 +15,6 @@ import (
"time"
"github.com/stashapp/stash/pkg/file"
"github.com/stashapp/stash/pkg/hash/md5"
"github.com/stashapp/stash/pkg/models"
"github.com/stashapp/stash/pkg/sliceutil/intslice"
"github.com/stashapp/stash/pkg/sqlite"
@@ -956,14 +955,14 @@ func getWidth(index int) int {
}
func getObjectDate(index int) *models.Date {
dates := []string{"null", "", "0001-01-01", "2001-02-03"}
dates := []string{"null", "2000-01-01", "0001-01-01", "2001-02-03"}
date := dates[index%len(dates)]
if date == "null" {
return nil
}
ret := models.NewDate(date)
ret, _ := models.ParseDate(date)
return &ret
}
@@ -1313,7 +1312,6 @@ func createMovies(ctx context.Context, mqb models.MovieReaderWriter, n int, o in
movie := models.Movie{
Name: name,
URL: getMovieNullStringValue(index, urlField),
Checksum: md5.FromString(name),
}
err := mqb.Create(ctx, &movie)
@@ -1578,7 +1576,6 @@ func getStudioNullStringValue(index int, field string) string {
func createStudio(ctx context.Context, sqb models.StudioReaderWriter, name string, parentID *int) (*models.Studio, error) {
studio := models.Studio{
Name: name,
Checksum: md5.FromString(name),
}
if parentID != nil {
@@ -1621,7 +1618,6 @@ func createStudios(ctx context.Context, sqb models.StudioReaderWriter, n int, o
name = getStudioStringValue(index, name)
studio := models.Studio{
Name: name,
Checksum: md5.FromString(name),
URL: getStudioNullStringValue(index, urlField),
IgnoreAutoTag: getIgnoreAutoTag(i),
}