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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
//! DatabaseMigration model for Appwrite SDK
use serde::{Deserialize, Serialize};
/// Database Migration
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(test, derive(Default))]
pub struct DatabaseMigration {
/// Database migration ID.
#[serde(rename = "$id")]
pub id: String,
/// Migration creation time in ISO 8601 format.
#[serde(rename = "$createdAt")]
pub created_at: String,
/// Migration update time in ISO 8601 format.
#[serde(rename = "$updatedAt")]
pub updated_at: String,
/// Project ID that owns the migrating database.
#[serde(rename = "projectId")]
pub project_id: String,
/// Logical database ID being migrated.
#[serde(rename = "databaseId")]
pub database_id: String,
/// Dedicated compute specification provisioned for the migration target.
#[serde(rename = "specification")]
pub specification: String,
/// Migration phase. Possible values: pending, provisioned, capturing,
/// backfilling, catching_up, verifying, ready_to_cutover, cutover, soaking,
/// done, failed, rolled_back.
#[serde(rename = "phase")]
pub phase: String,
/// Number of times a migration step has failed and been recorded.
#[serde(rename = "attempt")]
pub attempt: i64,
/// Reason the most recent migration step failed, empty while none has.
#[serde(rename = "lastError")]
pub last_error: String,
/// Number of documents still pending replication to the target.
#[serde(rename = "lagDocuments")]
pub lag_documents: i64,
/// Time the migrated data was verified against the source in ISO 8601 format.
#[serde(rename = "verifiedAt")]
pub verified_at: String,
/// Time routing was flipped to the target in ISO 8601 format.
#[serde(rename = "cutoverAt")]
pub cutover_at: String,
/// Time the post-cutover soak window ends in ISO 8601 format.
#[serde(rename = "soakUntil")]
pub soak_until: String,
/// Whether the migration cuts over automatically once ready. Set when the
/// migration is created and never changed afterwards, so it always reports
/// what was asked for.
#[serde(rename = "autoCutover")]
pub auto_cutover: bool,
/// Whether a cutover has been requested and not yet attempted. Set by the
/// cutover endpoint and cleared when the attempt is made, so a cutover that
/// fails a check parks the migration again rather than retrying on its own.
#[serde(rename = "cutoverRequested")]
pub cutover_requested: bool,
/// Whether the migration is paused.
#[serde(rename = "paused")]
pub paused: bool,
}
impl DatabaseMigration {
/// Get id
pub fn id(&self) -> &String {
&self.id
}
/// Get created_at
pub fn created_at(&self) -> &String {
&self.created_at
}
/// Get updated_at
pub fn updated_at(&self) -> &String {
&self.updated_at
}
/// Get project_id
pub fn project_id(&self) -> &String {
&self.project_id
}
/// Get database_id
pub fn database_id(&self) -> &String {
&self.database_id
}
/// Get specification
pub fn specification(&self) -> &String {
&self.specification
}
/// Get phase
pub fn phase(&self) -> &String {
&self.phase
}
/// Get attempt
pub fn attempt(&self) -> &i64 {
&self.attempt
}
/// Get last_error
pub fn last_error(&self) -> &String {
&self.last_error
}
/// Get lag_documents
pub fn lag_documents(&self) -> &i64 {
&self.lag_documents
}
/// Get verified_at
pub fn verified_at(&self) -> &String {
&self.verified_at
}
/// Get cutover_at
pub fn cutover_at(&self) -> &String {
&self.cutover_at
}
/// Get soak_until
pub fn soak_until(&self) -> &String {
&self.soak_until
}
/// Get auto_cutover
pub fn auto_cutover(&self) -> &bool {
&self.auto_cutover
}
/// Get cutover_requested
pub fn cutover_requested(&self) -> &bool {
&self.cutover_requested
}
/// Get paused
pub fn paused(&self) -> &bool {
&self.paused
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_database_migration_creation() {
let _model = <DatabaseMigration as Default>::default();
let _ = _model.id();
let _ = _model.created_at();
let _ = _model.updated_at();
let _ = _model.project_id();
let _ = _model.database_id();
let _ = _model.specification();
let _ = _model.phase();
let _ = _model.attempt();
let _ = _model.last_error();
let _ = _model.lag_documents();
let _ = _model.verified_at();
let _ = _model.cutover_at();
let _ = _model.soak_until();
let _ = _model.auto_cutover();
let _ = _model.cutover_requested();
let _ = _model.paused();
}
#[test]
fn test_database_migration_serialization() {
let model = <DatabaseMigration as Default>::default();
let json = serde_json::to_string(&model);
assert!(json.is_ok());
let deserialized: Result<DatabaseMigration, _> = serde_json::from_str(&json.unwrap());
assert!(deserialized.is_ok());
}
}