rootasrole_core/database/
versionning.rs1use semver::Version;
2use serde::{Deserialize, Serialize};
3use std::fmt::Debug;
4
5use super::migration::Migration;
6use crate::version;
7use crate::SettingsFile;
8
9use super::structs::*;
10
11#[derive(Deserialize, Serialize, Debug)]
12pub struct Versioning<T: Default + Debug> {
13 pub version: Version,
14 #[serde(default, flatten)]
15 pub data: T,
16}
17
18impl<T: Default + Debug> Versioning<T> {
19 pub fn new(data: T) -> Self {
20 Self {
21 version: version::PACKAGE_VERSION.to_owned().parse().unwrap(),
22 data,
23 }
24 }
25}
26
27impl<T: Default + Debug> Default for Versioning<T> {
28 fn default() -> Self {
29 Self {
30 version: version::PACKAGE_VERSION.to_owned().parse().unwrap(),
31 data: T::default(),
32 }
33 }
34}
35
36pub(crate) const JSON_MIGRATIONS: &[Migration<SConfig>] = &[];
37
38pub(crate) const SETTINGS_MIGRATIONS: &[Migration<SettingsFile>] = &[];