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
//! A Rust migration has two simple requirements:
//!
//! * A unit struct `TernMigration` that derives `Migration`. It can
//! optionally have the attribute `tern(no_transaction)`, which means
//! that the query will not be ran in a transaction.
//! * The struct `TernMigration` needs to implement the trait `QueryBuilder`,
//! which tells the runtime what to do to construct the query it needs to run
//! the actual migration.
//!
//! The associated `Ctx` in the query builder is whatever you've defined the
//! migration context to be. It's the thing deriving `MigrationContext`. In
//! this example, it has the database connection type and `GetEnvVar`. The
//! connection type is of course required, but anything additional is up to the
//! user according to the needs of the migration. For this example, `GetEnvVar`
//! is just a type that can get an environment variable.
//!
//! The query for this migration depends on the current time and place; it needs
//! whatever the $USER is and the maximum value of the `z` column in `dmd_test`.
//! So the query has to be built dynamically at the time when the migration is
//! applied, which is what `QueryBuilder` exists for.
use Migration;
use ;
use ;
use ExampleContext;
;