laterite_admin/settings/
migrations.rs1use laterite_core::strata::*;
4
5use super::store::Settings;
6
7pub const MODULE_ID: &str = "laterite.settings";
9
10pub fn migrations() -> MigrationSet {
12 MigrationSet::new(MODULE_ID, vec![Box::new(CreateSettings)])
13}
14
15struct CreateSettings;
16
17#[async_trait(?Send)]
18impl Migration for CreateSettings {
19 fn name(&self) -> &str {
20 "0001_create_settings"
21 }
22 async fn up(&self, s: &mut Schema<'_>) -> CoreResult<()> {
23 s.exec(
26 Table::create()
27 .table(Settings::Table)
28 .if_not_exists()
29 .col(key_col(Settings::Code).not_null().primary_key())
30 .col(
31 ColumnDef::new(Settings::Value)
32 .text()
33 .not_null()
34 .default("{}"),
35 )
36 .col(ColumnDef::new(Settings::UpdatedAt).text().not_null())
37 .to_owned(),
38 )
39 .await
40 }
41 async fn down(&self, s: &mut Schema<'_>) -> CoreResult<()> {
42 s.exec(Table::drop().table(Settings::Table).to_owned())
43 .await
44 }
45}