Skip to content

Commit

Permalink
refactor: [#56] rename command al dirs
Browse files Browse the repository at this point in the history
Make name more generic to allow addding other upgrade command in the
future.
  • Loading branch information
josecelano committed Nov 30, 2022
1 parent b92fb08 commit 996c7d1
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/bin/db_migrate.rs → src/bin/upgrade.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Migration command to migrate data from v1.0.0 to v2.0.0
//! Run it with `cargo run --bin db_migrate`
//! Run it with `cargo run --bin upgrade`

use std::sync::Arc;
use torrust_index_backend::config::Configuration;
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DB migration

With the console command `cargo run --bin db_migrate` you can migrate data from `v1.0.0` to `v2.0.0`. This migration includes:
With the console command `cargo run --bin upgrade` you can migrate data from `v1.0.0` to `v2.0.0`. This migration includes:

- Changing the DB schema.
- Transferring the torrent files in the dir `uploads` to the database.
Expand All @@ -22,8 +22,8 @@ and also:
Run the docker container and connect using the console client:

```s
./db_migrate/docker/start_mysql.sh
./db_migrate/docker/mysql_client.sh
./upgrades/from_v1_0_0_to_v2_0_0/docker/start_mysql.sh
./upgrades/from_v1_0_0_to_v2_0_0/docker/mysql_client.sh
```

Once you are connected to the client you can create databases with:
Expand Down Expand Up @@ -95,20 +95,20 @@ mysql> show tables;

### Create DB for backend `v1.0.0`

The `db_migrate` command is going to import data from version `v1.0.0` (database and `uploads` folder) into the new empty database for `v2.0.0`.
The `upgrade` command is going to import data from version `v1.0.0` (database and `uploads` folder) into the new empty database for `v2.0.0`.

You can import data into the source database for testing with the `mysql` DB client or docker.

Using `mysql` client:

```s
mysql -h127.0.0.1 -uroot -pdb-root-password torrust_v1 < ./db_migrate/db_schemas/db_migrations_v1_for_mysql_8.sql
mysql -h127.0.0.1 -uroot -pdb-root-password torrust_v1 < ./upgrades/from_v1_0_0_to_v2_0_0/db_schemas/db_migrations_v1_for_mysql_8.sql
```

Using dockerized `mysql` client:

```s
docker exec -i torrust-index-backend-mysql mysql torrust_v1 -uroot -pdb-root-password < ./db_migrate/db_schemas/db_migrations_v1_for_mysql_8.sql
docker exec -i torrust-index-backend-mysql mysql torrust_v1 -uroot -pdb-root-password < ./upgrades/from_v1_0_0_to_v2_0_0/db_schemas/db_migrations_v1_for_mysql_8.sql
```

### Commands
Expand All @@ -128,6 +128,6 @@ docker exec -it torrust-index-backend-mysql mysql torrust_v1 -uroot -pdb-root-pa
Backup DB:

```s
mysqldump -h127.0.0.1 torrust_v1 -uroot -pdb-root-password > ./db_migrate/db_schemas/v1_schema_dump.sql
mysqldump -h127.0.0.1 torrust_v2 -uroot -pdb-root-password > ./db_migrate/db_schemas/v2_schema_dump.sql
mysqldump -h127.0.0.1 torrust_v1 -uroot -pdb-root-password > ./upgrades/from_v1_0_0_to_v2_0_0/db_schemas/v1_schema_dump.sql
mysqldump -h127.0.0.1 torrust_v2 -uroot -pdb-root-password > ./upgrades/from_v1_0_0_to_v2_0_0/db_schemas/v2_schema_dump.sql
```
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 996c7d1

Please sign in to comment.