[PR #4279] [MERGED] Make MaxActiveSessions not nullable #10001

Closed
opened 2026-02-07 06:12:18 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/4279
Author: @joshuaboniface
Created: 10/5/2020
Status: Merged
Merged: 10/6/2020
Merged by: @joshuaboniface

Base: masterHead: fix-bad-migration


📝 Commits (2)

  • 49c3637 Make MaxActiveSessions not nullable
  • b3249e8 Add default value of 0

📊 Changes

2 files changed (+3 additions, -2 deletions)

View changed files

📝 Jellyfin.Server.Implementations/Migrations/20201004171403_AddMaxActiveSessions.cs (+2 -1)
📝 Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs (+1 -1)

📄 Description

Changes
Fixes a bad assumption with the previous migration.

WARNING: THIS WILL BREAK THE DB FOR ANYONE WHO DEPLOYED THE LAST FEW UNSTABLE RELEASES THAT APPLIED THE MIGRATION, i.e. any since #4269. To fix it, because of sqlite's stupidity, you have to drop the whole table and recreate it. Annoying, I know. Here's how to fix it:

  1. Go to wherever jellyfin.db is located (e.g. /var/lib/jellyfin/data).
  2. Stop Jellyfin processes.
  3. Open the database in sqlite3 (mind your permissions!): sudo -u jellyfin sqlite3 jellyfin.db
  4. Run the following to dump the Users table:
.output jellyfin-users.tmp.sql
.dump Users
.quit
  1. Edit the line (33 is the line number):
 33 , "MaxActiveSessions" INTEGER NULL);

to

 33 , "MaxActiveSessions" INTEGER NOT NULL DEFAULT 0);
  1. Re-enter sqlite3 (sudo -u jellyfin sqlite3 jellyfin.db) and drop the Users table (drop table Users;).
  2. Import the dump: sudo -u jellyfin sqlite3 < jellyfin-users.tmp.sql
  3. Remove the cruft: sudo -u jellyfin rm jellyfin-users.tmp.sql
  4. Upgrade to the unstable provided by this PR and/or start Jellyfin if you already did.

Or, in convenient script format:

#!/bin/bash

# REPLACE ME WITH YOUR REAL PATH IF DIFFERENT
pushd /var/lib/jellyfin

sudo service jellyfin stop
echo -e ".output jellyfin-users.tmp.sql\n.dump Users" | sudo -u jellyfin sqlite3 jellyfin.db
sudo sed -i 's/"MaxActiveSessions" INTEGER NULL/"MaxActiveSessions" INTEGER NOT NULL DEFAULT 0/g' jellyfin-users.tmp.sql
echo -e "DROP TABLE Users" | sudo -u jellyfin sqlite3 jellyfin.db
sudo -u jellyfin sqlite3 jellyfin.db < jellyfin-users.tmp.sql
sudo rm jellyfin-users.tmp.sql
sudo service jellyfin start

popd

Or in full-SQL, run this with sudo -u jellyfin sqlite3 jellyfin.db < script.sql:

UPDATE Users SET MaxActiveSessions = 0 WHERE MaxActiveSessions IS NULL;

CREATE TABLE "Users_new" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_Users" PRIMARY KEY,
    "Username" TEXT NOT NULL,
    "Password" TEXT NULL,
    "EasyPassword" TEXT NULL,
    "MustUpdatePassword" INTEGER NOT NULL,
    "AudioLanguagePreference" TEXT NULL,
    "AuthenticationProviderId" TEXT NOT NULL,
    "PasswordResetProviderId" TEXT NOT NULL,
    "InvalidLoginAttemptCount" INTEGER NOT NULL,
    "LastActivityDate" TEXT NULL,
    "LastLoginDate" TEXT NULL,
    "LoginAttemptsBeforeLockout" INTEGER NULL,
    "SubtitleMode" INTEGER NOT NULL,
    "PlayDefaultAudioTrack" INTEGER NOT NULL,
    "SubtitleLanguagePreference" TEXT NULL,
    "DisplayMissingEpisodes" INTEGER NOT NULL,
    "DisplayCollectionsView" INTEGER NOT NULL,
    "EnableLocalPassword" INTEGER NOT NULL,
    "HidePlayedInLatest" INTEGER NOT NULL,
    "RememberAudioSelections" INTEGER NOT NULL,
    "RememberSubtitleSelections" INTEGER NOT NULL,
    "EnableNextEpisodeAutoPlay" INTEGER NOT NULL,
    "EnableAutoLogin" INTEGER NOT NULL,
    "EnableUserPreferenceAccess" INTEGER NOT NULL,
    "MaxParentalAgeRating" INTEGER NULL,
    "RemoteClientBitrateLimit" INTEGER NULL,
    "InternalId" INTEGER NOT NULL,
    "SyncPlayAccess" INTEGER NOT NULL,
    "RowVersion" INTEGER NOT NULL,
    "MaxActiveSessions" INTEGER NOT NULL DEFAULT 0
);

INSERT INTO Users_new SELECT * FROM Users;

PRAGMA foreign_keys="0";

DROP TABLE Users;

ALTER TABLE Users_new RENAME TO Users;

PRAGMA foreign_keys="1";

Issues
N/A


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jellyfin/jellyfin/pull/4279 **Author:** [@joshuaboniface](https://github.com/joshuaboniface) **Created:** 10/5/2020 **Status:** ✅ Merged **Merged:** 10/6/2020 **Merged by:** [@joshuaboniface](https://github.com/joshuaboniface) **Base:** `master` ← **Head:** `fix-bad-migration` --- ### 📝 Commits (2) - [`49c3637`](https://github.com/jellyfin/jellyfin/commit/49c363751a5bb54ee52e7764f223cd6263200c7c) Make MaxActiveSessions not nullable - [`b3249e8`](https://github.com/jellyfin/jellyfin/commit/b3249e849c68c3474e18f999fc085d41bff75adc) Add default value of 0 ### 📊 Changes **2 files changed** (+3 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `Jellyfin.Server.Implementations/Migrations/20201004171403_AddMaxActiveSessions.cs` (+2 -1) 📝 `Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs` (+1 -1) </details> ### 📄 Description **Changes** Fixes a bad assumption with the previous migration. WARNING: THIS WILL BREAK THE DB FOR ANYONE WHO DEPLOYED THE LAST FEW UNSTABLE RELEASES THAT APPLIED THE MIGRATION, i.e. any since #4269. To fix it, because of sqlite's stupidity, you have to drop the whole table and recreate it. Annoying, I know. Here's how to fix it: 1. Go to wherever `jellyfin.db` is located (e.g. `/var/lib/jellyfin/data`). 2. Stop Jellyfin processes. 3. Open the database in sqlite3 (mind your permissions!): `sudo -u jellyfin sqlite3 jellyfin.db` 4. Run the following to dump the `Users` table: ``` .output jellyfin-users.tmp.sql .dump Users .quit ``` 5. Edit the line (33 is the line number): ``` 33 , "MaxActiveSessions" INTEGER NULL); ``` to ``` 33 , "MaxActiveSessions" INTEGER NOT NULL DEFAULT 0); ``` 6. Re-enter sqlite3 (`sudo -u jellyfin sqlite3 jellyfin.db`) and drop the Users table (`drop table Users;`). 7. Import the dump: `sudo -u jellyfin sqlite3 < jellyfin-users.tmp.sql` 8. Remove the cruft: `sudo -u jellyfin rm jellyfin-users.tmp.sql` 9. Upgrade to the unstable provided by this PR and/or start Jellyfin if you already did. Or, in convenient script format: ``` #!/bin/bash # REPLACE ME WITH YOUR REAL PATH IF DIFFERENT pushd /var/lib/jellyfin sudo service jellyfin stop echo -e ".output jellyfin-users.tmp.sql\n.dump Users" | sudo -u jellyfin sqlite3 jellyfin.db sudo sed -i 's/"MaxActiveSessions" INTEGER NULL/"MaxActiveSessions" INTEGER NOT NULL DEFAULT 0/g' jellyfin-users.tmp.sql echo -e "DROP TABLE Users" | sudo -u jellyfin sqlite3 jellyfin.db sudo -u jellyfin sqlite3 jellyfin.db < jellyfin-users.tmp.sql sudo rm jellyfin-users.tmp.sql sudo service jellyfin start popd ``` Or in full-SQL, run this with `sudo -u jellyfin sqlite3 jellyfin.db < script.sql`: ```script.sql UPDATE Users SET MaxActiveSessions = 0 WHERE MaxActiveSessions IS NULL; CREATE TABLE "Users_new" ( "Id" TEXT NOT NULL CONSTRAINT "PK_Users" PRIMARY KEY, "Username" TEXT NOT NULL, "Password" TEXT NULL, "EasyPassword" TEXT NULL, "MustUpdatePassword" INTEGER NOT NULL, "AudioLanguagePreference" TEXT NULL, "AuthenticationProviderId" TEXT NOT NULL, "PasswordResetProviderId" TEXT NOT NULL, "InvalidLoginAttemptCount" INTEGER NOT NULL, "LastActivityDate" TEXT NULL, "LastLoginDate" TEXT NULL, "LoginAttemptsBeforeLockout" INTEGER NULL, "SubtitleMode" INTEGER NOT NULL, "PlayDefaultAudioTrack" INTEGER NOT NULL, "SubtitleLanguagePreference" TEXT NULL, "DisplayMissingEpisodes" INTEGER NOT NULL, "DisplayCollectionsView" INTEGER NOT NULL, "EnableLocalPassword" INTEGER NOT NULL, "HidePlayedInLatest" INTEGER NOT NULL, "RememberAudioSelections" INTEGER NOT NULL, "RememberSubtitleSelections" INTEGER NOT NULL, "EnableNextEpisodeAutoPlay" INTEGER NOT NULL, "EnableAutoLogin" INTEGER NOT NULL, "EnableUserPreferenceAccess" INTEGER NOT NULL, "MaxParentalAgeRating" INTEGER NULL, "RemoteClientBitrateLimit" INTEGER NULL, "InternalId" INTEGER NOT NULL, "SyncPlayAccess" INTEGER NOT NULL, "RowVersion" INTEGER NOT NULL, "MaxActiveSessions" INTEGER NOT NULL DEFAULT 0 ); INSERT INTO Users_new SELECT * FROM Users; PRAGMA foreign_keys="0"; DROP TABLE Users; ALTER TABLE Users_new RENAME TO Users; PRAGMA foreign_keys="1"; ``` **Issues** N/A --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-07 06:12:18 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#10001