aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/apps.rs4
-rw-r--r--src/contrib/admin/migrations/m_0001_initial.rs10
-rw-r--r--src/contrib/admin/migrations/mod.rs3
-rw-r--r--src/contrib/admin/mod.rs3
-rw-r--r--src/db/migration/mod.rs12
-rw-r--r--src/db/mod.rs1
6 files changed, 31 insertions, 2 deletions
diff --git a/src/apps.rs b/src/apps.rs
index 26c6124..785ce8c 100644
--- a/src/apps.rs
+++ b/src/apps.rs
@@ -1,3 +1,5 @@
-pub struct AppConfig {
+use crate::db::migration::Migration;
+pub struct AppConfig {
+ pub migrations: &'static [Migration],
}
diff --git a/src/contrib/admin/migrations/m_0001_initial.rs b/src/contrib/admin/migrations/m_0001_initial.rs
new file mode 100644
index 0000000..6fed631
--- /dev/null
+++ b/src/contrib/admin/migrations/m_0001_initial.rs
@@ -0,0 +1,10 @@
+use crate::db::migration::{Migration, DatabaseChange};
+
+pub const MIGRATION: Migration = Migration {
+ id: 1,
+ name: "initial",
+ prereqs: &[],
+ changes: &[
+ DatabaseChange::CreateModel,
+ ],
+};
diff --git a/src/contrib/admin/migrations/mod.rs b/src/contrib/admin/migrations/mod.rs
new file mode 100644
index 0000000..5ecbb82
--- /dev/null
+++ b/src/contrib/admin/migrations/mod.rs
@@ -0,0 +1,3 @@
+use crate::db::migration::{Migration, gather};
+
+gather!();
diff --git a/src/contrib/admin/mod.rs b/src/contrib/admin/mod.rs
index 0f7e880..5098a4a 100644
--- a/src/contrib/admin/mod.rs
+++ b/src/contrib/admin/mod.rs
@@ -1,7 +1,8 @@
use crate::apps::AppConfig;
+mod migrations;
pub mod site;
pub const APP: AppConfig = AppConfig {
-
+ migrations: migrations::migrations,
};
diff --git a/src/db/migration/mod.rs b/src/db/migration/mod.rs
new file mode 100644
index 0000000..d53f46b
--- /dev/null
+++ b/src/db/migration/mod.rs
@@ -0,0 +1,12 @@
+pub use tosin_macros::gather_migrations as gather;
+
+pub struct Migration {
+ pub id: usize,
+ pub name: &'static str,
+ pub prereqs: &'static [(&'static str, usize)],
+ pub changes: &'static [DatabaseChange],
+}
+
+pub enum DatabaseChange {
+ CreateModel,
+}
diff --git a/src/db/mod.rs b/src/db/mod.rs
index b6528f5..05c38df 100644
--- a/src/db/mod.rs
+++ b/src/db/mod.rs
@@ -1,2 +1,3 @@
pub mod backend;
+pub mod migration;
pub mod models;