diff --git a/internal/audit/audit.go b/internal/audit/audit.go index f1e04363..0ed6f5c4 100644 --- a/internal/audit/audit.go +++ b/internal/audit/audit.go @@ -38,7 +38,6 @@ const ( ActionCreateUserAdmin Action = "create_user_admin" ActionDeleteUser Action = "delete_user" ActionPasswordResetAdmin Action = "password_reset_admin" - ActionAutoApproveToggle Action = "auto_approve_toggle" // Credentials. ActionPasswordChangeSelf Action = "password_change_self" diff --git a/internal/audit/audit_test.go b/internal/audit/audit_test.go index 19b0c07e..3dc1db97 100644 --- a/internal/audit/audit_test.go +++ b/internal/audit/audit_test.go @@ -163,7 +163,6 @@ func TestWrite_AllActionConstantsArePersisted(t *testing.T) { audit.ActionCreateUserAdmin, audit.ActionDeleteUser, audit.ActionPasswordResetAdmin, - audit.ActionAutoApproveToggle, audit.ActionPasswordChangeSelf, audit.ActionTokenRegenerate, audit.ActionForgotPasswordInit, diff --git a/internal/backup/archive_test.go b/internal/backup/archive_test.go index fa8cb1fe..c1a02b02 100644 --- a/internal/backup/archive_test.go +++ b/internal/backup/archive_test.go @@ -15,9 +15,9 @@ func sample() Contents { return Contents{ Schema: 98, Tables: map[string][][]byte{ - "users": {[]byte(`{"id":"u1","username":"ada"}`), []byte(`{"id":"u2","username":"bo"}`)}, - "tracks": {[]byte(`{"file_path":"/music/a.flac","id":"t1"}`)}, - "wants": {}, + "users": {[]byte(`{"id":"u1","username":"ada"}`), []byte(`{"id":"u2","username":"bo"}`)}, + "tracks": {[]byte(`{"file_path":"/music/a.flac","id":"t1"}`)}, + "playlists": {}, }, } } diff --git a/internal/backup/backup_test.go b/internal/backup/backup_test.go index 5727ad53..cf09a7dc 100644 --- a/internal/backup/backup_test.go +++ b/internal/backup/backup_test.go @@ -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) 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) - 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) 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 { t.Errorf("the backup holds no %s", tbl) } diff --git a/internal/backup/tables.go b/internal/backup/tables.go index 5ac351a8..dd1d1d54 100644 --- a/internal/backup/tables.go +++ b/internal/backup/tables.go @@ -2,8 +2,7 @@ // 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 -// and skip history, playlists, follows, wants and requests, download history, -// admin decisions, and settings. What stays out is everything the restored +// and skip history, playlists, admin decisions, and settings. What stays out is everything the restored // server rebuilds by itself: what it computes from the music files, what it // fetches again from MusicBrainz, ListenBrainz and the other providers, and // 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: "tag_provider_settings", Omit: []string{"api_key"}}, {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: "recommendation_weight_profiles"}, {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. {Name: "play_sessions"}, {Name: "play_events"}, @@ -97,13 +82,11 @@ var Tables = []Table{ {Name: "user_notification_prefs"}, {Name: "user_notification_email_state"}, {Name: "user_notifications"}, - {Name: "suggestion_snoozes"}, {Name: "quarantine"}, {Name: "quarantine_actions"}, - // Admin decisions: an album taken off the wanted listing stays off, and a - // dismissed duplicate group stays dismissed when the sweep finds it again. - {Name: "library_album_matches"}, + // Admin decisions: a dismissed duplicate group stays dismissed when the + // sweep finds it again. {Name: "duplicate_sweeps"}, {Name: "duplicate_groups"}, {Name: "duplicate_group_members"}, @@ -123,28 +106,22 @@ var Excluded = map[string]string{ "password_resets": "one-time reset links, which expire within hours", "user_invites": "open sign-up links; an admin sends an invite again from the restored server", - "track_fingerprints": "computed from the music files", - "track_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_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", + "track_fingerprints": "computed from the music files", + "track_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_tags": "fetched again from the tag providers", - "mb_artists": "MusicBrainz cache, fetched again", - "mb_release_groups": "MusicBrainz cache, fetched again", - "mb_releases": "MusicBrainz cache, fetched again", - "mb_release_tracks": "MusicBrainz cache, fetched again", - "mb_artist_release_groups": "MusicBrainz cache, fetched again", + "mb_release_groups": "MusicBrainz cache, fetched again", + "mb_releases": "MusicBrainz cache, fetched again", + "mb_release_tracks": "MusicBrainz cache, fetched again", "listenbrainz_similar_recordings": "similarity, fetched again from ListenBrainz", "track_similarity": "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_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", "diagnostic_events": "debug-mode diagnostics", diff --git a/internal/db/dbq/duplicates.sql.go b/internal/db/dbq/duplicates.sql.go index bed92a34..857762fa 100644 --- a/internal/db/dbq/duplicates.sql.go +++ b/internal/db/dbq/duplicates.sql.go @@ -316,7 +316,7 @@ SELECT g.id AS group_id, AND t.track_number IS NOT NULL AND o.disc_number IS NOT DISTINCT FROM t.disc_number 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.recording_mbid AS acoustid_recording FROM duplicate_groups g @@ -324,7 +324,6 @@ SELECT g.id AS group_id, JOIN tracks t ON t.id = m.track_id JOIN artists ON artists.id = t.artist_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 WHERE g.status = 'pending' AND t.missing_since IS NULL diff --git a/internal/db/dbq/models.go b/internal/db/dbq/models.go index 166d9646..4494329f 100644 --- a/internal/db/dbq/models.go +++ b/internal/db/dbq/models.go @@ -196,46 +196,6 @@ type AcoustidSetting struct { 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 { ID pgtype.UUID Title string @@ -289,15 +249,6 @@ type ArtistSimilarityFetch struct { Returned int32 } -type ArtistSimilarityUnmatched struct { - SeedArtistID pgtype.UUID - CandidateMbid string - CandidateName string - Score float64 - Source string - FetchedAt pgtype.Timestamptz -} - type AuditLog struct { ID pgtype.UUID ActorID pgtype.UUID @@ -345,19 +296,6 @@ type BackupSetting struct { 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 { ID pgtype.UUID UserID pgtype.UUID @@ -395,30 +333,6 @@ type DiagnosticEvent struct { 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 { ID pgtype.UUID MemberKey string @@ -459,24 +373,6 @@ type FingerprintSetting struct { 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 { UserID pgtype.UUID TrackID pgtype.UUID @@ -495,49 +391,6 @@ type GeneralLikesArtist struct { 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 { ID int64 EntityType string @@ -571,23 +424,6 @@ type LoudnessSetting struct { 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 { Mbid string ReleaseGroupMbid string @@ -735,13 +571,6 @@ type QuarantineAction struct { CreatedAt pgtype.Timestamptz } -type ReacquisitionSetting struct { - ID bool - Enabled bool - GraceHours int32 - MaxPerPass int32 -} - type RecommendationTuningAudit struct { ID int64 ChangedAt pgtype.Timestamptz @@ -769,49 +598,6 @@ type RegistrationSetting struct { 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 { ID pgtype.UUID StartedAt pgtype.Timestamptz @@ -867,14 +653,6 @@ type SmtpConfig struct { UpdatedAt pgtype.Timestamptz } -type SuggestionSnooze struct { - UserID pgtype.UUID - CandidateMbid string - CandidateName string - SnoozedUntil pgtype.Timestamptz - CreatedAt pgtype.Timestamptz -} - type SystemPlaylistRotationState struct { UserID pgtype.UUID PlaylistKind string @@ -1037,7 +815,6 @@ type User struct { ListenbrainzToken *string ListenbrainzEnabled bool DisplayName *string - AutoApproveRequests bool Email *string Timezone string TimezoneUpdatedAt pgtype.Timestamptz @@ -1092,54 +869,6 @@ type UserNotificationPref struct { 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 { UserID pgtype.UUID AlbumID pgtype.UUID diff --git a/internal/db/dbq/users.sql.go b/internal/db/dbq/users.sql.go index 35533e22..d14a016d 100644 --- a/internal/db/dbq/users.sql.go +++ b/internal/db/dbq/users.sql.go @@ -54,7 +54,7 @@ func (q *Queries) CountUsers(ctx context.Context) (int64, error) { const createUser = `-- name: CreateUser :one INSERT INTO users (username, password_hash, api_token_hash, is_admin, display_name) 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 { @@ -84,7 +84,6 @@ func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, e &i.ListenbrainzToken, &i.ListenbrainzEnabled, &i.DisplayName, - &i.AutoApproveRequests, &i.Email, &i.Timezone, &i.TimezoneUpdatedAt, @@ -97,7 +96,7 @@ func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, e const createUserAdmin = `-- name: CreateUserAdmin :one INSERT INTO users (username, password_hash, api_token_hash, is_admin, display_name) 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 { @@ -130,7 +129,6 @@ func (q *Queries) CreateUserAdmin(ctx context.Context, arg CreateUserAdminParams &i.ListenbrainzToken, &i.ListenbrainzEnabled, &i.DisplayName, - &i.AutoApproveRequests, &i.Email, &i.Timezone, &i.TimezoneUpdatedAt, @@ -147,7 +145,7 @@ VALUES ( (SELECT NOT EXISTS (SELECT 1 FROM users)), $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 { @@ -188,7 +186,6 @@ func (q *Queries) CreateUserFirstAdminRace(ctx context.Context, arg CreateUserFi &i.ListenbrainzToken, &i.ListenbrainzEnabled, &i.DisplayName, - &i.AutoApproveRequests, &i.Email, &i.Timezone, &i.TimezoneUpdatedAt, @@ -240,7 +237,7 @@ func (q *Queries) GetListenBrainzConfig(ctx context.Context, id pgtype.UUID) (Ge } 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) { @@ -256,7 +253,6 @@ func (q *Queries) GetUserByAPITokenHash(ctx context.Context, apiTokenHash string &i.ListenbrainzToken, &i.ListenbrainzEnabled, &i.DisplayName, - &i.AutoApproveRequests, &i.Email, &i.Timezone, &i.TimezoneUpdatedAt, @@ -267,7 +263,7 @@ func (q *Queries) GetUserByAPITokenHash(ctx context.Context, apiTokenHash string } 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 @@ -286,7 +282,6 @@ func (q *Queries) GetUserByEmail(ctx context.Context, lower string) (User, error &i.ListenbrainzToken, &i.ListenbrainzEnabled, &i.DisplayName, - &i.AutoApproveRequests, &i.Email, &i.Timezone, &i.TimezoneUpdatedAt, @@ -297,7 +292,7 @@ func (q *Queries) GetUserByEmail(ctx context.Context, lower string) (User, error } 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) { @@ -313,7 +308,6 @@ func (q *Queries) GetUserByID(ctx context.Context, id pgtype.UUID) (User, error) &i.ListenbrainzToken, &i.ListenbrainzEnabled, &i.DisplayName, - &i.AutoApproveRequests, &i.Email, &i.Timezone, &i.TimezoneUpdatedAt, @@ -324,7 +318,7 @@ func (q *Queries) GetUserByID(ctx context.Context, id pgtype.UUID) (User, error) } 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) { @@ -340,7 +334,6 @@ func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User, &i.ListenbrainzToken, &i.ListenbrainzEnabled, &i.DisplayName, - &i.AutoApproveRequests, &i.Email, &i.Timezone, &i.TimezoneUpdatedAt, @@ -419,20 +412,19 @@ func (q *Queries) ListUsernamesByIDs(ctx context.Context, dollar_1 []pgtype.UUID } 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 FROM users ORDER BY created_at DESC ` type ListUsersRow struct { - ID pgtype.UUID - Username string - DisplayName *string - IsAdmin bool - AutoApproveRequests bool - DebugModeEnabled bool - CreatedAt pgtype.Timestamptz + ID pgtype.UUID + Username string + DisplayName *string + IsAdmin bool + DebugModeEnabled bool + CreatedAt pgtype.Timestamptz } // Admin user-management list. Sort newest-first. @@ -450,7 +442,6 @@ func (q *Queries) ListUsers(ctx context.Context) ([]ListUsersRow, error) { &i.Username, &i.DisplayName, &i.IsAdmin, - &i.AutoApproveRequests, &i.DebugModeEnabled, &i.CreatedAt, ); err != nil { @@ -505,7 +496,7 @@ const setDebugMode = `-- name: SetDebugMode :one UPDATE users SET debug_mode_enabled = $2 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 { @@ -529,7 +520,6 @@ func (q *Queries) SetDebugMode(ctx context.Context, arg SetDebugModeParams) (Use &i.ListenbrainzToken, &i.ListenbrainzEnabled, &i.DisplayName, - &i.AutoApproveRequests, &i.Email, &i.Timezone, &i.TimezoneUpdatedAt, @@ -593,7 +583,7 @@ const updateUserAdmin = `-- name: UpdateUserAdmin :one UPDATE users SET is_admin = $2 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 { @@ -616,7 +606,6 @@ func (q *Queries) UpdateUserAdmin(ctx context.Context, arg UpdateUserAdminParams &i.ListenbrainzToken, &i.ListenbrainzEnabled, &i.DisplayName, - &i.AutoApproveRequests, &i.Email, &i.Timezone, &i.TimezoneUpdatedAt, @@ -631,7 +620,7 @@ UPDATE users SET display_name = $2, email = $3 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 { @@ -655,7 +644,6 @@ func (q *Queries) UpdateUserProfile(ctx context.Context, arg UpdateUserProfilePa &i.ListenbrainzToken, &i.ListenbrainzEnabled, &i.DisplayName, - &i.AutoApproveRequests, &i.Email, &i.Timezone, &i.TimezoneUpdatedAt, diff --git a/internal/db/migrations/0105_drop_acquisition.down.sql b/internal/db/migrations/0105_drop_acquisition.down.sql new file mode 100644 index 00000000..be46e1ba --- /dev/null +++ b/internal/db/migrations/0105_drop_acquisition.down.sql @@ -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 $$; diff --git a/internal/db/migrations/0105_drop_acquisition.up.sql b/internal/db/migrations/0105_drop_acquisition.up.sql new file mode 100644 index 00000000..87de6af8 --- /dev/null +++ b/internal/db/migrations/0105_drop_acquisition.up.sql @@ -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; diff --git a/internal/db/queries/duplicates.sql b/internal/db/queries/duplicates.sql index 168e6aed..8ff5dfc2 100644 --- a/internal/db/queries/duplicates.sql +++ b/internal/db/queries/duplicates.sql @@ -221,7 +221,7 @@ SELECT g.id AS group_id, AND t.track_number IS NOT NULL AND o.disc_number IS NOT DISTINCT FROM t.disc_number 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.recording_mbid AS acoustid_recording FROM duplicate_groups g @@ -229,7 +229,6 @@ SELECT g.id AS group_id, JOIN tracks t ON t.id = m.track_id JOIN artists ON artists.id = t.artist_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 WHERE g.status = 'pending' AND t.missing_since IS NULL diff --git a/internal/db/queries/users.sql b/internal/db/queries/users.sql index 711eace2..4e956f37 100644 --- a/internal/db/queries/users.sql +++ b/internal/db/queries/users.sql @@ -60,7 +60,7 @@ WHERE id = $1; -- name: ListUsers :many -- 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 FROM users ORDER BY created_at DESC; diff --git a/internal/dbtest/reset.go b/internal/dbtest/reset.go index e8b5807d..02e2ada6 100644 --- a/internal/dbtest/reset.go +++ b/internal/dbtest/reset.go @@ -39,7 +39,6 @@ const TestUserPrefix = "test-" var dataTables = []string{ "artist_similarity", "track_similarity", - "artist_similarity_unmatched", "listenbrainz_similar_recordings", "track_similarity_fetches", "artist_similarity_fetches", @@ -59,13 +58,10 @@ var dataTables = []string{ // does NOT reach it for a leftover row whose user survived. Truncate // explicitly or a stale snooze silently hides a candidate from the // next test's suggestion assertions. - "suggestion_snoozes", // Same reasoning: keyed by candidate MBID with no FK anywhere, // so nothing cascades to them. A leftover tag row would make a // candidate look enriched to the next test, and a leftover state row // would make it look already-settled and thus ineligible. - "candidate_artist_tags", - "candidate_artist_tag_state", "playlist_tracks", "playlists", "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 // shipped defaults on every construction, so truncating gives each test // pristine Discover knobs rather than whatever a previous test tuned. - "discover_tuning", "recommendation_tuning_audit", "duplicate_group_members", "duplicate_groups", @@ -101,21 +96,9 @@ var dataTables = []string{ "user_notifications", "user_notification_prefs", "user_notification_email_state", - "acquisition_services", "mb_release_tracks", "mb_releases", - "mb_artist_release_groups", "mb_release_groups", - "mb_artists", - "requests", - "download_interventions", - "library_album_matches", - "release_blocks", - "grabs", - "want_candidates", - "wants", - "follow_seen_groups", - "follows", "tracks", "albums", "artists", @@ -173,17 +156,6 @@ func ResetDB(t *testing.T, pool *pgxpool.Pool) { ); err != nil { 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. if _, err := pool.Exec(ctx, "UPDATE library_changes_trimmed SET through = 0"); err != nil { t.Fatalf("dbtest.ResetDB reset library_changes_trimmed: %v", err) @@ -199,18 +171,6 @@ func ResetDB(t *testing.T, pool *pgxpool.Pool) { ); err != nil { 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. if _, err := pool.Exec(ctx, ` UPDATE notification_email_settings