From 1be789f25f66af82e36106430497c400753eff81 Mon Sep 17 00:00:00 2001 From: abdo Date: Sat, 9 Jan 2021 14:36:38 +0300 Subject: [PATCH] Move sql code for upgrading to schema 17 to a separate file --- rslib/src/storage/tag/mod.rs | 13 ++----------- rslib/src/storage/upgrades/schema17_upgrade.sql | 7 +++++++ 2 files changed, 9 insertions(+), 11 deletions(-) create mode 100644 rslib/src/storage/upgrades/schema17_upgrade.sql diff --git a/rslib/src/storage/tag/mod.rs b/rslib/src/storage/tag/mod.rs index 8d9817856..bfbbce227 100644 --- a/rslib/src/storage/tag/mod.rs +++ b/rslib/src/storage/tag/mod.rs @@ -171,17 +171,8 @@ impl SqliteStorage { }) })? .collect::>>()?; - self.db.execute_batch( - " - drop table tags; - create table tags ( - id integer primary key not null, - name text not null collate unicase, - usn integer not null, - config blob not null - ); - ", - )?; + self.db + .execute_batch(include_str!["../upgrades/schema17_upgrade.sql"])?; tags.into_iter().try_for_each(|mut tag| -> Result<()> { tag.name = human_tag_name_to_native(&tag.name); self.register_tag(&mut tag) diff --git a/rslib/src/storage/upgrades/schema17_upgrade.sql b/rslib/src/storage/upgrades/schema17_upgrade.sql new file mode 100644 index 000000000..a324181f9 --- /dev/null +++ b/rslib/src/storage/upgrades/schema17_upgrade.sql @@ -0,0 +1,7 @@ +drop table tags; +create table tags ( + id integer primary key not null, + name text not null collate unicase, + usn integer not null, + config blob not null +); \ No newline at end of file