feat(db): drop the acquisition and Discover tables
release / web (push) Successful in 1m22s
release / go (push) Successful in 1m49s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 4m10s
release / android (push) Successful in 4m27s
release / Build signed APK (push) Successful in 4m56s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 22s
release / Verify release artifacts (tag releases only) (push) Skipped

Migration 105 removes the tables the acquisition and Discover features
kept, and users.auto_approve_requests. Before library_album_matches goes,
an album with no release-group MBID takes the one its match listed.
Tables drop without CASCADE, in reference order, so a reference from a
table that stays stops the migration. The down migration refuses: the
data is gone, and a backup from before it is the way back.

The backup table list, the test reset list and the duplicate and user
queries follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 00:20:22 -05:00
co-authored by Claude Opus 5.5
parent 741c748135
commit 8c6bbac48d
13 changed files with 84 additions and 387 deletions
-1
View File
@@ -38,7 +38,6 @@ const (
ActionCreateUserAdmin Action = "create_user_admin" ActionCreateUserAdmin Action = "create_user_admin"
ActionDeleteUser Action = "delete_user" ActionDeleteUser Action = "delete_user"
ActionPasswordResetAdmin Action = "password_reset_admin" ActionPasswordResetAdmin Action = "password_reset_admin"
ActionAutoApproveToggle Action = "auto_approve_toggle"
// Credentials. // Credentials.
ActionPasswordChangeSelf Action = "password_change_self" ActionPasswordChangeSelf Action = "password_change_self"
-1
View File
@@ -163,7 +163,6 @@ func TestWrite_AllActionConstantsArePersisted(t *testing.T) {
audit.ActionCreateUserAdmin, audit.ActionCreateUserAdmin,
audit.ActionDeleteUser, audit.ActionDeleteUser,
audit.ActionPasswordResetAdmin, audit.ActionPasswordResetAdmin,
audit.ActionAutoApproveToggle,
audit.ActionPasswordChangeSelf, audit.ActionPasswordChangeSelf,
audit.ActionTokenRegenerate, audit.ActionTokenRegenerate,
audit.ActionForgotPasswordInit, audit.ActionForgotPasswordInit,
+1 -1
View File
@@ -17,7 +17,7 @@ func sample() Contents {
Tables: map[string][][]byte{ Tables: map[string][][]byte{
"users": {[]byte(`{"id":"u1","username":"ada"}`), []byte(`{"id":"u2","username":"bo"}`)}, "users": {[]byte(`{"id":"u1","username":"ada"}`), []byte(`{"id":"u2","username":"bo"}`)},
"tracks": {[]byte(`{"file_path":"/music/a.flac","id":"t1"}`)}, "tracks": {[]byte(`{"file_path":"/music/a.flac","id":"t1"}`)},
"wants": {}, "playlists": {},
}, },
} }
} }
+1 -3
View File
@@ -153,8 +153,6 @@ func TestARestoredInstanceHoldsWhatTheBackupHeld_Integration(t *testing.T) {
playlist := mustID(t, pool, `INSERT INTO playlists (user_id, name) VALUES ($1, 'Mine') RETURNING id::text`, user) playlist := mustID(t, pool, `INSERT INTO playlists (user_id, name) VALUES ($1, 'Mine') RETURNING id::text`, user)
mustExec(t, pool, `INSERT INTO playlist_tracks (playlist_id, position, track_id, title, artist_name, album_title, duration_sec) mustExec(t, pool, `INSERT INTO playlist_tracks (playlist_id, position, track_id, title, artist_name, album_title, duration_sec)
VALUES ($1, 0, $2, 'Track', 'Artist', 'Album', 180)`, playlist, track) VALUES ($1, 0, $2, 'Track', 'Artist', 'Album', 180)`, playlist, track)
mustExec(t, pool, `INSERT INTO follows (artist_mbid, artist_name, profile_id, followed_by)
SELECT 'mbid-1', 'Artist', id, $1 FROM release_type_profiles WHERE is_default`, user)
mustExec(t, pool, `INSERT INTO library_changes (entity_type, entity_id, op) VALUES ('track', $1, 'upsert')`, track) mustExec(t, pool, `INSERT INTO library_changes (entity_type, entity_id, op) VALUES ('track', $1, 'upsert')`, track)
first, err := backup.Snapshot(ctx, pool) first, err := backup.Snapshot(ctx, pool)
@@ -174,7 +172,7 @@ func TestARestoredInstanceHoldsWhatTheBackupHeld_Integration(t *testing.T) {
} }
} }
} }
for _, tbl := range []string{"users", "tracks", "play_events", "general_likes", "playlist_tracks", "follows", "library_changes"} { for _, tbl := range []string{"users", "tracks", "play_events", "general_likes", "playlist_tracks", "library_changes"} {
if len(first.Tables[tbl]) == 0 { if len(first.Tables[tbl]) == 0 {
t.Errorf("the backup holds no %s", tbl) t.Errorf("the backup holds no %s", tbl)
} }
+3 -26
View File
@@ -2,8 +2,7 @@
// Lines, one table at a time, and loads it back into an empty instance. // Lines, one table at a time, and loads it back into an empty instance.
// //
// What goes in is everything a person made or decided: accounts, likes, play // What goes in is everything a person made or decided: accounts, likes, play
// and skip history, playlists, follows, wants and requests, download history, // and skip history, playlists, admin decisions, and settings. What stays out is everything the restored
// admin decisions, and settings. What stays out is everything the restored
// server rebuilds by itself: what it computes from the music files, what it // server rebuilds by itself: what it computes from the music files, what it
// fetches again from MusicBrainz, ListenBrainz and the other providers, and // fetches again from MusicBrainz, ListenBrainz and the other providers, and
// logs of past runs. Excluded says why for each, and the coverage test fails // logs of past runs. Excluded says why for each, and the coverage test fails
@@ -50,24 +49,10 @@ var Tables = []Table{
{Name: "cover_art_sources_meta"}, {Name: "cover_art_sources_meta"},
{Name: "tag_provider_settings", Omit: []string{"api_key"}}, {Name: "tag_provider_settings", Omit: []string{"api_key"}},
{Name: "tag_sources_meta"}, {Name: "tag_sources_meta"},
{Name: "acquisition_services", Omit: []string{"api_key", "password"}},
{Name: "acquisition_settings"},
{Name: "reacquisition_settings"},
{Name: "discover_tuning"},
{Name: "taste_tuning"}, {Name: "taste_tuning"},
{Name: "recommendation_weight_profiles"}, {Name: "recommendation_weight_profiles"},
{Name: "recommendation_tuning_audit"}, {Name: "recommendation_tuning_audit"},
// Follows, wants, requests and downloads.
{Name: "release_type_profiles"},
{Name: "follows"},
{Name: "follow_seen_groups"},
{Name: "wants"},
{Name: "grabs"},
{Name: "download_interventions"},
{Name: "release_blocks"},
{Name: "requests"},
// Listening history and likes. // Listening history and likes.
{Name: "play_sessions"}, {Name: "play_sessions"},
{Name: "play_events"}, {Name: "play_events"},
@@ -97,13 +82,11 @@ var Tables = []Table{
{Name: "user_notification_prefs"}, {Name: "user_notification_prefs"},
{Name: "user_notification_email_state"}, {Name: "user_notification_email_state"},
{Name: "user_notifications"}, {Name: "user_notifications"},
{Name: "suggestion_snoozes"},
{Name: "quarantine"}, {Name: "quarantine"},
{Name: "quarantine_actions"}, {Name: "quarantine_actions"},
// Admin decisions: an album taken off the wanted listing stays off, and a // Admin decisions: a dismissed duplicate group stays dismissed when the
// dismissed duplicate group stays dismissed when the sweep finds it again. // sweep finds it again.
{Name: "library_album_matches"},
{Name: "duplicate_sweeps"}, {Name: "duplicate_sweeps"},
{Name: "duplicate_groups"}, {Name: "duplicate_groups"},
{Name: "duplicate_group_members"}, {Name: "duplicate_group_members"},
@@ -128,23 +111,17 @@ var Excluded = map[string]string{
"album_loudness": "computed from the music files", "album_loudness": "computed from the music files",
"track_acoustid_lookups": "looked up again from each track's fingerprint", "track_acoustid_lookups": "looked up again from each track's fingerprint",
"track_tags": "fetched again from the tag providers", "track_tags": "fetched again from the tag providers",
"candidate_artist_tags": "fetched again from the tag providers",
"candidate_artist_tag_state": "fetched again from the tag providers",
"mb_artists": "MusicBrainz cache, fetched again",
"mb_release_groups": "MusicBrainz cache, fetched again", "mb_release_groups": "MusicBrainz cache, fetched again",
"mb_releases": "MusicBrainz cache, fetched again", "mb_releases": "MusicBrainz cache, fetched again",
"mb_release_tracks": "MusicBrainz cache, fetched again", "mb_release_tracks": "MusicBrainz cache, fetched again",
"mb_artist_release_groups": "MusicBrainz cache, fetched again",
"listenbrainz_similar_recordings": "similarity, fetched again from ListenBrainz", "listenbrainz_similar_recordings": "similarity, fetched again from ListenBrainz",
"track_similarity": "similarity, fetched again from the similarity providers", "track_similarity": "similarity, fetched again from the similarity providers",
"track_similarity_fetches": "similarity, fetched again from the similarity providers", "track_similarity_fetches": "similarity, fetched again from the similarity providers",
"artist_similarity": "similarity, fetched again from the similarity providers", "artist_similarity": "similarity, fetched again from the similarity providers",
"artist_similarity_fetches": "similarity, fetched again from the similarity providers", "artist_similarity_fetches": "similarity, fetched again from the similarity providers",
"artist_similarity_unmatched": "similarity, fetched again from the similarity providers",
"want_candidates": "the last search's results; the next search finds them again",
"scan_runs": "a log of past library scans", "scan_runs": "a log of past library scans",
"diagnostic_events": "debug-mode diagnostics", "diagnostic_events": "debug-mode diagnostics",
+1 -2
View File
@@ -316,7 +316,7 @@ SELECT g.id AS group_id,
AND t.track_number IS NOT NULL AND t.track_number IS NOT NULL
AND o.disc_number IS NOT DISTINCT FROM t.disc_number AND o.disc_number IS NOT DISTINCT FROM t.disc_number
AND o.track_number = t.track_number)::boolean AS position_clash, AND o.track_number = t.track_number)::boolean AS position_clash,
COALESCE(NULLIF(al.release_group_mbid, ''), lam.release_group_mbid, '')::text AS release_group_mbid, COALESCE(al.release_group_mbid, '')::text AS release_group_mbid,
l.state AS acoustid_state, l.state AS acoustid_state,
l.recording_mbid AS acoustid_recording l.recording_mbid AS acoustid_recording
FROM duplicate_groups g FROM duplicate_groups g
@@ -324,7 +324,6 @@ SELECT g.id AS group_id,
JOIN tracks t ON t.id = m.track_id JOIN tracks t ON t.id = m.track_id
JOIN artists ON artists.id = t.artist_id JOIN artists ON artists.id = t.artist_id
JOIN albums al ON al.id = t.album_id JOIN albums al ON al.id = t.album_id
LEFT JOIN library_album_matches lam ON lam.album_id = t.album_id AND lam.outcome = 'listed'
LEFT JOIN track_acoustid_lookups l ON l.track_id = t.id LEFT JOIN track_acoustid_lookups l ON l.track_id = t.id
WHERE g.status = 'pending' WHERE g.status = 'pending'
AND t.missing_since IS NULL AND t.missing_since IS NULL
-271
View File
@@ -196,46 +196,6 @@ type AcoustidSetting struct {
UpdatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz
} }
type AcquisitionService struct {
Code string
Kind string
Protocol string
Label string
Enabled bool
BaseUrl string
ApiKey string
Username string
Password string
Category string
TimeoutMs int32
ServesSearch bool
ServesDownloads bool
ServesEnrichment bool
LocalPath string
RemotePath string
SearchesPerHour int32
CreatedAt pgtype.Timestamptz
UpdatedAt pgtype.Timestamptz
}
type AcquisitionSetting struct {
ID bool
AutoGrab bool
SearchIntervalHours int32
AllowedQualities []string
LastPassAt pgtype.Timestamptz
LastPass []byte
UpdatedAt pgtype.Timestamptz
ImportRoot string
SeedRatio float32
SeedDays int32
StallHours int32
LibraryListingStartedAt pgtype.Timestamptz
LibraryListedAt pgtype.Timestamptz
LibraryUnlisted int32
UpgradeUntil string
}
type Album struct { type Album struct {
ID pgtype.UUID ID pgtype.UUID
Title string Title string
@@ -289,15 +249,6 @@ type ArtistSimilarityFetch struct {
Returned int32 Returned int32
} }
type ArtistSimilarityUnmatched struct {
SeedArtistID pgtype.UUID
CandidateMbid string
CandidateName string
Score float64
Source string
FetchedAt pgtype.Timestamptz
}
type AuditLog struct { type AuditLog struct {
ID pgtype.UUID ID pgtype.UUID
ActorID pgtype.UUID ActorID pgtype.UUID
@@ -345,19 +296,6 @@ type BackupSetting struct {
IncludeMusic bool IncludeMusic bool
} }
type CandidateArtistTag struct {
CandidateMbid string
Tag string
Weight float64
}
type CandidateArtistTagState struct {
CandidateMbid string
TagSource string
TagSourcesVersion int32
UpdatedAt pgtype.Timestamptz
}
type ContextualLike struct { type ContextualLike struct {
ID pgtype.UUID ID pgtype.UUID
UserID pgtype.UUID UserID pgtype.UUID
@@ -395,30 +333,6 @@ type DiagnosticEvent struct {
ReceivedAt pgtype.Timestamptz ReceivedAt pgtype.Timestamptz
} }
type DiscoverTuning struct {
Singleton bool
TagOverlapWeight float64
SnoozeDays float64
UpdatedAt pgtype.Timestamptz
}
type DownloadIntervention struct {
ID pgtype.UUID
Client string
InfoHash string
GrabID pgtype.UUID
Name string
Trigger string
Action string
Outcome string
Detail string
Observations int32
Remediations int32
FirstSeen pgtype.Timestamptz
LastSeen pgtype.Timestamptz
SettledAt pgtype.Timestamptz
}
type DuplicateGroup struct { type DuplicateGroup struct {
ID pgtype.UUID ID pgtype.UUID
MemberKey string MemberKey string
@@ -459,24 +373,6 @@ type FingerprintSetting struct {
AutoResolve bool AutoResolve bool
} }
type Follow struct {
ArtistMbid string
ArtistName string
ProfileID pgtype.UUID
FollowedBy pgtype.UUID
FollowedAt pgtype.Timestamptz
BaselineAt pgtype.Timestamptz
WantExisting bool
CheckedAt pgtype.Timestamptz
UpdatedAt pgtype.Timestamptz
}
type FollowSeenGroup struct {
ArtistMbid string
ReleaseGroupMbid string
SeenAt pgtype.Timestamptz
}
type GeneralLike struct { type GeneralLike struct {
UserID pgtype.UUID UserID pgtype.UUID
TrackID pgtype.UUID TrackID pgtype.UUID
@@ -495,49 +391,6 @@ type GeneralLikesArtist struct {
LikedAt pgtype.Timestamptz LikedAt pgtype.Timestamptz
} }
type Grab struct {
ID pgtype.UUID
WantID pgtype.UUID
InfoHash string
Name string
Key string
Indexer string
Source string
Client string
SavePath string
Quality string
Origin string
Forced bool
GrabbedBy pgtype.UUID
GrabbedAt pgtype.Timestamptz
EndedAt pgtype.Timestamptz
EndReason string
EndDetail string
Progress float32
ImportState string
ImportReason string
ImportDetail []byte
ImportForced bool
ImportAttempts int32
ImportUpdatedAt pgtype.Timestamptz
ImportedAt pgtype.Timestamptz
ImportedFiles int32
Destination string
Seeding bool
Ratio float32
SeedReleasedAt pgtype.Timestamptz
}
type LibraryAlbumMatch struct {
AlbumID pgtype.UUID
Outcome string
Method string
ReleaseGroupMbid string
Detail string
DecidedAt pgtype.Timestamptz
Matcher int32
}
type LibraryChange struct { type LibraryChange struct {
ID int64 ID int64
EntityType string EntityType string
@@ -571,23 +424,6 @@ type LoudnessSetting struct {
LeveledCacheMb int32 LeveledCacheMb int32
} }
type MbArtist struct {
Mbid string
Name string
SortName string
Disambiguation string
ArtistType string
Country string
DiscographyRefreshedAt pgtype.Timestamptz
CreatedAt pgtype.Timestamptz
UpdatedAt pgtype.Timestamptz
}
type MbArtistReleaseGroup struct {
ArtistMbid string
ReleaseGroupMbid string
}
type MbRelease struct { type MbRelease struct {
Mbid string Mbid string
ReleaseGroupMbid string ReleaseGroupMbid string
@@ -735,13 +571,6 @@ type QuarantineAction struct {
CreatedAt pgtype.Timestamptz CreatedAt pgtype.Timestamptz
} }
type ReacquisitionSetting struct {
ID bool
Enabled bool
GraceHours int32
MaxPerPass int32
}
type RecommendationTuningAudit struct { type RecommendationTuningAudit struct {
ID int64 ID int64
ChangedAt pgtype.Timestamptz ChangedAt pgtype.Timestamptz
@@ -769,49 +598,6 @@ type RegistrationSetting struct {
Mode string Mode string
} }
type ReleaseBlock struct {
InfoHash string
Name string
Reason string
Detail string
WantID pgtype.UUID
BlockedBy pgtype.UUID
BlockedAt pgtype.Timestamptz
ExpiresAt pgtype.Timestamptz
}
type ReleaseTypeProfile struct {
ID pgtype.UUID
Name string
PrimaryTypes []string
SecondaryTypes []string
IsDefault bool
CreatedAt pgtype.Timestamptz
UpdatedAt pgtype.Timestamptz
}
type Request struct {
ID pgtype.UUID
UserID pgtype.UUID
Status RequestStatus
Kind RequestKind
ArtistMbid string
AlbumMbid *string
TrackMbid *string
ArtistName string
AlbumTitle *string
TrackTitle *string
DecidedAt pgtype.Timestamptz
DecidedBy pgtype.UUID
Notes *string
CompletedAt pgtype.Timestamptz
MatchedTrackID pgtype.UUID
MatchedAlbumID pgtype.UUID
MatchedArtistID pgtype.UUID
RequestedAt pgtype.Timestamptz
UpdatedAt pgtype.Timestamptz
}
type ScanRun struct { type ScanRun struct {
ID pgtype.UUID ID pgtype.UUID
StartedAt pgtype.Timestamptz StartedAt pgtype.Timestamptz
@@ -867,14 +653,6 @@ type SmtpConfig struct {
UpdatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz
} }
type SuggestionSnooze struct {
UserID pgtype.UUID
CandidateMbid string
CandidateName string
SnoozedUntil pgtype.Timestamptz
CreatedAt pgtype.Timestamptz
}
type SystemPlaylistRotationState struct { type SystemPlaylistRotationState struct {
UserID pgtype.UUID UserID pgtype.UUID
PlaylistKind string PlaylistKind string
@@ -1037,7 +815,6 @@ type User struct {
ListenbrainzToken *string ListenbrainzToken *string
ListenbrainzEnabled bool ListenbrainzEnabled bool
DisplayName *string DisplayName *string
AutoApproveRequests bool
Email *string Email *string
Timezone string Timezone string
TimezoneUpdatedAt pgtype.Timestamptz TimezoneUpdatedAt pgtype.Timestamptz
@@ -1092,54 +869,6 @@ type UserNotificationPref struct {
UpdatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz
} }
type Want struct {
ID pgtype.UUID
ReleaseGroupMbid string
ArtistMbid string
ArtistName string
Title string
PrimaryType string
FirstReleaseDate string
Reason string
AlbumID pgtype.UUID
CreatedBy pgtype.UUID
WantedAt pgtype.Timestamptz
FulfilledAt pgtype.Timestamptz
CreatedAt pgtype.Timestamptz
UpdatedAt pgtype.Timestamptz
SearchedAt pgtype.Timestamptz
SearchOutcome string
SearchConsidered int32
BestRelease string
BestVerdict string
SearchError string
Upgrade string
HeldTier string
HeldQuality string
UpgradeCheckedAt pgtype.Timestamptz
}
type WantCandidate struct {
WantID pgtype.UUID
Key string
Name string
InfoHash string
Indexer string
Source string
SizeBytes int64
Seeders int32
FilesCount int32
Format string
Quality string
Year int32
Verdict string
Reason string
Reasons []byte
FoldedFrom []string
Rank int32
SearchedAt pgtype.Timestamptz
}
type YouMightLikeAlbum struct { type YouMightLikeAlbum struct {
UserID pgtype.UUID UserID pgtype.UUID
AlbumID pgtype.UUID AlbumID pgtype.UUID
+11 -23
View File
@@ -54,7 +54,7 @@ func (q *Queries) CountUsers(ctx context.Context) (int64, error) {
const createUser = `-- name: CreateUser :one const createUser = `-- name: CreateUser :one
INSERT INTO users (username, password_hash, api_token_hash, is_admin, display_name) INSERT INTO users (username, password_hash, api_token_hash, is_admin, display_name)
VALUES ($1, $2, $3, $4, $5) VALUES ($1, $2, $3, $4, $5)
RETURNING id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, auto_approve_requests, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash RETURNING id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash
` `
type CreateUserParams struct { type CreateUserParams struct {
@@ -84,7 +84,6 @@ func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, e
&i.ListenbrainzToken, &i.ListenbrainzToken,
&i.ListenbrainzEnabled, &i.ListenbrainzEnabled,
&i.DisplayName, &i.DisplayName,
&i.AutoApproveRequests,
&i.Email, &i.Email,
&i.Timezone, &i.Timezone,
&i.TimezoneUpdatedAt, &i.TimezoneUpdatedAt,
@@ -97,7 +96,7 @@ func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, e
const createUserAdmin = `-- name: CreateUserAdmin :one const createUserAdmin = `-- name: CreateUserAdmin :one
INSERT INTO users (username, password_hash, api_token_hash, is_admin, display_name) INSERT INTO users (username, password_hash, api_token_hash, is_admin, display_name)
VALUES ($1, $2, $3, $4, $5) VALUES ($1, $2, $3, $4, $5)
RETURNING id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, auto_approve_requests, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash RETURNING id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash
` `
type CreateUserAdminParams struct { type CreateUserAdminParams struct {
@@ -130,7 +129,6 @@ func (q *Queries) CreateUserAdmin(ctx context.Context, arg CreateUserAdminParams
&i.ListenbrainzToken, &i.ListenbrainzToken,
&i.ListenbrainzEnabled, &i.ListenbrainzEnabled,
&i.DisplayName, &i.DisplayName,
&i.AutoApproveRequests,
&i.Email, &i.Email,
&i.Timezone, &i.Timezone,
&i.TimezoneUpdatedAt, &i.TimezoneUpdatedAt,
@@ -147,7 +145,7 @@ VALUES (
(SELECT NOT EXISTS (SELECT 1 FROM users)), (SELECT NOT EXISTS (SELECT 1 FROM users)),
$4 $4
) )
RETURNING id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, auto_approve_requests, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash RETURNING id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash
` `
type CreateUserFirstAdminRaceParams struct { type CreateUserFirstAdminRaceParams struct {
@@ -188,7 +186,6 @@ func (q *Queries) CreateUserFirstAdminRace(ctx context.Context, arg CreateUserFi
&i.ListenbrainzToken, &i.ListenbrainzToken,
&i.ListenbrainzEnabled, &i.ListenbrainzEnabled,
&i.DisplayName, &i.DisplayName,
&i.AutoApproveRequests,
&i.Email, &i.Email,
&i.Timezone, &i.Timezone,
&i.TimezoneUpdatedAt, &i.TimezoneUpdatedAt,
@@ -240,7 +237,7 @@ func (q *Queries) GetListenBrainzConfig(ctx context.Context, id pgtype.UUID) (Ge
} }
const getUserByAPITokenHash = `-- name: GetUserByAPITokenHash :one const getUserByAPITokenHash = `-- name: GetUserByAPITokenHash :one
SELECT id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, auto_approve_requests, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash FROM users WHERE api_token_hash = $1 SELECT id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash FROM users WHERE api_token_hash = $1
` `
func (q *Queries) GetUserByAPITokenHash(ctx context.Context, apiTokenHash string) (User, error) { func (q *Queries) GetUserByAPITokenHash(ctx context.Context, apiTokenHash string) (User, error) {
@@ -256,7 +253,6 @@ func (q *Queries) GetUserByAPITokenHash(ctx context.Context, apiTokenHash string
&i.ListenbrainzToken, &i.ListenbrainzToken,
&i.ListenbrainzEnabled, &i.ListenbrainzEnabled,
&i.DisplayName, &i.DisplayName,
&i.AutoApproveRequests,
&i.Email, &i.Email,
&i.Timezone, &i.Timezone,
&i.TimezoneUpdatedAt, &i.TimezoneUpdatedAt,
@@ -267,7 +263,7 @@ func (q *Queries) GetUserByAPITokenHash(ctx context.Context, apiTokenHash string
} }
const getUserByEmail = `-- name: GetUserByEmail :one const getUserByEmail = `-- name: GetUserByEmail :one
SELECT id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, auto_approve_requests, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash FROM users WHERE lower(email) = lower($1) SELECT id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash FROM users WHERE lower(email) = lower($1)
` `
// Used by forgot-password lookup. Lowercase comparison both sides // Used by forgot-password lookup. Lowercase comparison both sides
@@ -286,7 +282,6 @@ func (q *Queries) GetUserByEmail(ctx context.Context, lower string) (User, error
&i.ListenbrainzToken, &i.ListenbrainzToken,
&i.ListenbrainzEnabled, &i.ListenbrainzEnabled,
&i.DisplayName, &i.DisplayName,
&i.AutoApproveRequests,
&i.Email, &i.Email,
&i.Timezone, &i.Timezone,
&i.TimezoneUpdatedAt, &i.TimezoneUpdatedAt,
@@ -297,7 +292,7 @@ func (q *Queries) GetUserByEmail(ctx context.Context, lower string) (User, error
} }
const getUserByID = `-- name: GetUserByID :one const getUserByID = `-- name: GetUserByID :one
SELECT id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, auto_approve_requests, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash FROM users WHERE id = $1 SELECT id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash FROM users WHERE id = $1
` `
func (q *Queries) GetUserByID(ctx context.Context, id pgtype.UUID) (User, error) { func (q *Queries) GetUserByID(ctx context.Context, id pgtype.UUID) (User, error) {
@@ -313,7 +308,6 @@ func (q *Queries) GetUserByID(ctx context.Context, id pgtype.UUID) (User, error)
&i.ListenbrainzToken, &i.ListenbrainzToken,
&i.ListenbrainzEnabled, &i.ListenbrainzEnabled,
&i.DisplayName, &i.DisplayName,
&i.AutoApproveRequests,
&i.Email, &i.Email,
&i.Timezone, &i.Timezone,
&i.TimezoneUpdatedAt, &i.TimezoneUpdatedAt,
@@ -324,7 +318,7 @@ func (q *Queries) GetUserByID(ctx context.Context, id pgtype.UUID) (User, error)
} }
const getUserByUsername = `-- name: GetUserByUsername :one const getUserByUsername = `-- name: GetUserByUsername :one
SELECT id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, auto_approve_requests, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash FROM users WHERE username = $1 SELECT id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash FROM users WHERE username = $1
` `
func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User, error) { func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User, error) {
@@ -340,7 +334,6 @@ func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User,
&i.ListenbrainzToken, &i.ListenbrainzToken,
&i.ListenbrainzEnabled, &i.ListenbrainzEnabled,
&i.DisplayName, &i.DisplayName,
&i.AutoApproveRequests,
&i.Email, &i.Email,
&i.Timezone, &i.Timezone,
&i.TimezoneUpdatedAt, &i.TimezoneUpdatedAt,
@@ -419,7 +412,7 @@ func (q *Queries) ListUsernamesByIDs(ctx context.Context, dollar_1 []pgtype.UUID
} }
const listUsers = `-- name: ListUsers :many const listUsers = `-- name: ListUsers :many
SELECT id, username, display_name, is_admin, auto_approve_requests, SELECT id, username, display_name, is_admin,
debug_mode_enabled, created_at debug_mode_enabled, created_at
FROM users FROM users
ORDER BY created_at DESC ORDER BY created_at DESC
@@ -430,7 +423,6 @@ type ListUsersRow struct {
Username string Username string
DisplayName *string DisplayName *string
IsAdmin bool IsAdmin bool
AutoApproveRequests bool
DebugModeEnabled bool DebugModeEnabled bool
CreatedAt pgtype.Timestamptz CreatedAt pgtype.Timestamptz
} }
@@ -450,7 +442,6 @@ func (q *Queries) ListUsers(ctx context.Context) ([]ListUsersRow, error) {
&i.Username, &i.Username,
&i.DisplayName, &i.DisplayName,
&i.IsAdmin, &i.IsAdmin,
&i.AutoApproveRequests,
&i.DebugModeEnabled, &i.DebugModeEnabled,
&i.CreatedAt, &i.CreatedAt,
); err != nil { ); err != nil {
@@ -505,7 +496,7 @@ const setDebugMode = `-- name: SetDebugMode :one
UPDATE users UPDATE users
SET debug_mode_enabled = $2 SET debug_mode_enabled = $2
WHERE id = $1 WHERE id = $1
RETURNING id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, auto_approve_requests, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash RETURNING id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash
` `
type SetDebugModeParams struct { type SetDebugModeParams struct {
@@ -529,7 +520,6 @@ func (q *Queries) SetDebugMode(ctx context.Context, arg SetDebugModeParams) (Use
&i.ListenbrainzToken, &i.ListenbrainzToken,
&i.ListenbrainzEnabled, &i.ListenbrainzEnabled,
&i.DisplayName, &i.DisplayName,
&i.AutoApproveRequests,
&i.Email, &i.Email,
&i.Timezone, &i.Timezone,
&i.TimezoneUpdatedAt, &i.TimezoneUpdatedAt,
@@ -593,7 +583,7 @@ const updateUserAdmin = `-- name: UpdateUserAdmin :one
UPDATE users UPDATE users
SET is_admin = $2 SET is_admin = $2
WHERE id = $1 WHERE id = $1
RETURNING id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, auto_approve_requests, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash RETURNING id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash
` `
type UpdateUserAdminParams struct { type UpdateUserAdminParams struct {
@@ -616,7 +606,6 @@ func (q *Queries) UpdateUserAdmin(ctx context.Context, arg UpdateUserAdminParams
&i.ListenbrainzToken, &i.ListenbrainzToken,
&i.ListenbrainzEnabled, &i.ListenbrainzEnabled,
&i.DisplayName, &i.DisplayName,
&i.AutoApproveRequests,
&i.Email, &i.Email,
&i.Timezone, &i.Timezone,
&i.TimezoneUpdatedAt, &i.TimezoneUpdatedAt,
@@ -631,7 +620,7 @@ UPDATE users
SET display_name = $2, SET display_name = $2,
email = $3 email = $3
WHERE id = $1 WHERE id = $1
RETURNING id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, auto_approve_requests, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash RETURNING id, username, password_hash, is_admin, created_at, subsonic_password, listenbrainz_token, listenbrainz_enabled, display_name, email, timezone, timezone_updated_at, debug_mode_enabled, api_token_hash
` `
type UpdateUserProfileParams struct { type UpdateUserProfileParams struct {
@@ -655,7 +644,6 @@ func (q *Queries) UpdateUserProfile(ctx context.Context, arg UpdateUserProfilePa
&i.ListenbrainzToken, &i.ListenbrainzToken,
&i.ListenbrainzEnabled, &i.ListenbrainzEnabled,
&i.DisplayName, &i.DisplayName,
&i.AutoApproveRequests,
&i.Email, &i.Email,
&i.Timezone, &i.Timezone,
&i.TimezoneUpdatedAt, &i.TimezoneUpdatedAt,
@@ -0,0 +1,5 @@
-- The dropped tables held data this migration deleted, so there is nothing
-- to restore them from. Restore a backup taken before it instead.
DO $$ BEGIN
RAISE EXCEPTION 'migration 105 dropped data and cannot be undone; restore a backup taken before it';
END $$;
@@ -0,0 +1,44 @@
-- Minstrel plays and keeps the library it is given; it no longer finds
-- music. This drops the tables that served finding it (follows, wants,
-- searches, downloads, requests and their settings), the Discover tables,
-- the MusicBrainz artist catalogue only those used, and the per-user
-- auto-approve switch.
--
-- An album matched to a release group only through its wanted-listing
-- match keeps that release group: it is copied onto the album first, where
-- the duplicate resolver reads it.
UPDATE albums al
SET release_group_mbid = lam.release_group_mbid
FROM library_album_matches lam
WHERE lam.album_id = al.id
AND lam.outcome = 'listed'
AND COALESCE(lam.release_group_mbid, '') <> ''
AND COALESCE(al.release_group_mbid, '') = '';
-- Each table goes after the tables that reference it, without CASCADE, so
-- a reference from a table that stays stops the migration instead of being
-- dropped quietly.
DROP TABLE download_interventions;
DROP TABLE want_candidates;
DROP TABLE release_blocks;
DROP TABLE grabs;
DROP TABLE wants;
DROP TABLE follow_seen_groups;
DROP TABLE follows;
DROP TABLE release_type_profiles;
DROP TABLE requests;
DROP TABLE acquisition_services;
DROP TABLE acquisition_settings;
DROP TABLE reacquisition_settings;
DROP TABLE library_album_matches;
DROP TABLE suggestion_snoozes;
DROP TABLE discover_tuning;
DROP TABLE candidate_artist_tag_state;
DROP TABLE candidate_artist_tags;
DROP TABLE artist_similarity_unmatched;
DROP TABLE mb_artist_release_groups;
DROP TABLE mb_artists;
ALTER TABLE users DROP COLUMN auto_approve_requests;
+1 -2
View File
@@ -221,7 +221,7 @@ SELECT g.id AS group_id,
AND t.track_number IS NOT NULL AND t.track_number IS NOT NULL
AND o.disc_number IS NOT DISTINCT FROM t.disc_number AND o.disc_number IS NOT DISTINCT FROM t.disc_number
AND o.track_number = t.track_number)::boolean AS position_clash, AND o.track_number = t.track_number)::boolean AS position_clash,
COALESCE(NULLIF(al.release_group_mbid, ''), lam.release_group_mbid, '')::text AS release_group_mbid, COALESCE(al.release_group_mbid, '')::text AS release_group_mbid,
l.state AS acoustid_state, l.state AS acoustid_state,
l.recording_mbid AS acoustid_recording l.recording_mbid AS acoustid_recording
FROM duplicate_groups g FROM duplicate_groups g
@@ -229,7 +229,6 @@ SELECT g.id AS group_id,
JOIN tracks t ON t.id = m.track_id JOIN tracks t ON t.id = m.track_id
JOIN artists ON artists.id = t.artist_id JOIN artists ON artists.id = t.artist_id
JOIN albums al ON al.id = t.album_id JOIN albums al ON al.id = t.album_id
LEFT JOIN library_album_matches lam ON lam.album_id = t.album_id AND lam.outcome = 'listed'
LEFT JOIN track_acoustid_lookups l ON l.track_id = t.id LEFT JOIN track_acoustid_lookups l ON l.track_id = t.id
WHERE g.status = 'pending' WHERE g.status = 'pending'
AND t.missing_since IS NULL AND t.missing_since IS NULL
+1 -1
View File
@@ -60,7 +60,7 @@ WHERE id = $1;
-- name: ListUsers :many -- name: ListUsers :many
-- Admin user-management list. Sort newest-first. -- Admin user-management list. Sort newest-first.
SELECT id, username, display_name, is_admin, auto_approve_requests, SELECT id, username, display_name, is_admin,
debug_mode_enabled, created_at debug_mode_enabled, created_at
FROM users FROM users
ORDER BY created_at DESC; ORDER BY created_at DESC;
-40
View File
@@ -39,7 +39,6 @@ const TestUserPrefix = "test-"
var dataTables = []string{ var dataTables = []string{
"artist_similarity", "artist_similarity",
"track_similarity", "track_similarity",
"artist_similarity_unmatched",
"listenbrainz_similar_recordings", "listenbrainz_similar_recordings",
"track_similarity_fetches", "track_similarity_fetches",
"artist_similarity_fetches", "artist_similarity_fetches",
@@ -59,13 +58,10 @@ var dataTables = []string{
// does NOT reach it for a leftover row whose user survived. Truncate // does NOT reach it for a leftover row whose user survived. Truncate
// explicitly or a stale snooze silently hides a candidate from the // explicitly or a stale snooze silently hides a candidate from the
// next test's suggestion assertions. // next test's suggestion assertions.
"suggestion_snoozes",
// Same reasoning: keyed by candidate MBID with no FK anywhere, // Same reasoning: keyed by candidate MBID with no FK anywhere,
// so nothing cascades to them. A leftover tag row would make a // so nothing cascades to them. A leftover tag row would make a
// candidate look enriched to the next test, and a leftover state row // candidate look enriched to the next test, and a leftover state row
// would make it look already-settled and thus ineligible. // would make it look already-settled and thus ineligible.
"candidate_artist_tags",
"candidate_artist_tag_state",
"playlist_tracks", "playlist_tracks",
"playlists", "playlists",
"library_changes", // reset so each test's sync cursor starts clean "library_changes", // reset so each test's sync cursor starts clean
@@ -87,7 +83,6 @@ var dataTables = []string{
// Same reasoning as taste_tuning above: recsettings.New re-seeds // Same reasoning as taste_tuning above: recsettings.New re-seeds
// shipped defaults on every construction, so truncating gives each test // shipped defaults on every construction, so truncating gives each test
// pristine Discover knobs rather than whatever a previous test tuned. // pristine Discover knobs rather than whatever a previous test tuned.
"discover_tuning",
"recommendation_tuning_audit", "recommendation_tuning_audit",
"duplicate_group_members", "duplicate_group_members",
"duplicate_groups", "duplicate_groups",
@@ -101,21 +96,9 @@ var dataTables = []string{
"user_notifications", "user_notifications",
"user_notification_prefs", "user_notification_prefs",
"user_notification_email_state", "user_notification_email_state",
"acquisition_services",
"mb_release_tracks", "mb_release_tracks",
"mb_releases", "mb_releases",
"mb_artist_release_groups",
"mb_release_groups", "mb_release_groups",
"mb_artists",
"requests",
"download_interventions",
"library_album_matches",
"release_blocks",
"grabs",
"want_candidates",
"wants",
"follow_seen_groups",
"follows",
"tracks", "tracks",
"albums", "albums",
"artists", "artists",
@@ -173,17 +156,6 @@ func ResetDB(t *testing.T, pool *pgxpool.Pool) {
); err != nil { ); err != nil {
t.Fatalf("dbtest.ResetDB reset loudness settings: %v", err) t.Fatalf("dbtest.ResetDB reset loudness settings: %v", err)
} }
// Release-type profiles: migration 0081 seeds "Standard" as
// the default. Tests add and edit profiles, so put back exactly the
// seeded row rather than truncating it away.
if _, err := pool.Exec(ctx, `
DELETE FROM release_type_profiles WHERE name <> 'Standard';
UPDATE release_type_profiles
SET primary_types = ARRAY['Album', 'EP', 'Single'], secondary_types = '{}', is_default = true
WHERE name = 'Standard'`,
); err != nil {
t.Fatalf("dbtest.ResetDB reset release-type profiles: %v", err)
}
// The change log's trimmed mark, a singleton: nothing has been trimmed. // The change log's trimmed mark, a singleton: nothing has been trimmed.
if _, err := pool.Exec(ctx, "UPDATE library_changes_trimmed SET through = 0"); err != nil { if _, err := pool.Exec(ctx, "UPDATE library_changes_trimmed SET through = 0"); err != nil {
t.Fatalf("dbtest.ResetDB reset library_changes_trimmed: %v", err) t.Fatalf("dbtest.ResetDB reset library_changes_trimmed: %v", err)
@@ -199,18 +171,6 @@ func ResetDB(t *testing.T, pool *pgxpool.Pool) {
); err != nil { ); err != nil {
t.Fatalf("dbtest.ResetDB reset backup settings: %v", err) t.Fatalf("dbtest.ResetDB reset backup settings: %v", err)
} }
// Search and grab settings, a singleton reset the same way.
// The library listing reads as done, so a test's albums are not
// put on the wanted list behind its back; its own tests clear it.
if _, err := pool.Exec(ctx, `
UPDATE acquisition_settings
SET auto_grab = DEFAULT, search_interval_hours = DEFAULT, allowed_qualities = DEFAULT, import_root = DEFAULT,
seed_ratio = DEFAULT, seed_days = DEFAULT, stall_hours = DEFAULT, upgrade_until = DEFAULT,
library_listing_started_at = now(), library_listed_at = now(), library_unlisted = 0,
last_pass_at = NULL, last_pass = DEFAULT, updated_at = DEFAULT`,
); err != nil {
t.Fatalf("dbtest.ResetDB reset acquisition settings: %v", err)
}
// Notification email settings, reset the same way. // Notification email settings, reset the same way.
if _, err := pool.Exec(ctx, ` if _, err := pool.Exec(ctx, `
UPDATE notification_email_settings UPDATE notification_email_settings