Skip to content

Commit d7f51fa

Browse files
committed
docs: [#169] app upgrader documentation
Documentation for the command to upgrade the application.
1 parent 2626f9f commit d7f51fa

File tree

2 files changed

+49
-12
lines changed

2 files changed

+49
-12
lines changed

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,6 @@
240240
//! For more information about this command you can visit the documentation for
241241
//! the [`Upgrade app from version 1.0.0 to 2.0.0`](crate::upgrades::from_v1_0_0_to_v2_0_0::upgrader) module.
242242
//!
243-
//! Refer to the documentation of each command for more information.
244-
//!
245243
//! # Contributing
246244
//!
247245
//! If you want to contribute to this documentation you can:

src/upgrades/from_v1_0_0_to_v2_0_0/upgrader.rs

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,51 @@
1-
//! It updates the application from version v1.0.0 to v2.0.0.
1+
//! A console command to upgrade the application from version `v1.0.0` to `v2.0.0`.
2+
//!
3+
//! # Usage
4+
//!
5+
//! ```bash
6+
//! cargo run --bin upgrade SOURCE_DB_FILE TARGET_DB_FILE TORRENT_UPLOAD_DIR
7+
//! ```
8+
//!
9+
//! Where:
10+
//!
11+
//! - `SOURCE_DB_FILE` is the source database in version `v1.0.0` we want to migrate.
12+
//! - `TARGET_DB_FILE` is the new migrated database in version `v2.0.0`.
13+
//! - `TORRENT_UPLOAD_DIR` is the relative dir where torrent files are stored.
14+
//!
15+
//! For example:
16+
//!
17+
//! ```bash
18+
//! cargo run --bin upgrade ./data.db ./data_v2.db ./uploads
19+
//! ```
20+
//!
21+
//! This command was created to help users to migrate from version `v1.0.0` to
22+
//! `v2.0.0`. The main changes in version `v2.0.0` were:
23+
//!
24+
//! - The database schema was changed.
25+
//! - The torrents are now stored entirely in the database. The torrent files
26+
//! are not stored in the filesystem anymore. This command reads the torrent
27+
//! files from the filesystem and store them in the database.
28+
//!
29+
//! We recommend to download your production database and the torrent files dir.
30+
//! And run the command in a local environment with the version `v2.0.0.`. Then,
31+
//! you can run the app locally and make sure all the data was migrated
32+
//! correctly.
33+
//!
34+
//! # Notes
235
//!
336
//! NOTES for `torrust_users` table transfer:
437
//!
5-
//! - In v2, the table `torrust_user` contains a field `date_registered` non existing in v1.
6-
//! We changed that columns to allow NULL. We also added the new column `date_imported` with
7-
//! the datetime when the upgrader was executed.
38+
//! - In v2, the table `torrust_user` contains a field `date_registered` non
39+
//! existing in v1. We changed that column to allow `NULL`. We also added the
40+
//! new column `date_imported` with the datetime when the upgrader was executed.
841
//!
942
//! NOTES for `torrust_user_profiles` table transfer:
1043
//!
11-
//! - In v2, the table `torrust_user_profiles` contains two new fields: `bio` and `avatar`.
12-
//! Empty string is used as default value.
44+
//! - In v2, the table `torrust_user_profiles` contains two new fields: `bio`
45+
//! and `avatar`. Empty string is used as default value.
46+
//!
47+
//!
48+
//! If you want more information about this command you can read the [issue 56](https://github.com/torrust/torrust-index-backend/issues/56).
1349
use std::env;
1450
use std::time::SystemTime;
1551

@@ -26,9 +62,12 @@ const NUMBER_OF_ARGUMENTS: usize = 3;
2662

2763
#[derive(Debug)]
2864
pub struct Arguments {
29-
pub source_database_file: String, // The source database in version v1.0.0 we want to migrate
30-
pub target_database_file: String, // The new migrated database in version v2.0.0
31-
pub upload_path: String, // The relative dir where torrent files are stored
65+
/// The source database in version v1.0.0 we want to migrate
66+
pub source_database_file: String,
67+
/// The new migrated database in version v2.0.0
68+
pub target_database_file: String,
69+
// The relative dir where torrent files are stored
70+
pub upload_path: String,
3271
}
3372

3473
fn print_usage() {
@@ -100,7 +139,7 @@ pub async fn upgrade(args: &Arguments, date_imported: &str) {
100139
}
101140

102141
/// Current datetime in ISO8601 without time zone.
103-
/// For example: 2022-11-10 10:35:15
142+
/// For example: `2022-11-10 10:35:15`
104143
#[must_use]
105144
pub fn datetime_iso_8601() -> String {
106145
let dt: DateTime<Utc> = SystemTime::now().into();

0 commit comments

Comments
 (0)