Skip to content

Commit 9556b7b

Browse files
jyn514Joshua Nelson
authored and
Joshua Nelson
committed
Don't use unnecessary Rc
1 parent 6f2be2c commit 9556b7b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/db/migrate.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ use error::Result as CratesfyiResult;
44
use postgres::{Connection, transaction::Transaction, Error as PostgresError};
55
use schemamama::{Migration, Migrator, Version};
66
use schemamama_postgres::{PostgresAdapter, PostgresMigration};
7-
use std::rc::Rc;
87

98

9+
#[derive(Copy, Clone)]
1010
enum ApplyMode {
1111
Permanent,
1212
Temporary,
1313
}
1414

15+
#[derive(Copy, Clone)]
1516
struct MigrationContext {
1617
apply_mode: ApplyMode,
1718
}
@@ -40,7 +41,7 @@ impl MigrationContext {
4041
macro_rules! migration {
4142
($context:expr, $version:expr, $description:expr, $up:expr, $down:expr $(,)?) => {{
4243
struct Amigration {
43-
ctx: Rc<MigrationContext>,
44+
ctx: MigrationContext,
4445
};
4546
impl Migration for Amigration {
4647
fn version(&self) -> Version {
@@ -74,7 +75,7 @@ pub fn migrate_temporary(version: Option<Version>, conn: &Connection) -> Cratesf
7475
}
7576

7677
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 };
7879

7980
conn.execute(
8081
&context.format_query(
@@ -88,7 +89,7 @@ fn migrate_inner(version: Option<Version>, conn: &Connection, apply_mode: ApplyM
8889

8990
let migrations: Vec<Box<dyn PostgresMigration>> = vec![
9091
migration!(
91-
context.clone(),
92+
context,
9293
// version
9394
1,
9495
// description
@@ -205,7 +206,7 @@ fn migrate_inner(version: Option<Version>, conn: &Connection, apply_mode: ApplyM
205206
owners, releases, crates, builds, queue, files, config;"
206207
),
207208
migration!(
208-
context.clone(),
209+
context,
209210
// version
210211
2,
211212
// description
@@ -216,7 +217,7 @@ fn migrate_inner(version: Option<Version>, conn: &Connection, apply_mode: ApplyM
216217
"ALTER TABLE queue DROP COLUMN priority;"
217218
),
218219
migration!(
219-
context.clone(),
220+
context,
220221
// version
221222
3,
222223
// description
@@ -231,7 +232,7 @@ fn migrate_inner(version: Option<Version>, conn: &Connection, apply_mode: ApplyM
231232
"DROP TABLE sandbox_overrides;"
232233
),
233234
migration!(
234-
context.clone(),
235+
context,
235236
4,
236237
"Make more fields not null",
237238
"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
242243
ALTER COLUMN downloads DROP NOT NULL"
243244
),
244245
migration!(
245-
context.clone(),
246+
context,
246247
// version
247248
5,
248249
// description

0 commit comments

Comments
 (0)