Created Preparation for update with database schema changes (markdown)

Aurora Lahtela 2022-04-10 09:03:34 +03:00
parent 1168d34968
commit 98a2ddd67c
1 changed files with 49 additions and 0 deletions

@ -0,0 +1,49 @@
![Plan Header](https://puu.sh/AXSg7/5f2f78c06c.jpg)
# Preparation for update with database schema changes
If an update has backwards incompatible database schema changes it is mentioned in the change log.
- Backup your database
- Stop all servers
- Start one server with Plan and wait until Patching has completed (`"All database patches applied successfully."`)
If you need a rough estimate how long patching will take, you can run query `SELECT COUNT(*) as row_count FROM <table name mentioned in change log>` and estimate.
Patching the database usually takes ~1 second per 20000 rows of data.
## How to Backup your database
### SQLite
- Stop your server
- Go to Plan plugin directory
- Make sure that `database.db-shm` and `database.db-wal` files are not present
- If they are the server didn't shut down properly, restart the server and stop it.
- Copy `database.db` to your backup folder
<details>
<summary>How to restore if something goes wrong</summary>
- Stop your server
- Go to Plan plugin directory
- Make sure that `database.db-shm` and `database.db-wal` files are not present
- If they are the server didn't shut down properly, restart the server and stop it.
- Copy `database.db` to your Plan folder from your backup'
</details>
### MySQL
- https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html
- `mysqldump [login options] <plan database name> > backup-plan-dump.sql`
- Copy the dump file to your backup folder
<details>
<summary>How to restore if something goes wrong</summary>
- Login to mysql
- `mysql> drop database <broken plan database>;`
- `mysql> source /path/to/backup-plan-dump.sql`
</details>