Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added PostgreSQL support.
One week without issues running on PostgreSQL.
Will maintain and do appropriate migration patches are needed.
TODO by the Team:
MIGRATION options ATT: @ElementalCrisis for documentation update.
Migration of an existing database to PostgreSQL it should be done on the same versions of Shoko Server.
(Since different versions may have different database schemas)
The below uses MySQL as an example, but PgLoader supports migrations from SQLite and SqlServer, the below script may need to be tweaked accordingly if you use other engine.
The migration is done with PgLoader in a docker, you could also download PgLoader binaries and do it directly.
Steps
Replace [MYSQLUSER], [MYSQLPASSOWORD], [MYSQLIP], [POSTGREUSER], [POSTGREPASSWORD], [POSTGREIP] with the appropriate values, this will migrate all your data.
Code tidbits:
NHibernate PostgreSQL does not support direct conversion from bool to int, which automagically happens on the other database engines, for this a BoolToIntConverter was created and added to the offending properties in the database mappings.
Without adding sequence annotations to the mapping in NHibernate, PostgreSQL sequences do not work as intended (Autoincrement, etc). Adding them will affect the mappings on other engines. So a sloppy conversion was added to the SQL generation with a driver interceptor, that renames it to the appropriate sequence. [SequenceNpgsqlDriver ->PostgreSQL.cs].
Finally Uppercase letters on tables and columns require that the tables use quotes. To skip that requirement, a LowecaseNamingStrategy was created, and incorporated, that lowercase all tables and columns.