mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
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:
@@ -28,7 +28,6 @@ const (
|
||||
|
||||
type studioRow struct {
|
||||
ID int `db:"id" goqu:"skipinsert"`
|
||||
Checksum string `db:"checksum"`
|
||||
Name zero.String `db:"name"`
|
||||
URL zero.String `db:"url"`
|
||||
ParentID null.Int `db:"parent_id,omitempty"`
|
||||
@@ -45,7 +44,6 @@ type studioRow struct {
|
||||
|
||||
func (r *studioRow) fromStudio(o models.Studio) {
|
||||
r.ID = o.ID
|
||||
r.Checksum = o.Checksum
|
||||
r.Name = zero.StringFrom(o.Name)
|
||||
r.URL = zero.StringFrom(o.URL)
|
||||
r.ParentID = intFromPtr(o.ParentID)
|
||||
@@ -59,7 +57,6 @@ func (r *studioRow) fromStudio(o models.Studio) {
|
||||
func (r *studioRow) resolve() *models.Studio {
|
||||
ret := &models.Studio{
|
||||
ID: r.ID,
|
||||
Checksum: r.Checksum,
|
||||
Name: r.Name.String,
|
||||
URL: r.URL.String,
|
||||
ParentID: nullIntPtr(r.ParentID),
|
||||
@@ -78,7 +75,6 @@ type studioRowRecord struct {
|
||||
}
|
||||
|
||||
func (r *studioRowRecord) fromPartial(o models.StudioPartial) {
|
||||
r.setString("checksum", o.Checksum)
|
||||
r.setNullString("name", o.Name)
|
||||
r.setNullString("url", o.URL)
|
||||
r.setNullInt("parent_id", o.ParentID)
|
||||
@@ -173,13 +169,6 @@ func (qb *StudioStore) Destroy(ctx context.Context, id int) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO - set null on foreign key in scraped items
|
||||
// remove studio from scraped items
|
||||
_, err := qb.tx.Exec(ctx, "UPDATE scraped_items SET studio_id = null WHERE studio_id = ?", id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return qb.destroyExisting(ctx, []int{id})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user