You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
// remove unreferenced tags created due to an error
1969
+
ID:"0079-remove-unreferenced-tags",
1970
+
Migrate:func(tx*gorm.DB)error {
1971
+
// update tag counts
1972
+
tasks.CountTags()
1973
+
1974
+
// check there are no Tags with a count of 0 that are in use, should not happen if CountTags is working properly,
1975
+
// but don't want to risk a referential integrity issue
1976
+
typetagsInUsestruct {
1977
+
Cntint
1978
+
}
1979
+
varresulttagsInUse
1980
+
db.Raw("select count(*) as cnt from scene_tags st join scenes s on s.id=st.scene_id join tags t on t.id=st.tag_id where t.`count` = 0 and s.deleted_at is NULL").Scan(&result)
1981
+
ifresult.Cnt>0 {
1982
+
// this should never happen, but not deleting unreferenced tags will not break the system, so don't fail the migration, flag it to retry