KartulUdus / PoracleJS

NodeJS application for PokémonGo WebHook Discord alarms

Home Page:https://kartuludus.github.io/PoracleJS/#/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Migration script from sqlite to mysql

jfberry opened this issue · comments

As a sqlite user I would like to upgrade to mysql so that I can take advantage of backups and other mysql related tools (eg poracleweb project)

These steps confirmed working after my migration. Things are slightly more complicated now because we have upgraded the database schema since dropping support for sqlite.

  1. be on the latest version that supports sqlite -- git checkout 4350c45bf63ce1bc6c341f3a0b921238b106f1d6
  2. create an empty database like explained here https://muckelba.github.io/poracleWiki/v4/database.html (when granting the privileges make sure to be logged into mysql with root/mysql root)
  3. change database client in /config/local.json from sqlite to mysql and enter the credentials (remember 2nd step?)
  4. launch poracle and it will create the database. If you get an error referring to '767 specified key was too long' you will need to drop the database, adjust mysql/mariadb settings (see https://dba.stackexchange.com/questions/231219/mariadb-10-1-38-specified-key-was-too-long-max-key-length-is-767-bytes ) and go back to 2
  5. Navigate to PoracleJS/src/lib/db
    5a. Fix any broken date fields sqlite3 poracle.sqlite "update humans set last_checked='2021-01-01 12:00';"
  6. Dump existing database sqlite3 poracle.sqlite .dump | grep '^INSERT' | grep -v migrations > ~/insert.sql - this creates a file, insert.sql in your home directory
  7. run mysql command line mysql (again, as root so either log in with root or sudo mysql)
  8. change to poracle database use poracle;
  9. load freshly created insert script source ~/insert.sql
  10. I'd suggest making sure poracle runs now - change your config to use mysql and fire it up and make sure it can process some hooks
  11. switch to latest version - git checkout develop - database should now migrate to latest schema