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