Browse Source

Change name

Cesar Rodas 1 year ago
parent
commit
8c5ae4c7d4
2 changed files with 19 additions and 19 deletions
  1. 7 7
      utxo/src/storage/sqlite/batch.rs
  2. 12 12
      utxo/src/storage/sqlite/mod.rs

+ 7 - 7
utxo/src/storage/sqlite/batch.rs

@@ -63,14 +63,14 @@ impl<'a> storage::Batch<'a> for Batch<'a> {
         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())
@@ -262,7 +262,7 @@ impl<'a> storage::Batch<'a> for Batch<'a> {
     async fn store_transaction(&mut self, transaction: &Transaction) -> Result<(), Error> {
         sqlx::query(
             r#"
-                INSERT INTO "blobs"("id", "transaction_id", "blob", "status", "created_at")
+                INSERT INTO "revisions"("revision_id", "transaction_id", "blob", "status", "created_at")
                 VALUES(?, ?, ?, ?, ?)
             "#,
         )
@@ -278,8 +278,8 @@ impl<'a> storage::Batch<'a> for Batch<'a> {
         if let Some(previous) = transaction.previous() {
             let r = sqlx::query(
                 r#"
-                UPDATE "transactions" SET "blob_id" = ?, "status" = ?
-                WHERE "transaction_id" = ? and "blob_id" = ?
+                UPDATE "transactions" SET "revision_id" = ?, "status" = ?
+                WHERE "transaction_id" = ? and "revision_id" = ?
                 "#,
             )
             .bind(transaction.revision_id.to_string())
@@ -296,7 +296,7 @@ impl<'a> storage::Batch<'a> for Batch<'a> {
         } else {
             sqlx::query(
                 r#"
-                INSERT INTO "transactions"("transaction_id", "blob_id", "status")
+                INSERT INTO "transactions"("transaction_id", "revision_id", "status")
                 VALUES(?, ?, ?)
             "#,
             )

+ 12 - 12
utxo/src/storage/sqlite/mod.rs

@@ -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"#,
             )