@@ -4,9 +4,6 @@ use clap::Clap;
4
4
pub struct Opt {
5
5
#[ clap( subcommand) ]
6
6
pub command : Command ,
7
-
8
- #[ clap( short = 'D' , long) ]
9
- pub database_url : Option < String > ,
10
7
}
11
8
12
9
#[ derive( Clap , Debug ) ]
@@ -36,6 +33,10 @@ pub enum Command {
36
33
/// Arguments to be passed to `cargo rustc ...`.
37
34
#[ clap( last = true ) ]
38
35
args : Vec < String > ,
36
+
37
+ /// Location of the DB, by default will be read from the DATABASE_URL env var
38
+ #[ clap( long, short = 'D' , env) ]
39
+ database_url : String ,
39
40
} ,
40
41
41
42
#[ clap( alias = "mig" ) ]
@@ -52,14 +53,22 @@ pub struct DatabaseOpt {
52
53
#[ derive( Clap , Debug ) ]
53
54
pub enum DatabaseCommand {
54
55
/// Creates the database specified in your DATABASE_URL.
55
- Create ,
56
+ Create {
57
+ /// Location of the DB, by default will be read from the DATABASE_URL env var
58
+ #[ clap( long, short = 'D' , env) ]
59
+ database_url : String ,
60
+ } ,
56
61
57
62
/// Drops the database specified in your DATABASE_URL.
58
63
Drop {
59
64
/// Automatic confirmation. Without this option, you will be prompted before dropping
60
65
/// your database.
61
66
#[ clap( short) ]
62
67
yes : bool ,
68
+
69
+ /// Location of the DB, by default will be read from the DATABASE_URL env var
70
+ #[ clap( long, short = 'D' , env) ]
71
+ database_url : String ,
63
72
} ,
64
73
65
74
/// Drops the database specified in your DATABASE_URL, re-creates it, and runs any pending migrations.
@@ -72,13 +81,21 @@ pub enum DatabaseCommand {
72
81
/// Path to folder containing migrations.
73
82
#[ clap( long, default_value = "migrations" ) ]
74
83
source : String ,
84
+
85
+ /// Location of the DB, by default will be read from the DATABASE_URL env var
86
+ #[ clap( long, short = 'D' , env) ]
87
+ database_url : String ,
75
88
} ,
76
89
77
90
/// Creates the database specified in your DATABASE_URL and runs any pending migrations.
78
91
Setup {
79
92
/// Path to folder containing migrations.
80
93
#[ clap( long, default_value = "migrations" ) ]
81
94
source : String ,
95
+
96
+ /// Location of the DB, by default will be read from the DATABASE_URL env var
97
+ #[ clap( long, short = 'D' , env) ]
98
+ database_url : String ,
82
99
} ,
83
100
}
84
101
@@ -115,6 +132,10 @@ pub enum MigrateCommand {
115
132
/// Ignore applied migrations that missing in the resolved migrations
116
133
#[ clap( long) ]
117
134
ignore_missing : bool ,
135
+
136
+ /// Location of the DB, by default will be read from the DATABASE_URL env var
137
+ #[ clap( long, short = 'D' , env) ]
138
+ database_url : String ,
118
139
} ,
119
140
120
141
/// Revert the latest migration with a down file.
@@ -126,10 +147,18 @@ pub enum MigrateCommand {
126
147
/// Ignore applied migrations that missing in the resolved migrations
127
148
#[ clap( long) ]
128
149
ignore_missing : bool ,
150
+
151
+ /// Location of the DB, by default will be read from the DATABASE_URL env var
152
+ #[ clap( long, short = 'D' , env) ]
153
+ database_url : String ,
129
154
} ,
130
155
131
156
/// List all available migrations.
132
- Info ,
157
+ Info {
158
+ /// Location of the DB, by default will be read from the DATABASE_URL env var
159
+ #[ clap( long, env) ]
160
+ database_url : String ,
161
+ } ,
133
162
134
163
/// Generate a `build.rs` to trigger recompilation when a new migration is added.
135
164
///
0 commit comments