stash/pkg/sqlite/tables.go

265 lines
6.4 KiB
Go
Raw Normal View History

File storage rewrite (#2676) * Restructure data layer part 2 (#2599) * Refactor and separate image model * Refactor image query builder * Handle relationships in image query builder * Remove relationship management methods * Refactor gallery model/query builder * Add scenes to gallery model * Convert scene model * Refactor scene models * Remove unused methods * Add unit tests for gallery * Add image tests * Add scene tests * Convert unnecessary scene value pointers to values * Convert unnecessary pointer values to values * Refactor scene partial * Add scene partial tests * Refactor ImagePartial * Add image partial tests * Refactor gallery partial update * Add partial gallery update tests * Use zero/null package for null values * Add files and scan system * Add sqlite implementation for files/folders * Add unit tests for files/folders * Image refactors * Update image data layer * Refactor gallery model and creation * Refactor scene model * Refactor scenes * Don't set title from filename * Allow galleries to freely add/remove images * Add multiple scene file support to graphql and UI * Add multiple file support for images in graphql/UI * Add multiple file for galleries in graphql/UI * Remove use of some deprecated fields * Remove scene path usage * Remove gallery path usage * Remove path from image * Move funscript to video file * Refactor caption detection * Migrate existing data * Add post commit/rollback hook system * Lint. Comment out import/export tests * Add WithDatabase read only wrapper * Prepend tasks to list * Add 32 pre-migration * Add warnings in release and migration notes
2022-07-13 06:30:54 +00:00
package sqlite
import (
"github.com/doug-martin/goqu/v9"
_ "github.com/doug-martin/goqu/v9/dialect/sqlite3"
)
var dialect = goqu.Dialect("sqlite3")
var (
galleriesImagesJoinTable = goqu.T(galleriesImagesTable)
imagesTagsJoinTable = goqu.T(imagesTagsTable)
performersImagesJoinTable = goqu.T(performersImagesTable)
imagesFilesJoinTable = goqu.T(imagesFilesTable)
galleriesFilesJoinTable = goqu.T(galleriesFilesTable)
galleriesTagsJoinTable = goqu.T(galleriesTagsTable)
performersGalleriesJoinTable = goqu.T(performersGalleriesTable)
galleriesScenesJoinTable = goqu.T(galleriesScenesTable)
scenesFilesJoinTable = goqu.T(scenesFilesTable)
scenesTagsJoinTable = goqu.T(scenesTagsTable)
scenesPerformersJoinTable = goqu.T(performersScenesTable)
scenesStashIDsJoinTable = goqu.T("scene_stash_ids")
scenesMoviesJoinTable = goqu.T(moviesScenesTable)
scenesURLsJoinTable = goqu.T(scenesURLsTable)
performersAliasesJoinTable = goqu.T(performersAliasesTable)
performersTagsJoinTable = goqu.T(performersTagsTable)
performersStashIDsJoinTable = goqu.T("performer_stash_ids")
File storage rewrite (#2676) * Restructure data layer part 2 (#2599) * Refactor and separate image model * Refactor image query builder * Handle relationships in image query builder * Remove relationship management methods * Refactor gallery model/query builder * Add scenes to gallery model * Convert scene model * Refactor scene models * Remove unused methods * Add unit tests for gallery * Add image tests * Add scene tests * Convert unnecessary scene value pointers to values * Convert unnecessary pointer values to values * Refactor scene partial * Add scene partial tests * Refactor ImagePartial * Add image partial tests * Refactor gallery partial update * Add partial gallery update tests * Use zero/null package for null values * Add files and scan system * Add sqlite implementation for files/folders * Add unit tests for files/folders * Image refactors * Update image data layer * Refactor gallery model and creation * Refactor scene model * Refactor scenes * Don't set title from filename * Allow galleries to freely add/remove images * Add multiple scene file support to graphql and UI * Add multiple file support for images in graphql/UI * Add multiple file for galleries in graphql/UI * Remove use of some deprecated fields * Remove scene path usage * Remove gallery path usage * Remove path from image * Move funscript to video file * Refactor caption detection * Migrate existing data * Add post commit/rollback hook system * Lint. Comment out import/export tests * Add WithDatabase read only wrapper * Prepend tasks to list * Add 32 pre-migration * Add warnings in release and migration notes
2022-07-13 06:30:54 +00:00
)
var (
imageTableMgr = &table{
table: goqu.T(imageTable),
idColumn: goqu.T(imageTable).Col(idColumn),
}
imagesFilesTableMgr = &relatedFilesTable{
table: table{
table: imagesFilesJoinTable,
idColumn: imagesFilesJoinTable.Col(imageIDColumn),
},
}
imageGalleriesTableMgr = &joinTable{
table: table{
table: galleriesImagesJoinTable,
idColumn: galleriesImagesJoinTable.Col(imageIDColumn),
},
fkColumn: galleriesImagesJoinTable.Col(galleryIDColumn),
}
imagesTagsTableMgr = &joinTable{
table: table{
table: imagesTagsJoinTable,
idColumn: imagesTagsJoinTable.Col(imageIDColumn),
},
fkColumn: imagesTagsJoinTable.Col(tagIDColumn),
}
imagesPerformersTableMgr = &joinTable{
table: table{
table: performersImagesJoinTable,
idColumn: performersImagesJoinTable.Col(imageIDColumn),
},
fkColumn: performersImagesJoinTable.Col(performerIDColumn),
}
)
var (
galleryTableMgr = &table{
table: goqu.T(galleryTable),
idColumn: goqu.T(galleryTable).Col(idColumn),
}
galleriesFilesTableMgr = &relatedFilesTable{
table: table{
table: galleriesFilesJoinTable,
idColumn: galleriesFilesJoinTable.Col(galleryIDColumn),
},
}
galleriesTagsTableMgr = &joinTable{
table: table{
table: galleriesTagsJoinTable,
idColumn: galleriesTagsJoinTable.Col(galleryIDColumn),
},
fkColumn: galleriesTagsJoinTable.Col(tagIDColumn),
}
galleriesPerformersTableMgr = &joinTable{
table: table{
table: performersGalleriesJoinTable,
idColumn: performersGalleriesJoinTable.Col(galleryIDColumn),
},
fkColumn: performersGalleriesJoinTable.Col(performerIDColumn),
}
galleriesScenesTableMgr = &joinTable{
table: table{
table: galleriesScenesJoinTable,
idColumn: galleriesScenesJoinTable.Col(galleryIDColumn),
},
fkColumn: galleriesScenesJoinTable.Col(sceneIDColumn),
}
galleriesChaptersTableMgr = &table{
table: goqu.T(galleriesChaptersTable),
idColumn: goqu.T(galleriesChaptersTable).Col(idColumn),
}
File storage rewrite (#2676) * Restructure data layer part 2 (#2599) * Refactor and separate image model * Refactor image query builder * Handle relationships in image query builder * Remove relationship management methods * Refactor gallery model/query builder * Add scenes to gallery model * Convert scene model * Refactor scene models * Remove unused methods * Add unit tests for gallery * Add image tests * Add scene tests * Convert unnecessary scene value pointers to values * Convert unnecessary pointer values to values * Refactor scene partial * Add scene partial tests * Refactor ImagePartial * Add image partial tests * Refactor gallery partial update * Add partial gallery update tests * Use zero/null package for null values * Add files and scan system * Add sqlite implementation for files/folders * Add unit tests for files/folders * Image refactors * Update image data layer * Refactor gallery model and creation * Refactor scene model * Refactor scenes * Don't set title from filename * Allow galleries to freely add/remove images * Add multiple scene file support to graphql and UI * Add multiple file support for images in graphql/UI * Add multiple file for galleries in graphql/UI * Remove use of some deprecated fields * Remove scene path usage * Remove gallery path usage * Remove path from image * Move funscript to video file * Refactor caption detection * Migrate existing data * Add post commit/rollback hook system * Lint. Comment out import/export tests * Add WithDatabase read only wrapper * Prepend tasks to list * Add 32 pre-migration * Add warnings in release and migration notes
2022-07-13 06:30:54 +00:00
)
var (
sceneTableMgr = &table{
table: goqu.T(sceneTable),
idColumn: goqu.T(sceneTable).Col(idColumn),
}
2023-03-15 22:07:33 +00:00
sceneMarkerTableMgr = &table{
table: goqu.T(sceneMarkerTable),
idColumn: goqu.T(sceneMarkerTable).Col(idColumn),
}
File storage rewrite (#2676) * Restructure data layer part 2 (#2599) * Refactor and separate image model * Refactor image query builder * Handle relationships in image query builder * Remove relationship management methods * Refactor gallery model/query builder * Add scenes to gallery model * Convert scene model * Refactor scene models * Remove unused methods * Add unit tests for gallery * Add image tests * Add scene tests * Convert unnecessary scene value pointers to values * Convert unnecessary pointer values to values * Refactor scene partial * Add scene partial tests * Refactor ImagePartial * Add image partial tests * Refactor gallery partial update * Add partial gallery update tests * Use zero/null package for null values * Add files and scan system * Add sqlite implementation for files/folders * Add unit tests for files/folders * Image refactors * Update image data layer * Refactor gallery model and creation * Refactor scene model * Refactor scenes * Don't set title from filename * Allow galleries to freely add/remove images * Add multiple scene file support to graphql and UI * Add multiple file support for images in graphql/UI * Add multiple file for galleries in graphql/UI * Remove use of some deprecated fields * Remove scene path usage * Remove gallery path usage * Remove path from image * Move funscript to video file * Refactor caption detection * Migrate existing data * Add post commit/rollback hook system * Lint. Comment out import/export tests * Add WithDatabase read only wrapper * Prepend tasks to list * Add 32 pre-migration * Add warnings in release and migration notes
2022-07-13 06:30:54 +00:00
scenesFilesTableMgr = &relatedFilesTable{
table: table{
table: scenesFilesJoinTable,
idColumn: scenesFilesJoinTable.Col(sceneIDColumn),
},
}
scenesTagsTableMgr = &joinTable{
table: table{
table: scenesTagsJoinTable,
idColumn: scenesTagsJoinTable.Col(sceneIDColumn),
},
fkColumn: scenesTagsJoinTable.Col(tagIDColumn),
}
scenesPerformersTableMgr = &joinTable{
table: table{
table: scenesPerformersJoinTable,
idColumn: scenesPerformersJoinTable.Col(sceneIDColumn),
},
fkColumn: scenesPerformersJoinTable.Col(performerIDColumn),
}
scenesGalleriesTableMgr = galleriesScenesTableMgr.invert()
scenesStashIDsTableMgr = &stashIDTable{
table: table{
table: scenesStashIDsJoinTable,
idColumn: scenesStashIDsJoinTable.Col(sceneIDColumn),
},
}
scenesMoviesTableMgr = &scenesMoviesTable{
table: table{
table: scenesMoviesJoinTable,
idColumn: scenesMoviesJoinTable.Col(sceneIDColumn),
},
}
scenesURLsTableMgr = &orderedValueTable[string]{
table: table{
table: scenesURLsJoinTable,
idColumn: scenesURLsJoinTable.Col(sceneIDColumn),
},
valueColumn: scenesURLsJoinTable.Col(sceneURLColumn),
}
File storage rewrite (#2676) * Restructure data layer part 2 (#2599) * Refactor and separate image model * Refactor image query builder * Handle relationships in image query builder * Remove relationship management methods * Refactor gallery model/query builder * Add scenes to gallery model * Convert scene model * Refactor scene models * Remove unused methods * Add unit tests for gallery * Add image tests * Add scene tests * Convert unnecessary scene value pointers to values * Convert unnecessary pointer values to values * Refactor scene partial * Add scene partial tests * Refactor ImagePartial * Add image partial tests * Refactor gallery partial update * Add partial gallery update tests * Use zero/null package for null values * Add files and scan system * Add sqlite implementation for files/folders * Add unit tests for files/folders * Image refactors * Update image data layer * Refactor gallery model and creation * Refactor scene model * Refactor scenes * Don't set title from filename * Allow galleries to freely add/remove images * Add multiple scene file support to graphql and UI * Add multiple file support for images in graphql/UI * Add multiple file for galleries in graphql/UI * Remove use of some deprecated fields * Remove scene path usage * Remove gallery path usage * Remove path from image * Move funscript to video file * Refactor caption detection * Migrate existing data * Add post commit/rollback hook system * Lint. Comment out import/export tests * Add WithDatabase read only wrapper * Prepend tasks to list * Add 32 pre-migration * Add warnings in release and migration notes
2022-07-13 06:30:54 +00:00
)
var (
fileTableMgr = &table{
table: goqu.T(fileTable),
idColumn: goqu.T(fileTable).Col(idColumn),
}
videoFileTableMgr = &table{
table: goqu.T(videoFileTable),
idColumn: goqu.T(videoFileTable).Col(fileIDColumn),
}
imageFileTableMgr = &table{
table: goqu.T(imageFileTable),
idColumn: goqu.T(imageFileTable).Col(fileIDColumn),
}
folderTableMgr = &table{
table: goqu.T(folderTable),
idColumn: goqu.T(folderTable).Col(idColumn),
}
fingerprintTableMgr = &table{
table: goqu.T(fingerprintTable),
idColumn: goqu.T(fingerprintTable).Col(idColumn),
}
)
var (
performerTableMgr = &table{
table: goqu.T(performerTable),
idColumn: goqu.T(performerTable).Col(idColumn),
}
performersAliasesTableMgr = &stringTable{
table: table{
table: performersAliasesJoinTable,
idColumn: performersAliasesJoinTable.Col(performerIDColumn),
},
stringColumn: performersAliasesJoinTable.Col(performerAliasColumn),
}
performersTagsTableMgr = &joinTable{
table: table{
table: performersTagsJoinTable,
idColumn: performersTagsJoinTable.Col(performerIDColumn),
},
fkColumn: performersTagsJoinTable.Col(tagIDColumn),
}
performersStashIDsTableMgr = &stashIDTable{
table: table{
table: performersStashIDsJoinTable,
idColumn: performersStashIDsJoinTable.Col(performerIDColumn),
},
}
)
var (
studioTableMgr = &table{
table: goqu.T(studioTable),
idColumn: goqu.T(studioTable).Col(idColumn),
}
)
var (
tagTableMgr = &table{
table: goqu.T(tagTable),
idColumn: goqu.T(tagTable).Col(idColumn),
}
)
var (
movieTableMgr = &table{
table: goqu.T(movieTable),
idColumn: goqu.T(movieTable).Col(idColumn),
}
)
var (
blobTableMgr = &table{
table: goqu.T(blobTable),
idColumn: goqu.T(blobTable).Col(blobChecksumColumn),
}
)
var (
savedFilterTableMgr = &table{
table: goqu.T(savedFilterTable),
idColumn: goqu.T(savedFilterTable).Col(idColumn),
}
)