1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#[cfg(feature = "sqlx")]
mod from_postgres;
#[cfg(feature = "openapi")]
mod from_openapi;
#[cfg(feature = "openapi")]
pub use from_openapi::FromOpenApiOptions;
mod table;
mod r#type;
mod column;
mod index;
pub use column::Column;
pub use r#type::Type;
pub use table::Table;
use anyhow::Result;
use crate::migrate::{Migration, migrate, MigrationOptions};
#[derive(Debug)]
#[derive(Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Schema {
pub tables: Vec<Table>,
}
impl Schema {
pub fn migrate_to(self, desired: Schema, options: &MigrationOptions) -> Result<Migration> {
migrate(self, desired, options)
}
pub fn name_schema(&mut self, schema: &str) {
for table in &mut self.tables {
table.schema = Some(schema.to_string());
}
}
}