rust_ef/migration/
types.rs1#[derive(Debug, Clone)]
5pub struct Migration {
6 pub id: String,
7 pub description: String,
8 pub up_sql: String,
9 pub down_sql: String,
10}
11
12#[derive(Debug, Clone)]
15pub struct ModelSnapshot {
16 pub migration_id: String,
17 pub entity_types: Vec<SnapshotEntityType>,
18}
19
20#[derive(Debug, Clone, Default)]
22pub struct SnapshotEntityType {
23 pub type_name: String,
24 pub table_name: String,
25 pub columns: Vec<SnapshotColumn>,
26 pub indexes: Vec<SnapshotIndex>,
28 pub foreign_keys: Vec<SnapshotForeignKey>,
30 pub checks: Vec<SnapshotCheck>,
32 pub table_options: SnapshotTableOptions,
34 pub is_view: bool,
36 pub is_keyless: bool,
38 pub comment: Option<String>,
40}
41
42#[derive(Debug, Clone, PartialEq, Eq, Default)]
44pub struct SnapshotIndexColumn {
45 pub value: String,
47 pub is_expression: bool,
49}
50
51#[derive(Debug, Clone, PartialEq, Eq, Default)]
53pub struct SnapshotIndex {
54 pub name: String,
56 pub columns: Vec<SnapshotIndexColumn>,
58 pub is_unique: bool,
60 pub filter: Option<String>,
62 pub include: Vec<String>,
64}
65
66#[derive(Debug, Clone, PartialEq, Eq, Default)]
68pub struct SnapshotForeignKey {
69 pub name: String,
71 pub columns: Vec<String>,
73 pub referenced_table: String,
75 pub referenced_columns: Vec<String>,
77 pub on_delete: Option<String>,
79}
80
81#[derive(Debug, Clone, PartialEq, Eq, Default)]
83pub struct SnapshotCheck {
84 pub name: String,
85 pub expression: String,
86}
87
88#[derive(Debug, Clone, PartialEq, Eq, Default)]
90pub struct SnapshotTableOptions {
91 pub engine: Option<String>,
92 pub charset: Option<String>,
93 pub collate: Option<String>,
94}
95
96impl SnapshotTableOptions {
97 pub fn is_empty(&self) -> bool {
98 self.engine.is_none() && self.charset.is_none() && self.collate.is_none()
99 }
100}
101
102#[derive(Debug, Clone, PartialEq, Default)]
104pub struct SnapshotColumn {
105 pub field_name: String,
106 pub column_name: String,
107 pub type_name: String,
108 pub is_primary_key: bool,
109 pub is_required: bool,
110 pub is_foreign_key: bool,
111 pub max_length: Option<usize>,
112 pub is_auto_increment: bool,
113 pub is_sequence: bool,
115 pub sequence_name: Option<String>,
117 pub fk_referenced_table: Option<String>,
119 pub fk_referenced_column: Option<String>,
121 pub has_index: bool,
123 pub is_unique: bool,
125 pub fk_on_delete: Option<String>,
128 pub default_value: Option<String>,
130 pub column_type: Option<String>,
132 pub precision: Option<u32>,
134 pub scale: Option<u32>,
136 pub is_fixed_length: bool,
138 pub collation: Option<String>,
140 pub comment: Option<String>,
142 pub computed_sql: Option<String>,
144 pub computed_stored: bool,
146}