Skip to content

Commit 86bd0c6

Browse files
authored
Merge pull request #14 from getsentry/sqlx-migrations
feat(store): Use sqlx migrations
2 parents c2d3762 + f85f4ee commit 86bd0c6

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// generated by `sqlx migrate build-script`
2+
fn main() {
3+
// trigger recompilation when a new migration is added
4+
println!("cargo:rerun-if-changed=migrations");
5+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CREATE TABLE IF NOT EXISTS inflight_taskactivations (
2+
id UUID NOT NULL PRIMARY KEY,
3+
activation BLOB NOT NULL,
4+
offset BIGINTEGER NOT NULL,
5+
added_at DATETIME NOT NULL,
6+
deadletter_at DATETIME,
7+
processing_deadline_duration INTEGER NOT NULL,
8+
processing_deadline DATETIME,
9+
status INTEGER NOT NULL
10+
);

migrations/1730926801-initial.sql

Whitespace-only changes.

src/inflight_task_store.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,7 @@ impl InflightTaskStore {
8080
}
8181
let sqlite_pool = SqlitePool::connect(url).await?;
8282

83-
sqlx::query(
84-
"CREATE TABLE IF NOT EXISTS inflight_taskactivations (
85-
id UUID NOT NULL PRIMARY KEY,
86-
activation BLOB NOT NULL,
87-
offset BIGINTEGER NOT NULL,
88-
added_at DATETIME NOT NULL,
89-
deadletter_at DATETIME,
90-
processing_deadline_duration INTEGER NOT NULL,
91-
processing_deadline DATETIME,
92-
status INTEGER NOT NULL
93-
);",
94-
)
95-
.execute(&sqlite_pool)
96-
.await?;
83+
sqlx::migrate!("./migrations").run(&sqlite_pool).await?;
9784

9885
Ok(Self { sqlite_pool })
9986
}

0 commit comments

Comments
 (0)