Skip to content

Commit e265201

Browse files
committed
seaorm 迁移增加种子数据
1 parent 7a6be3e commit e265201

File tree

7 files changed

+57
-24
lines changed

7 files changed

+57
-24
lines changed

locales/after_print_info.yml

Lines changed: 19 additions & 19 deletions
Large diffs are not rendered by default.

locales/code_comment.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,4 +758,23 @@ talk_to_me_lang:
758758
uk: "Говоріть зі мною українською"
759759
th: "พูดกับฉันเป็นภาษาไทย"
760760
el: "Μίλα μου στα ελληνικά"
761-
da: "Tal med mig på dansk"
761+
da: "Tal med mig på dansk"
762+
763+
rendering_liquid_file:
764+
en: rendering liquid file
765+
zh_CN: 渲染 liquid 文件
766+
zh_TW: 渲染 liquid 檔案
767+
fr: rendu du fichier liquid
768+
ja: liquid ファイルのレンダリング
769+
es: renderizando archivo liquid
770+
de: Rendering der Liquid-Datei
771+
ru: рендеринг liquid файла
772+
it: rendering del file liquid
773+
pt: renderizando arquivo liquid
774+
ko: liquid 파일 렌더링
775+
no: rendering av liquid-fil
776+
is: rendering liquid skrá
777+
uk: рендеринг liquid файлу
778+
th: การเรนเดอร์ไฟล์ liquid
779+
el: απόδοση αρχείου liquid
780+
da: rendering af liquid-fil

src/project.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ fn after_print_info(project_name: &String) {
2929
success(t!("create_info", project_name = project_name).replace(r"\n", "\n"));
3030
success(t!("create_success").replace(r"\n", "\n"));
3131
success(t!("rust_version_tip"));
32+
success(t!("cursor_rules_info").replace(r"\n", "\n"));
3233
println!(); // a new line
3334
}
3435

src/templates/classic/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use anyhow::Result;
77
use liquid::model::Object;
88
use rust_i18n::t;
99

10-
use crate::printer::warning;
10+
use crate::printer::{success, warning};
1111
use crate::{git, Project};
1212

1313
pub(crate) mod selection;
@@ -145,7 +145,8 @@ fn write_file(tmpl: &[u8], file_path: &Path, data: &Object) -> Result<()> {
145145
fs::create_dir_all(parent)?;
146146
}
147147
if file_path.extension() == Some(OsStr::new("liquid")) {
148-
println!("rendering liquid file: {:?}", file_path);
148+
let msg = t!("rendering_liquid_file").replace(r"\n", "\n") + &format!(" {:?}", file_path);
149+
success(msg);
149150
let template = liquid::ParserBuilder::with_stdlib()
150151
.build()
151152
.expect("should create liquid parser")
0 Bytes
Binary file not shown.

templates/classic/seaorm/migration/src/m20220101_000001_create_table.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,19 @@ impl MigrationTrait for Migration {
2626
.col(ColumnDef::new(Users::Password).string().not_null())
2727
.to_owned(),
2828
)
29-
.await
29+
.await?;
30+
31+
let insert = Query::insert()
32+
.into_table(Users::Table)
33+
.columns([Users::Id, Users::Username, Users::Password])
34+
.values_panic([
35+
"cdd0e080-5bb1-4442-b6f7-2ba60dbd0555".into(),
36+
"zhangsan".into(),
37+
"$argon2id$v=19$m=19456,t=2,p=1$rcosL5pOPdA2c7i4ZuLA4Q$s0JGh78UzMmu1qZMpVUA3b8kWYLXcZhw7uBfwhYDJ4A".into(),
38+
])
39+
.to_owned();
40+
41+
manager.exec_stmt(insert).await
3042
}
3143

3244
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {

templates/classic/sqlx/src/db/mod.rs.liquid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use crate::config::DbConfig;
4444
pub static SQLX_POOL: OnceLock<MySqlPool> = OnceLock::new();
4545

4646
pub async fn init(config: &DbConfig) {
47-
let sqlx_pool = SqlitePool::connect(&config.url).await
47+
let sqlx_pool = MySqlPool::connect(&config.url).await
4848
.expect("Database connection failed.");
4949
crate::db::SQLX_POOL
5050
.set(sqlx_pool)

0 commit comments

Comments
 (0)