diff --git a/src/bin/db_migrate.rs b/src/bin/upgrade.rs similarity index 98% rename from src/bin/db_migrate.rs rename to src/bin/upgrade.rs index fcfb7eae..563bebdb 100644 --- a/src/bin/db_migrate.rs +++ b/src/bin/upgrade.rs @@ -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; diff --git a/src/upgrades/from_v1_0_0_to_v2_0_0/upgrader.rs b/src/upgrades/from_v1_0_0_to_v2_0_0/upgrader.rs new file mode 100644 index 00000000..e69de29b diff --git a/db_migrate/README.md b/upgrades/from_v1_0_0_to_v2_0_0/README.md similarity index 75% rename from db_migrate/README.md rename to upgrades/from_v1_0_0_to_v2_0_0/README.md index 617a6009..af9a9b69 100644 --- a/db_migrate/README.md +++ b/upgrades/from_v1_0_0_to_v2_0_0/README.md @@ -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. @@ -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: @@ -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 @@ -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 ``` diff --git a/db_migrate/db_schemas/mysql/db_migrations_v2.sql b/upgrades/from_v1_0_0_to_v2_0_0/db_schemas/mysql/db_migrations_v2.sql similarity index 100% rename from db_migrate/db_schemas/mysql/db_migrations_v2.sql rename to upgrades/from_v1_0_0_to_v2_0_0/db_schemas/mysql/db_migrations_v2.sql diff --git a/db_migrate/db_schemas/sqlite3/db_migrations_v1.sql b/upgrades/from_v1_0_0_to_v2_0_0/db_schemas/sqlite3/db_migrations_v1.sql similarity index 100% rename from db_migrate/db_schemas/sqlite3/db_migrations_v1.sql rename to upgrades/from_v1_0_0_to_v2_0_0/db_schemas/sqlite3/db_migrations_v1.sql diff --git a/db_migrate/db_schemas/sqlite3/db_migrations_v2.sql b/upgrades/from_v1_0_0_to_v2_0_0/db_schemas/sqlite3/db_migrations_v2.sql similarity index 100% rename from db_migrate/db_schemas/sqlite3/db_migrations_v2.sql rename to upgrades/from_v1_0_0_to_v2_0_0/db_schemas/sqlite3/db_migrations_v2.sql diff --git a/db_migrate/docker/start_mysql.sh b/upgrades/from_v1_0_0_to_v2_0_0/docker/start_mysql.sh similarity index 100% rename from db_migrate/docker/start_mysql.sh rename to upgrades/from_v1_0_0_to_v2_0_0/docker/start_mysql.sh diff --git a/db_migrate/docker/start_mysql_client.sh b/upgrades/from_v1_0_0_to_v2_0_0/docker/start_mysql_client.sh similarity index 100% rename from db_migrate/docker/start_mysql_client.sh rename to upgrades/from_v1_0_0_to_v2_0_0/docker/start_mysql_client.sh diff --git a/db_migrate/docker/stop_mysql.sh b/upgrades/from_v1_0_0_to_v2_0_0/docker/stop_mysql.sh similarity index 100% rename from db_migrate/docker/stop_mysql.sh rename to upgrades/from_v1_0_0_to_v2_0_0/docker/stop_mysql.sh