@@ -4,14 +4,15 @@ use error::Result as CratesfyiResult;
4
4
use postgres:: { Connection , transaction:: Transaction , Error as PostgresError } ;
5
5
use schemamama:: { Migration , Migrator , Version } ;
6
6
use schemamama_postgres:: { PostgresAdapter , PostgresMigration } ;
7
- use std:: rc:: Rc ;
8
7
9
8
9
+ #[ derive( Copy , Clone ) ]
10
10
enum ApplyMode {
11
11
Permanent ,
12
12
Temporary ,
13
13
}
14
14
15
+ #[ derive( Copy , Clone ) ]
15
16
struct MigrationContext {
16
17
apply_mode : ApplyMode ,
17
18
}
@@ -40,7 +41,7 @@ impl MigrationContext {
40
41
macro_rules! migration {
41
42
( $context: expr, $version: expr, $description: expr, $up: expr, $down: expr $( , ) ?) => { {
42
43
struct Amigration {
43
- ctx: Rc < MigrationContext > ,
44
+ ctx: MigrationContext ,
44
45
} ;
45
46
impl Migration for Amigration {
46
47
fn version( & self ) -> Version {
@@ -74,7 +75,7 @@ pub fn migrate_temporary(version: Option<Version>, conn: &Connection) -> Cratesf
74
75
}
75
76
76
77
fn migrate_inner ( version : Option < Version > , conn : & Connection , apply_mode : ApplyMode ) -> CratesfyiResult < ( ) > {
77
- let context = Rc :: new ( MigrationContext { apply_mode } ) ;
78
+ let context = MigrationContext { apply_mode } ;
78
79
79
80
conn. execute (
80
81
& context. format_query (
@@ -88,7 +89,7 @@ fn migrate_inner(version: Option<Version>, conn: &Connection, apply_mode: ApplyM
88
89
89
90
let migrations: Vec < Box < dyn PostgresMigration > > = vec ! [
90
91
migration!(
91
- context. clone ( ) ,
92
+ context,
92
93
// version
93
94
1 ,
94
95
// description
@@ -205,7 +206,7 @@ fn migrate_inner(version: Option<Version>, conn: &Connection, apply_mode: ApplyM
205
206
owners, releases, crates, builds, queue, files, config;"
206
207
) ,
207
208
migration!(
208
- context. clone ( ) ,
209
+ context,
209
210
// version
210
211
2 ,
211
212
// description
@@ -216,7 +217,7 @@ fn migrate_inner(version: Option<Version>, conn: &Connection, apply_mode: ApplyM
216
217
"ALTER TABLE queue DROP COLUMN priority;"
217
218
) ,
218
219
migration!(
219
- context. clone ( ) ,
220
+ context,
220
221
// version
221
222
3 ,
222
223
// description
@@ -231,7 +232,7 @@ fn migrate_inner(version: Option<Version>, conn: &Connection, apply_mode: ApplyM
231
232
"DROP TABLE sandbox_overrides;"
232
233
) ,
233
234
migration!(
234
- context. clone ( ) ,
235
+ context,
235
236
4 ,
236
237
"Make more fields not null" ,
237
238
"ALTER TABLE releases ALTER COLUMN release_time SET NOT NULL,
@@ -242,7 +243,7 @@ fn migrate_inner(version: Option<Version>, conn: &Connection, apply_mode: ApplyM
242
243
ALTER COLUMN downloads DROP NOT NULL"
243
244
) ,
244
245
migration!(
245
- context. clone ( ) ,
246
+ context,
246
247
// version
247
248
5 ,
248
249
// description
0 commit comments