toolu_orm_core/diff/
operation.rs1use crate::column::{ColumnDef, ColumnType};
4use crate::index::IndexDef;
5use crate::snapshot::ForeignKeyDef;
6use crate::table::TableDef;
7
8#[derive(Debug, Clone, PartialEq)]
9pub enum ColumnChange {
10 Type {
11 column: String,
12 old: ColumnType,
13 new: ColumnType,
14 },
15 Default {
16 column: String,
17 old: Option<String>,
18 new: Option<String>,
19 },
20 Nullable {
21 column: String,
22 old: bool,
23 new: bool,
24 },
25 Unique {
26 column: String,
27 old: bool,
28 new: bool,
29 },
30}
31
32#[derive(Debug, Clone, PartialEq)]
33pub enum Operation {
34 CreateEnum {
35 name: String,
36 variants: Vec<String>,
37 },
38 AlterEnum {
39 name: String,
40 added: Vec<String>,
41 removed: Vec<String>,
42 },
43 DropEnum {
44 name: String,
45 },
46 CreateTable {
47 table: TableDef,
48 },
49 DropTable {
50 name: String,
51 },
52 RenameTable {
53 old: String,
54 new: String,
55 },
56 AddColumn {
57 table: String,
58 column: ColumnDef,
59 },
60 DropColumn {
61 table: String,
62 column: String,
63 },
64 RenameColumn {
65 table: String,
66 old: String,
67 new: String,
68 },
69 AlterColumn {
70 table: String,
71 changes: Vec<ColumnChange>,
72 table_def: TableDef,
73 },
74 CreateIndex {
75 table: String,
76 index: IndexDef,
77 },
78 DropIndex {
79 name: String,
80 },
81 AddForeignKey {
82 table: String,
83 fk: ForeignKeyDef,
84 },
85 DropForeignKey {
86 table: String,
87 name: String,
88 },
89 AddCheckConstraint {
90 table: String,
91 name: String,
92 expr: String,
93 },
94 DropCheckConstraint {
95 table: String,
96 name: String,
97 },
98}