Skip to content

Commit

Permalink
seaorm 迁移增加种子数据
Browse files Browse the repository at this point in the history
  • Loading branch information
fankaiLiu committed Jan 21, 2025
1 parent 7a6be3e commit e265201
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 24 deletions.
38 changes: 19 additions & 19 deletions locales/after_print_info.yml

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion locales/code_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -758,4 +758,23 @@ talk_to_me_lang:
uk: "Говоріть зі мною українською"
th: "พูดกับฉันเป็นภาษาไทย"
el: "Μίλα μου στα ελληνικά"
da: "Tal med mig på dansk"
da: "Tal med mig på dansk"

rendering_liquid_file:
en: rendering liquid file
zh_CN: 渲染 liquid 文件
zh_TW: 渲染 liquid 檔案
fr: rendu du fichier liquid
ja: liquid ファイルのレンダリング
es: renderizando archivo liquid
de: Rendering der Liquid-Datei
ru: рендеринг liquid файла
it: rendering del file liquid
pt: renderizando arquivo liquid
ko: liquid 파일 렌더링
no: rendering av liquid-fil
is: rendering liquid skrá
uk: рендеринг liquid файлу
th: การเรนเดอร์ไฟล์ liquid
el: απόδοση αρχείου liquid
da: rendering af liquid-fil
1 change: 1 addition & 0 deletions src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fn after_print_info(project_name: &String) {
success(t!("create_info", project_name = project_name).replace(r"\n", "\n"));
success(t!("create_success").replace(r"\n", "\n"));
success(t!("rust_version_tip"));
success(t!("cursor_rules_info").replace(r"\n", "\n"));
println!(); // a new line
}

Expand Down
5 changes: 3 additions & 2 deletions src/templates/classic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use anyhow::Result;
use liquid::model::Object;
use rust_i18n::t;

use crate::printer::warning;
use crate::printer::{success, warning};
use crate::{git, Project};

pub(crate) mod selection;
Expand Down Expand Up @@ -145,7 +145,8 @@ fn write_file(tmpl: &[u8], file_path: &Path, data: &Object) -> Result<()> {
fs::create_dir_all(parent)?;
}
if file_path.extension() == Some(OsStr::new("liquid")) {
println!("rendering liquid file: {:?}", file_path);
let msg = t!("rendering_liquid_file").replace(r"\n", "\n") + &format!(" {:?}", file_path);
success(msg);
let template = liquid::ParserBuilder::with_stdlib()
.build()
.expect("should create liquid parser")
Expand Down
Binary file modified templates/classic/_data/seaorm.sqlite
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,19 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new(Users::Password).string().not_null())
.to_owned(),
)
.await
.await?;

let insert = Query::insert()
.into_table(Users::Table)
.columns([Users::Id, Users::Username, Users::Password])
.values_panic([
"cdd0e080-5bb1-4442-b6f7-2ba60dbd0555".into(),
"zhangsan".into(),
"$argon2id$v=19$m=19456,t=2,p=1$rcosL5pOPdA2c7i4ZuLA4Q$s0JGh78UzMmu1qZMpVUA3b8kWYLXcZhw7uBfwhYDJ4A".into(),
])
.to_owned();

manager.exec_stmt(insert).await
}

async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
Expand Down
2 changes: 1 addition & 1 deletion templates/classic/sqlx/src/db/mod.rs.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use crate::config::DbConfig;
pub static SQLX_POOL: OnceLock<MySqlPool> = OnceLock::new();

pub async fn init(config: &DbConfig) {
let sqlx_pool = SqlitePool::connect(&config.url).await
let sqlx_pool = MySqlPool::connect(&config.url).await
.expect("Database connection failed.");
crate::db::SQLX_POOL
.set(sqlx_pool)
Expand Down

0 comments on commit e265201

Please sign in to comment.