From 77f3a9ae5a2ce308a3a8973e2d444e3a6e577914 Mon Sep 17 00:00:00 2001 From: Dotan Nahum Date: Wed, 7 Aug 2024 10:05:15 +0300 Subject: [PATCH] docs: clarify data fixes --- docs-site/content/docs/the-app/models.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/docs-site/content/docs/the-app/models.md b/docs-site/content/docs/the-app/models.md index 076336343..2b5dbdfc0 100644 --- a/docs-site/content/docs/the-app/models.md +++ b/docs-site/content/docs/the-app/models.md @@ -267,24 +267,25 @@ You can copy some of this code for adding an index ### Create a data fix -Creating a data fix in a migration is easy - just `use` your models as you would otherwise: +Creating a data fix in a migration is easy - just use SQL statements as you like: ```rust async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { let db = manager.get_connection(); + + // issue SQL queries with `db` + // https://www.sea-ql.org/SeaORM/docs/basic-crud/raw-sql/#use-raw-query--execute-interface - cake::ActiveModel { - name: Set("Cheesecake".to_owned()), - ..Default::default() - } - .insert(db) - .await?; Ok(()) } ``` -Having said that, it's up to you to code your data fixes in a `task` or `migration` or an ad-hoc `playground`. +Having said that, it's up to you to code your data fixes in: + +* `task` - where you can use high level models +* `migration` - where you can both change structure and fix data stemming from it with raw SQL +* or an ad-hoc `playground` - where you can use high level models or experiment with things ## Validation