runique/migration/primary_key/
mod.rs1use sea_query::ColumnType;
3
4#[derive(Debug, Clone)]
6pub struct PrimaryKeyDef {
7 pub name: String,
8 pub col_type: ColumnType,
9 pub auto_increment: bool,
10}
11
12impl PrimaryKeyDef {
13 pub fn new(name: impl Into<String>) -> Self {
15 Self {
16 name: name.into(),
17 col_type: ColumnType::Integer,
18 auto_increment: true,
19 }
20 }
21
22 pub fn i32(mut self) -> Self {
24 self.col_type = ColumnType::Integer;
25 self
26 }
27
28 pub fn i64(mut self) -> Self {
30 self.col_type = ColumnType::BigInteger;
31 self
32 }
33
34 pub fn uuid(mut self) -> Self {
37 self.col_type = ColumnType::Uuid;
38 self.auto_increment = false;
39 self
40 }
41
42 pub fn auto_increment(mut self) -> Self {
44 self.auto_increment = true;
45 self
46 }
47
48 pub fn no_auto_increment(mut self) -> Self {
51 self.auto_increment = false;
52 self
53 }
54}