1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(Batches::Table)
.if_not_exists()
.col(
ColumnDef::new(Batches::Id)
.string()
.not_null()
.primary_key(),
)
.col(
ColumnDef::new(Batches::Object)
.string()
.not_null()
.default("batch"),
)
.col(ColumnDef::new(Batches::Endpoint).string().not_null())
.col(ColumnDef::new(Batches::InputFileId).string().null())
.col(
ColumnDef::new(Batches::CompletionWindow)
.string()
.not_null(),
)
.col(ColumnDef::new(Batches::Status).string().not_null())
.col(ColumnDef::new(Batches::OutputFileId).string().null())
.col(ColumnDef::new(Batches::ErrorFileId).string().null())
.col(
ColumnDef::new(Batches::CreatedAt)
.timestamp_with_time_zone()
.not_null()
.default(Expr::current_timestamp()),
)
.col(
ColumnDef::new(Batches::InProgressAt)
.timestamp_with_time_zone()
.null(),
)
.col(
ColumnDef::new(Batches::FinalizingAt)
.timestamp_with_time_zone()
.null(),
)
.col(
ColumnDef::new(Batches::CompletedAt)
.timestamp_with_time_zone()
.null(),
)
.col(
ColumnDef::new(Batches::FailedAt)
.timestamp_with_time_zone()
.null(),
)
.col(
ColumnDef::new(Batches::ExpiredAt)
.timestamp_with_time_zone()
.null(),
)
.col(
ColumnDef::new(Batches::CancellingAt)
.timestamp_with_time_zone()
.null(),
)
.col(
ColumnDef::new(Batches::CancelledAt)
.timestamp_with_time_zone()
.null(),
)
.col(ColumnDef::new(Batches::RequestCountsTotal).integer().null())
.col(
ColumnDef::new(Batches::RequestCountsCompleted)
.integer()
.null(),
)
.col(
ColumnDef::new(Batches::RequestCountsFailed)
.integer()
.null(),
)
.col(ColumnDef::new(Batches::Metadata).text().null())
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(Batches::Table).to_owned())
.await
}
}
#[derive(DeriveIden)]
enum Batches {
Table,
Id,
Object,
Endpoint,
InputFileId,
CompletionWindow,
Status,
OutputFileId,
ErrorFileId,
CreatedAt,
InProgressAt,
FinalizingAt,
CompletedAt,
FailedAt,
ExpiredAt,
CancellingAt,
CancelledAt,
RequestCountsTotal,
RequestCountsCompleted,
RequestCountsFailed,
Metadata,
}