]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/db/Currency.java
working backup and restore of configuration settings
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / db / Currency.java
index 02e47760ecccfc3596213af8936326957017cda0..a9f799f867f87d10af30213cc30fc01b37f7e3c6 100644 (file)
@@ -20,9 +20,11 @@ package net.ktnx.mobileledger.db;
 import androidx.annotation.NonNull;
 import androidx.room.ColumnInfo;
 import androidx.room.Entity;
+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 +35,12 @@ public class Currency {
     @NonNull
     @ColumnInfo(name = "has_gap")
     private Boolean hasGap;
+    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;