Skip to main content

schema_diff/
change.rs

1use schema_model::model::column::Column;
2use schema_model::model::constraint::Constraint;
3use schema_model::model::key::Key;
4use schema_model::model::relation::Relation;
5use schema_model::model::view::View;
6
7#[derive(Debug, Clone)]
8pub enum SchemaChange {
9    AddTable {
10        table_name: String,
11    },
12    DropTable {
13        table_name: String,
14    },
15    RenameTable {
16        old_name: String,
17        new_name: String,
18    },
19    AddColumn {
20        table_name: String,
21        column: Column,
22    },
23    DropColumn {
24        table_name: String,
25        column_name: String,
26        rename_candidates: Vec<String>,
27    },
28    RenameColumn {
29        table_name: String,
30        old_name: String,
31        new_name: String,
32    },
33    ModifyColumn {
34        table_name: String,
35        old_column: Column,
36        new_column: Column,
37    },
38    AddKey {
39        table_name: String,
40        key: Key,
41        /// 1-based position of `key` among the sibling keys the create path numbers it
42        /// with - unique keys are numbered among the table's other unique keys, indexes
43        /// among the table's other indexes - so a migration can reproduce the exact
44        /// `ak_<table><n>` / `ix_<table><n>` name the create path would use.
45        ordinal: usize,
46    },
47    DropKey {
48        table_name: String,
49        key: Key,
50        /// See `AddKey::ordinal`.
51        ordinal: usize,
52    },
53    AddConstraint {
54        table_name: String,
55        constraint: Constraint,
56    },
57    DropConstraint {
58        table_name: String,
59        constraint_name: String,
60    },
61    AddRelation {
62        relation: Relation,
63        /// 1-based position of `relation` among its table's relations, matching the
64        /// create path's `fk_<table><n>` numbering.
65        ordinal: usize,
66    },
67    DropRelation {
68        relation: Relation,
69        /// See `AddRelation::ordinal`.
70        ordinal: usize,
71    },
72    AddView {
73        view: View,
74    },
75    DropView {
76        view_name: String,
77    },
78}