Skip to content

Migration from ssj_auth

Jerry edited this page Dec 8, 2024 · 2 revisions

Database Migration

Risks

Warning

This method haven't been tested in production yet, I'm not sure it is the best solution.
This method possibly can cause performance issues or even temporary ban on discord servers(api) because of frequent use

Important

Because of shitty database scheme in ssj_auth there are no expires field as in typeauthd which required for typeauthd correct working and tokens processing, so this method will set expires field to 0 by default, so typeauthd will automatically update every token when needed(when used)

Migrating from ssj_auth to typeauthd seems to be hard work, because I haven't tested it in production yet, and there might be pitfalls I don't know about. But I have one method to migrate database from ssj_auth.

Migrating

There is a python script and an SQL query doing the same, creating new table(database) and migrating data from old tables to a new scheme. Using .sql file is not a hard work, just pass it to SQL query interpreter you use. Python script usage is easy to understand too, here is an example

# lets pretend our old db file is in `./ssj_auth/assets/database.db`
# our script is in ./typeauthd/scripts/convert_db.py`
# then we just need to do
touch ./typeauthd/app.sqlite # create new database file

# run script passing old db as a 1st argument and new database file as the 2nd argument
python ./typeauthd/scripts/convert_db.py ./ssj_auth/assets/database.db ./typeauthd/app.sqlite

After successful execution you'll get the following message:
Database conversion completed successfully! New database saved at './typeauthd/app.sqlite'.

Then you can use this database for typeauthd. Read Important and Warning above to be sure you understand all risks of this.

Clone this wiki locally