Migration script from sqlite to mysql
jfberry opened this issue · comments
James Berry commented
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)
James Berry commented
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.
- be on the latest version that supports sqlite --
git checkout 4350c45bf63ce1bc6c341f3a0b921238b106f1d6
- 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)
- change database client in /config/local.json from sqlite to mysql and enter the credentials (remember 2nd step?)
- 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
- Navigate to PoracleJS/src/lib/db
5a. Fix any broken date fieldssqlite3 poracle.sqlite "update humans set last_checked='2021-01-01 12:00';"
- Dump existing database
sqlite3 poracle.sqlite .dump | grep '^INSERT' | grep -v migrations > ~/insert.sql
- this creates a file, insert.sql in your home directory - run mysql command line
mysql
(again, as root so either log in with root or sudo mysql) - change to poracle database
use poracle;
- load freshly created insert script
source ~/insert.sql
- 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
- switch to latest version -
git checkout develop
- database should now migrate to latest schema