mirror of
https://github.com/jackyzha0/quartz.git
synced 2026-03-25 07:25:42 -05:00
Revised based on testing while running the upgrades
This commit is contained in:
parent
c8023e2d8f
commit
2620ecdc5a
@ -1,25 +1,19 @@
|
||||
|
||||
This directory contains scripts for migrating an SQLite database to a PostgreSQL database as well as setting up a new database with the server ID.
|
||||
Change directory to `/usr/vcs/docker/migration-scripts`
|
||||
```
|
||||
cd /usr/vcs/docker/migration-scripts
|
||||
```
|
||||
This directory contains scripts for migrating an SQLite database to a Postgres database as well as setting up a new database with the server ID.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Postgres installed and running
|
||||
- Postgres installed and running [[Postgres + docker compose setup]]
|
||||
- Liquibase installed (Automated with [[Postgres + docker compose setup]])
|
||||
- Execution of Liquibase scripts (Automated with [[Postgres + docker compose setup]])
|
||||
- SQLite database file(s) to be migrated(for upgrades only)
|
||||
- SQLite database file(s) to be migrated(for existing server upgrades only)
|
||||
|
||||
## Setup
|
||||
|
||||
In `/usr/vcs/docker/migration-scripts` modify the `.pgpass` file in with the correct content: `hostname:port:database:username:password`
|
||||
|
||||
For example:
|
||||
```
|
||||
localhost:5432:postgres:vcs:vcs
|
||||
```
|
||||
|
||||
>Replace with the actual information of your Postgres database. If your password contains special characters, make sure to escape them with a backslash \\
|
||||
|
||||
Make the scripts are executable and set the correct permissions for the `.pgpass` file:
|
||||
Make the scripts are executable, if not:
|
||||
```
|
||||
chmod +x database_migration.sh
|
||||
chmod +x disable_constraints.sh
|
||||
@ -27,67 +21,48 @@ chmod +x create_db_dump.sh
|
||||
chmod +x transform_db_dump.sh
|
||||
chmod +x consolidate.sh
|
||||
chmod +x update_server_id.sh
|
||||
chmod 600 .pgpass
|
||||
```
|
||||
|
||||
**Existing server upgrade only:**
|
||||
For single server grab the `vcs.db` file, and rename it `serverID.db`(use the actual server id of the server, in case of `vcs.db-wall` and `vcs.db-shm` rename those with the server id as well)
|
||||
For multi server gather all the `vcs.db` files and rename as mentioned in the single server step
|
||||
#### Existing Server Upgrade Only
|
||||
For single server grab the `vcs.db` file, and rename it `serverID.db`(use the actual server id of the server, in case of `vcs.db-wall` and `vcs.db-shm` rename those with the server id as well).
|
||||
For multi server gather all the `vcs.db` files and rename as mentioned in the single server step.
|
||||
|
||||
Move the database file(s) to the scripts directory(`/usr/vcs/docker/migration-scripts`)
|
||||
|
||||
## Running the Migration
|
||||
|
||||
ServerID - server id for the server
|
||||
PSQL_PATH - path to Postgres psql
|
||||
Example: `docker exec -i artsentry-services-postgres-1 psql`
|
||||
|
||||
`artsentry-services-postgres-1` - name of the Docker container which can be found by running `docker ps` ([[running services.png]])
|
||||
**Required info:**
|
||||
- server_id - server id for the server
|
||||
- psql_path - path to Postgres psql
|
||||
>Example: `docker exec -i artsentry-services-postgres-1 psql`
|
||||
>`artsentry-services-postgres-1` - name of the Docker container which can be found by
|
||||
>running `docker ps` ([[running services.png]])
|
||||
- postgres_user
|
||||
>APP_USER="vcs" from docker compose environment(.env) of [[Postgres + docker compose setup]]
|
||||
- database_name
|
||||
>DB_NAME="postgres" from docker compose environment(.env) of [[Postgres + docker compose setup]]
|
||||
- docker_command - psql_path -U postgres_user -d database_name
|
||||
Example: `docker exec -i artsentry-services-postgres-1 psql -U vcs -d postgres
|
||||
|
||||
#### New Server Install
|
||||
|
||||
Run the `update_server_id.sh` script with the `ServerID` and the `PSQL_PATH` parameter:
|
||||
Run the `update_server_id.sh` script with the `server_id` and the `docker_command` parameter:
|
||||
|
||||
Example of running the script with Docker instance of Postgres:
|
||||
|
||||
```bash
|
||||
./update_server_id.sh 'server_id' 'docker exec -i artsentry-services-postgres-1 psql'
|
||||
```
|
||||
|
||||
Example of running the script with local instance of Postgres:
|
||||
|
||||
```bash
|
||||
./update_server_id.sh 'server_id' '/opt/homebrew/Cellar/postgresql@16/16.2_1/bin/psql'
|
||||
```
|
||||
|
||||
If you want to redirect the output to a different file, use the following command:
|
||||
|
||||
```bash
|
||||
./update_server_id.sh 'server_id' 'docker exec -i artsentry-services-postgres-1 psql' > migration.log
|
||||
```
|
||||
|
||||
#### Existing Server Upgrade
|
||||
|
||||
To run the migration process, execute the `database_migration.sh` script with `PSQL_PATH` parameter:
|
||||
To run the migration process, execute the `database_migration.sh` script with `docker_command` parameter:
|
||||
|
||||
Example of running the script with Docker instance of PostgreSQL:
|
||||
Example of running the script with Docker instance of Postgre:
|
||||
|
||||
```bash
|
||||
./database_migration.sh 'docker exec -i artsentry-services-postgres-1 psql'
|
||||
```
|
||||
|
||||
Example of running the script with local instance of PostgreSQL:
|
||||
|
||||
```bash
|
||||
./database_migration.sh '/opt/homebrew/Cellar/postgresql@16/16.2_1/bin/psql'
|
||||
```
|
||||
|
||||
If you want to redirect the output to a different file, use the following command:
|
||||
|
||||
```bash
|
||||
./database_migration.sh 'docker exec -i artsentry-services-postgres-1 psql' > migration.log
|
||||
```
|
||||
|
||||
#### Start VCS Server
|
||||
After completing the required steps in [[Postgres + docker compose setup]] and executing the script(s) above, start the VCS Server
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user