mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Rename movie tables to groups in database schema (#5082)
* Rename movie tables to groups * Correct index name * Rename synopsis to description in schema
This commit is contained in:
@@ -17,15 +17,15 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
groupTable = "movies"
|
||||
groupIDColumn = "movie_id"
|
||||
groupTable = "groups"
|
||||
groupIDColumn = "group_id"
|
||||
|
||||
groupFrontImageBlobColumn = "front_image_blob"
|
||||
groupBackImageBlobColumn = "back_image_blob"
|
||||
|
||||
groupsTagsTable = "movies_tags"
|
||||
groupsTagsTable = "groups_tags"
|
||||
|
||||
groupURLsTable = "movie_urls"
|
||||
groupURLsTable = "group_urls"
|
||||
groupURLColumn = "url"
|
||||
)
|
||||
|
||||
@@ -36,12 +36,12 @@ type groupRow struct {
|
||||
Duration null.Int `db:"duration"`
|
||||
Date NullDate `db:"date"`
|
||||
// expressed as 1-100
|
||||
Rating null.Int `db:"rating"`
|
||||
StudioID null.Int `db:"studio_id,omitempty"`
|
||||
Director zero.String `db:"director"`
|
||||
Synopsis zero.String `db:"synopsis"`
|
||||
CreatedAt Timestamp `db:"created_at"`
|
||||
UpdatedAt Timestamp `db:"updated_at"`
|
||||
Rating null.Int `db:"rating"`
|
||||
StudioID null.Int `db:"studio_id,omitempty"`
|
||||
Director zero.String `db:"director"`
|
||||
Description zero.String `db:"description"`
|
||||
CreatedAt Timestamp `db:"created_at"`
|
||||
UpdatedAt Timestamp `db:"updated_at"`
|
||||
|
||||
// not used in resolutions or updates
|
||||
FrontImageBlob zero.String `db:"front_image_blob"`
|
||||
@@ -57,7 +57,7 @@ func (r *groupRow) fromGroup(o models.Group) {
|
||||
r.Rating = intFromPtr(o.Rating)
|
||||
r.StudioID = intFromPtr(o.StudioID)
|
||||
r.Director = zero.StringFrom(o.Director)
|
||||
r.Synopsis = zero.StringFrom(o.Synopsis)
|
||||
r.Description = zero.StringFrom(o.Synopsis)
|
||||
r.CreatedAt = Timestamp{Timestamp: o.CreatedAt}
|
||||
r.UpdatedAt = Timestamp{Timestamp: o.UpdatedAt}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func (r *groupRow) resolve() *models.Group {
|
||||
Rating: nullIntPtr(r.Rating),
|
||||
StudioID: nullIntPtr(r.StudioID),
|
||||
Director: r.Director.String,
|
||||
Synopsis: r.Synopsis.String,
|
||||
Synopsis: r.Description.String,
|
||||
CreatedAt: r.CreatedAt.Timestamp,
|
||||
UpdatedAt: r.UpdatedAt.Timestamp,
|
||||
}
|
||||
@@ -92,7 +92,7 @@ func (r *groupRowRecord) fromPartial(o models.GroupPartial) {
|
||||
r.setNullInt("rating", o.Rating)
|
||||
r.setNullInt("studio_id", o.StudioID)
|
||||
r.setNullString("director", o.Director)
|
||||
r.setNullString("synopsis", o.Synopsis)
|
||||
r.setNullString("description", o.Synopsis)
|
||||
r.setTimestamp("created_at", o.CreatedAt)
|
||||
r.setTimestamp("updated_at", o.UpdatedAt)
|
||||
}
|
||||
@@ -330,7 +330,7 @@ func (qb *GroupStore) getMany(ctx context.Context, q *goqu.SelectDataset) ([]*mo
|
||||
}
|
||||
|
||||
func (qb *GroupStore) FindByName(ctx context.Context, name string, nocase bool) (*models.Group, error) {
|
||||
// query := "SELECT * FROM movies WHERE name = ?"
|
||||
// query := "SELECT * FROM groups WHERE name = ?"
|
||||
// if nocase {
|
||||
// query += " COLLATE NOCASE"
|
||||
// }
|
||||
@@ -350,7 +350,7 @@ func (qb *GroupStore) FindByName(ctx context.Context, name string, nocase bool)
|
||||
}
|
||||
|
||||
func (qb *GroupStore) FindByNames(ctx context.Context, names []string, nocase bool) ([]*models.Group, error) {
|
||||
// query := "SELECT * FROM movies WHERE name"
|
||||
// query := "SELECT * FROM groups WHERE name"
|
||||
// if nocase {
|
||||
// query += " COLLATE NOCASE"
|
||||
// }
|
||||
@@ -400,7 +400,7 @@ func (qb *GroupStore) makeQuery(ctx context.Context, groupFilter *models.GroupFi
|
||||
distinctIDs(&query, groupTable)
|
||||
|
||||
if q := findFilter.Q; q != nil && *q != "" {
|
||||
searchColumns := []string{"movies.name", "movies.aliases"}
|
||||
searchColumns := []string{"groups.name", "groups.aliases"}
|
||||
query.parseQueryString(searchColumns, *q)
|
||||
}
|
||||
|
||||
@@ -487,11 +487,11 @@ func (qb *GroupStore) getGroupSort(findFilter *models.FindFilterType) (string, e
|
||||
case "scenes_count": // generic getSort won't work for this
|
||||
sortQuery += getCountSort(groupTable, groupsScenesTable, groupIDColumn, direction)
|
||||
default:
|
||||
sortQuery += getSort(sort, direction, "movies")
|
||||
sortQuery += getSort(sort, direction, "groups")
|
||||
}
|
||||
|
||||
// Whatever the sorting, always use name/id as a final sort
|
||||
sortQuery += ", COALESCE(movies.name, movies.id) COLLATE NATURAL_CI ASC"
|
||||
sortQuery += ", COALESCE(groups.name, groups.id) COLLATE NATURAL_CI ASC"
|
||||
return sortQuery, nil
|
||||
}
|
||||
|
||||
@@ -551,10 +551,10 @@ func (qb *GroupStore) HasBackImage(ctx context.Context, groupID int) (bool, erro
|
||||
}
|
||||
|
||||
func (qb *GroupStore) FindByPerformerID(ctx context.Context, performerID int) ([]*models.Group, error) {
|
||||
query := `SELECT DISTINCT movies.*
|
||||
FROM movies
|
||||
INNER JOIN movies_scenes ON movies.id = movies_scenes.movie_id
|
||||
INNER JOIN performers_scenes ON performers_scenes.scene_id = movies_scenes.scene_id
|
||||
query := `SELECT DISTINCT groups.*
|
||||
FROM groups
|
||||
INNER JOIN groups_scenes ON groups.id = groups_scenes.group_id
|
||||
INNER JOIN performers_scenes ON performers_scenes.scene_id = groups_scenes.scene_id
|
||||
WHERE performers_scenes.performer_id = ?
|
||||
`
|
||||
args := []interface{}{performerID}
|
||||
@@ -562,9 +562,9 @@ WHERE performers_scenes.performer_id = ?
|
||||
}
|
||||
|
||||
func (qb *GroupStore) CountByPerformerID(ctx context.Context, performerID int) (int, error) {
|
||||
query := `SELECT COUNT(DISTINCT movies_scenes.movie_id) AS count
|
||||
FROM movies_scenes
|
||||
INNER JOIN performers_scenes ON performers_scenes.scene_id = movies_scenes.scene_id
|
||||
query := `SELECT COUNT(DISTINCT groups_scenes.group_id) AS count
|
||||
FROM groups_scenes
|
||||
INNER JOIN performers_scenes ON performers_scenes.scene_id = groups_scenes.scene_id
|
||||
WHERE performers_scenes.performer_id = ?
|
||||
`
|
||||
args := []interface{}{performerID}
|
||||
@@ -572,9 +572,9 @@ WHERE performers_scenes.performer_id = ?
|
||||
}
|
||||
|
||||
func (qb *GroupStore) FindByStudioID(ctx context.Context, studioID int) ([]*models.Group, error) {
|
||||
query := `SELECT movies.*
|
||||
FROM movies
|
||||
WHERE movies.studio_id = ?
|
||||
query := `SELECT groups.*
|
||||
FROM groups
|
||||
WHERE groups.studio_id = ?
|
||||
`
|
||||
args := []interface{}{studioID}
|
||||
return qb.queryGroups(ctx, query, args)
|
||||
@@ -582,8 +582,8 @@ WHERE movies.studio_id = ?
|
||||
|
||||
func (qb *GroupStore) CountByStudioID(ctx context.Context, studioID int) (int, error) {
|
||||
query := `SELECT COUNT(1) AS count
|
||||
FROM movies
|
||||
WHERE movies.studio_id = ?
|
||||
FROM groups
|
||||
WHERE groups.studio_id = ?
|
||||
`
|
||||
args := []interface{}{studioID}
|
||||
return groupRepository.runCountQuery(ctx, query, args)
|
||||
|
||||
Reference in New Issue
Block a user