]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/db/Currency.java
fix search previous transactions by description
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / db / Currency.java
index 02e47760ecccfc3596213af8936326957017cda0..855244396b3e9ca641c7d6ae3552c906305c39a1 100644 (file)
@@ -20,9 +20,12 @@ package net.ktnx.mobileledger.db;
 import androidx.annotation.NonNull;
 import androidx.room.ColumnInfo;
 import androidx.room.Entity;
+import androidx.room.Ignore;
+import androidx.room.Index;
 import androidx.room.PrimaryKey;
 
-@Entity(tableName = "currencies")
+@Entity(tableName = "currencies",
+        indices = {@Index(name = "currency_name_idx", unique = true, value = "name")})
 public class Currency {
     @PrimaryKey(autoGenerate = true)
     private long id;
@@ -33,6 +36,13 @@ public class Currency {
     @NonNull
     @ColumnInfo(name = "has_gap")
     private Boolean hasGap;
+    @Ignore
+    public Currency() {
+        id = 0;
+        name = "";
+        position = "after";
+        hasGap = true;
+    }
     public Currency(long id, @NonNull String name, @NonNull String position,
                     @NonNull Boolean hasGap) {
         this.id = id;