From bc874c9d1363d3bf8865ea7a629eb976e23386b3 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Wed, 30 Jun 2021 16:31:21 -0600 Subject: use the actual path to the app dir for make_migrations --- examples/tutorial01/polls/mod.rs | 1 + .../tutorial02/polls/migrations/m_0001_auto.rs | 34 ++++++++++++++++++++++ examples/tutorial02/polls/mod.rs | 1 + 3 files changed, 36 insertions(+) create mode 100644 examples/tutorial02/polls/migrations/m_0001_auto.rs (limited to 'examples') diff --git a/examples/tutorial01/polls/mod.rs b/examples/tutorial01/polls/mod.rs index 7f02b17..44db04b 100644 --- a/examples/tutorial01/polls/mod.rs +++ b/examples/tutorial01/polls/mod.rs @@ -10,6 +10,7 @@ pub use urls::urls; #[allow(dead_code)] pub const APP: AppConfig = AppConfig { name: module_path!(), + mod_rs_path: file!(), models: models::ALL, migrations: migrations::ALL, }; diff --git a/examples/tutorial02/polls/migrations/m_0001_auto.rs b/examples/tutorial02/polls/migrations/m_0001_auto.rs new file mode 100644 index 0000000..7fa7de0 --- /dev/null +++ b/examples/tutorial02/polls/migrations/m_0001_auto.rs @@ -0,0 +1,34 @@ +use tosin::db::migration::Migration; + +pub const MIGRATION: Migration = Migration { + id: 1usize, + name: "auto", + prereqs: &[], + changes: &[ + DatabaseChange::CreateModel { + name: "Question", + fields: &[ + Field::IntField { name: "id" }, + Field::CharField { + name: "question_text", + max_length: Some(200usize), + }, + Field::DateTimeField { name: "pub_date" }, + ], + options: &[], + }, + DatabaseChange::CreateModel { + name: "Choice", + fields: &[ + Field::IntField { name: "id" }, + Field::IntField { name: "question" }, + Field::CharField { + name: "choice_text", + max_length: Some(200usize), + }, + Field::IntField { name: "votes" }, + ], + options: &[], + }, + ], +}; diff --git a/examples/tutorial02/polls/mod.rs b/examples/tutorial02/polls/mod.rs index 2c50e84..0e81062 100644 --- a/examples/tutorial02/polls/mod.rs +++ b/examples/tutorial02/polls/mod.rs @@ -9,6 +9,7 @@ pub use urls::urls; pub const APP: AppConfig = AppConfig { name: module_path!(), + mod_rs_path: file!(), models: models::ALL, migrations: migrations::ALL, }; -- cgit v1.2.3