-
-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add postgres support + migrations #628
base: develop
Are you sure you want to change the base?
Conversation
Merge 'origin/develop' into main
Merge develop into main
Merge 'develop' into main
Merge develop into main
…ed ssl for postgres config Fallenbagel#186
Whats the difference between this and #421? |
This PR contains all the changes in #421 plus changes from @ralgar that are also mentioned in that PR. Additionally, this PR contains the migration script required to get postgres running, documentation on how to configure postgres, and improved ssl configuration options |
I think migrating the config file to the db is worth its own issue and PR. After this is merged |
Not sure I agree with this idea. IMO config should be in files and only data should be in the DB, it's simpler and more transparent that way. What benefit do you envision from moving the configuration into the DB? From my end, all I see is that it will break (and seriously complicate) the declarative configuration workflow that I and @aleksasiriski are both currently using:
Jellyseerr is the easiest app to configure in my cluster, precisely because of this JSON file. Just copy it into an emptyDir and run |
I agree with what you're saying to a point however there's a bunch of configuration in this config file that could be offloaded to the database. Obviously things like database, port and some other config should live in env and/or a config file but when it comes to a app that implements sqlite or pg most configuration should live in the database. Otherwise you start mixing configuration between env, file and database and that's not great.
This is pretty janky however I do it sometimes as well across other apps but there's no guarantee that this config file won't change in the future which will end up breaking this pattern. For example sabnzbd is all one configuration file and the app can run migrations on the config file. If you take a snapshot of this config, do the init container dance with envsubst, and then sabnzbd releases an update that migrates the config to a version your config that you snapshotted is going to be out of date and will potentially break the app. Another issue you run into is that you essentially make it so changing configuration in the UI is pointless because those values live in your initcontainer/configmap/envsubst solution. Any time you want to make a configuration change you must restart the application. Some values aren't even easy to guess what to put in the config file because they are calculated on save in the UI.
If the config is in the DB and you're already backing up the database there's no reason to do this. It's not like your deploying new instances of jellyseerr every hour and need declarative configuration for this app. Once it's set up that configuration lives in the database and should be backed up. Don't get me wrong, I love applications that have full declarative configuration. I don't think jellyseerr really benefits from it due to the reasons I laid out. |
I don't see a point in offloading configuration to the database. It just makes it harder to make changes. Config files can be live reloaded without a reboot and there isn't a performance benefit to adding it to the database. Edit: And there isn't an issue exposing to the UI either. It can be mapped to the config file as well. I don't know, I just don't see a real good reason for the added complexity. |
The amount of times I've to go into the Sonarr or Radarr or any other apps database to change config is pretty much zero. Most expose enough options in the config file to make sure the app starts, so you can change config in the UI. Basically anything that requires a app restart should be in env or config file, anything that can change during run time should be in the database (since there is a database implemented in the app)
The main problem I'm trying to solve is close to what @aleksasiriski and @ralgar is doing but I don't want to deal with the nuances they are faced with in their solution of templating the config file, which is possibly dealing with upstream config changes and not having access to change settings in the UI and have those reflected in the template. But I get it, why change it if things work now for the majority of people 🤷♂️ |
Let's move this to a discussion so anyone interested can talk about it there :D I'll join with my perspective as well. |
@Fallenbagel id appreciate a review when you (or anyone else) gets the chance. I haven’t seen or heard about any issues for a while and I’d prefer to get this merged before more migrations are required |
There is one issue. Not sure if it's isolated to this pr (but I have not been able to reproduce it on sqlite) #652 Also ill review when I can |
I had a look and I don’t think it’s caused by this pr directly. I think it’s either caused by a user being renamed or a bad migration. I’m going to write up an SQLite to Postgres migration guide when I have a little time |
Yep, I'm pretty sure it's because of old tags being in place from when I used Overseerr. I had assumed that it would see that It turns out that it simply maps based on I've gone ahead and wiped out my tags (Not worth the trouble to fix considering some of my users still don't have an ID yet). Issue #652 should no longer be an issue. Extremely excited to get this merged into Jellyseerr! Thank you so much @dr-carrot and @Fallenbagel! |
import { Column } from 'typeorm'; | ||
|
||
const pgTypeMapping: { [key: string]: ColumnType } = { | ||
datetime: 'timestamp with time zone', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be a timestamp without time zone to match how the datetime is stored in sqlite? I haven't tested that, so am not sure what the behaviour would be.
Edit: looks like a fork is doing just that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll give it a try and make sure it works first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sqlite doesn't support that. In fact, that fork dropped sqlite completely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uses PostgreSQL over SQLite (SQLite database functionality is completely removed!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My question was about Postgres actually. not using a different data type for Sqlite.
More specifically, whether this can be done without any issues since imo it's always a good idea to store timestamps without the time zone:
datetime: 'timestamp with time zone', | |
datetime: 'timestamp without time zone', |
Looking at having to have separate migrations for sqlite and postgres isn't awesome, but seems like it's the way to do it. Something that I think would be nice is to update the dev setup to include everything that's needed to work with Jellyseer whether it's with the sqlite or postgres database. That would include:
|
There's also a fix I saw a fork have to make that I'm curious to know if someone using this pull's docker image had to do? The issue seems to be TypeORM not loading the MediaRequest relations on a Media entity, and therefore dumping all the requests for a Media whenever it's updated and saved. |
There was something similar in this PR, but it didn't always work quite right. After some experimenting I found that using more strict constraints makes typeorm behave itself in that instance. I haven't heard of or had any issues with it since |
…nto v1.7.0/postgresql
…nto v1.7.0/postgresql
I've been using this branch for a couple months and semi-regularly get these two errors in my Postgres logs.
This one seems to be because there is no value provided for the |
Description
Screenshot (if UI-related)
To-Dos
yarn build
yarn i18n:extract
Issues Fixed or Closed
TODO:
drcarrot/jellyseerr-postgres:latest