rocal-cli 0.2.6

CLI tool for Rocal - Full-Stack WASM framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::fs::File;

use chrono::Utc;

use crate::commands::utils::project::find_project_root;

pub fn add(name: &str) {
    let now = Utc::now();
    let stamp = now.format("%Y%m%d%H%M%S").to_string();
    let file_name = &format!("{stamp}-{name}.sql");

    let root_path = find_project_root().expect("Failed to find the project root");

    File::create(root_path.join(&format!("db/migrations/{file_name}")))
        .expect(&format!("Failed to create db/migrations/{file_name}"));

    println!("{file_name}");
}