|
@@ -37,13 +37,13 @@ impl SQLite {
|
|
|
r#"
|
|
|
CREATE TABLE IF NOT EXISTS "transactions" (
|
|
|
"transaction_id" VARCHAR(66) NOT NULL PRIMARY KEY,
|
|
|
- "blob_id" VARCHAR(66) NOT NULL,
|
|
|
+ "revision_id" VARCHAR(66) NOT NULL,
|
|
|
"status" VARCHAR(10) NOT NULL,
|
|
|
"created_at" DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
|
"updated_at" DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
|
);
|
|
|
- CREATE TABLE IF NOT EXISTS "blobs" (
|
|
|
- "id" VARCHAR(64) NOT NULL PRIMARY KEY,
|
|
|
+ CREATE TABLE IF NOT EXISTS "revisions" (
|
|
|
+ "revision_id" VARCHAR(64) NOT NULL PRIMARY KEY,
|
|
|
"transaction_id" VARCHAR(66) NOT NULL,
|
|
|
"previous_blob_id" BLOB,
|
|
|
"status" VARCHAR(30) NOT NULL,
|
|
@@ -243,14 +243,14 @@ impl Storage for SQLite {
|
|
|
let row = sqlx::query(
|
|
|
r#"
|
|
|
SELECT
|
|
|
- "t"."blob_id" as "current_id",
|
|
|
+ "t"."revision_id" as "current_id",
|
|
|
"b"."blob"
|
|
|
FROM
|
|
|
"transactions" as "t",
|
|
|
- "blobs" as "b"
|
|
|
+ "revisions" as "b"
|
|
|
WHERE
|
|
|
"t"."transaction_id" = ?
|
|
|
- AND "t"."blob_id" = "b"."id"
|
|
|
+ AND "t"."revision_id" = "b"."revision_id"
|
|
|
"#,
|
|
|
)
|
|
|
.bind(transaction_id.to_string())
|
|
@@ -291,16 +291,16 @@ impl Storage for SQLite {
|
|
|
let sql = if types.is_empty() {
|
|
|
r#"SELECT
|
|
|
"t"."transaction_id",
|
|
|
- "t"."blob_id",
|
|
|
+ "t"."revision_id",
|
|
|
"b"."blob"
|
|
|
FROM
|
|
|
"transaction_accounts" as "ta",
|
|
|
"transactions" as "t",
|
|
|
- "blobs" as "b"
|
|
|
+ "revisions" as "b"
|
|
|
WHERE
|
|
|
"ta"."account_id" = ?
|
|
|
AND "t"."transaction_id" = "ta"."transaction_id"
|
|
|
- AND "t"."blob_id" = "b"."id"
|
|
|
+ AND "t"."revision_id" = "b"."revision_id"
|
|
|
ORDER BY "ta"."id" DESC"#
|
|
|
.to_owned()
|
|
|
} else {
|
|
@@ -312,16 +312,16 @@ impl Storage for SQLite {
|
|
|
format!(
|
|
|
r#"SELECT
|
|
|
"t"."transaction_id",
|
|
|
- "t"."blob_id",
|
|
|
+ "t"."revision_id",
|
|
|
"b"."blob"
|
|
|
FROM
|
|
|
"transaction_accounts" as "ta",
|
|
|
"transactions" as "t",
|
|
|
- "blobs" as "b"
|
|
|
+ "revisions" as "b"
|
|
|
WHERE
|
|
|
"account_id" = ?
|
|
|
AND "t"."transaction_id" = "ta"."transaction_id"
|
|
|
- AND "t"."blob_id" = "b"."id"
|
|
|
+ AND "t"."revision_id" = "b"."revision_id"
|
|
|
AND "type" IN ({types})
|
|
|
ORDER BY "ta"."id" DESC"#,
|
|
|
)
|