]> nmode's Git Repositories - signal-cli/commitdiff
Create database tables with strict mode
authorAsamK <asamk@gmx.de>
Tue, 23 Aug 2022 17:41:02 +0000 (19:41 +0200)
committerAsamK <asamk@gmx.de>
Sun, 28 Aug 2022 14:06:13 +0000 (16:06 +0200)
lib/src/main/java/org/asamk/signal/manager/storage/AccountDatabase.java
lib/src/main/java/org/asamk/signal/manager/storage/groups/GroupStore.java
lib/src/main/java/org/asamk/signal/manager/storage/prekeys/PreKeyStore.java
lib/src/main/java/org/asamk/signal/manager/storage/prekeys/SignedPreKeyStore.java
lib/src/main/java/org/asamk/signal/manager/storage/recipients/RecipientStore.java
lib/src/main/java/org/asamk/signal/manager/storage/sendLog/MessageSendLogStore.java
lib/src/main/java/org/asamk/signal/manager/storage/stickers/StickerStore.java

index 5093b9be827debe3773dc86d973327a8a085505d..3c168860e14adb45b84a5f26cb341c5cb858d804 100644 (file)
@@ -64,9 +64,9 @@ public class AccountDatabase extends Database {
                                           color TEXT,
 
                                           expiration_time INTEGER NOT NULL DEFAULT 0,
-                                          blocked BOOLEAN NOT NULL DEFAULT FALSE,
-                                          archived BOOLEAN NOT NULL DEFAULT FALSE,
-                                          profile_sharing BOOLEAN NOT NULL DEFAULT FALSE,
+                                          blocked INTEGER NOT NULL DEFAULT FALSE,
+                                          archived INTEGER NOT NULL DEFAULT FALSE,
+                                          profile_sharing INTEGER NOT NULL DEFAULT FALSE,
 
                                           profile_last_update_timestamp INTEGER NOT NULL DEFAULT 0,
                                           profile_given_name TEXT,
@@ -77,7 +77,7 @@ public class AccountDatabase extends Database {
                                           profile_mobile_coin_address BLOB,
                                           profile_unidentified_access_mode TEXT,
                                           profile_capabilities TEXT
-                                        );
+                                        ) STRICT;
                                         """);
             }
         }
@@ -89,8 +89,8 @@ public class AccountDatabase extends Database {
                                           _id INTEGER PRIMARY KEY,
                                           pack_id BLOB UNIQUE NOT NULL,
                                           pack_key BLOB NOT NULL,
-                                          installed BOOLEAN NOT NULL DEFAULT FALSE
-                                        );
+                                          installed INTEGER NOT NULL DEFAULT FALSE
+                                        ) STRICT;
                                         """);
             }
         }
@@ -107,7 +107,7 @@ public class AccountDatabase extends Database {
                                           signature BLOB NOT NULL,
                                           timestamp INTEGER DEFAULT 0,
                                           UNIQUE(account_id_type, key_id)
-                                        );
+                                        ) STRICT;
                                         CREATE TABLE pre_key (
                                           _id INTEGER PRIMARY KEY,
                                           account_id_type INTEGER NOT NULL,
@@ -115,7 +115,7 @@ public class AccountDatabase extends Database {
                                           public_key BLOB NOT NULL,
                                           private_key BLOB NOT NULL,
                                           UNIQUE(account_id_type, key_id)
-                                        );
+                                        ) STRICT;
                                         """);
             }
         }
@@ -129,9 +129,9 @@ public class AccountDatabase extends Database {
                                           master_key BLOB NOT NULL,
                                           group_data BLOB,
                                           distribution_id BLOB UNIQUE NOT NULL,
-                                          blocked BOOLEAN NOT NULL DEFAULT FALSE,
-                                          permission_denied BOOLEAN NOT NULL DEFAULT FALSE
-                                        );
+                                          blocked INTEGER NOT NULL DEFAULT FALSE,
+                                          permission_denied INTEGER NOT NULL DEFAULT FALSE
+                                        ) STRICT;
                                         CREATE TABLE group_v1 (
                                           _id INTEGER PRIMARY KEY,
                                           group_id BLOB UNIQUE NOT NULL,
@@ -139,15 +139,15 @@ public class AccountDatabase extends Database {
                                           name TEXT,
                                           color TEXT,
                                           expiration_time INTEGER NOT NULL DEFAULT 0,
-                                          blocked BOOLEAN NOT NULL DEFAULT FALSE,
-                                          archived BOOLEAN NOT NULL DEFAULT FALSE
-                                        );
+                                          blocked INTEGER NOT NULL DEFAULT FALSE,
+                                          archived INTEGER NOT NULL DEFAULT FALSE
+                                        ) STRICT;
                                         CREATE TABLE group_v1_member (
                                           _id INTEGER PRIMARY KEY,
                                           group_id INTEGER NOT NULL REFERENCES group_v1 (_id) ON DELETE CASCADE,
                                           recipient_id INTEGER NOT NULL REFERENCES recipient (_id) ON DELETE CASCADE,
                                           UNIQUE(group_id, recipient_id)
-                                        );
+                                        ) STRICT;
                                         """);
             }
         }
@@ -162,7 +162,7 @@ public class AccountDatabase extends Database {
                                           device_id INTEGER NOT NULL,
                                           record BLOB NOT NULL,
                                           UNIQUE(account_id_type, recipient_id, device_id)
-                                        );
+                                        ) STRICT;
                                         """);
             }
         }
@@ -176,7 +176,7 @@ public class AccountDatabase extends Database {
                                           identity_key BLOB NOT NULL,
                                           added_timestamp INTEGER NOT NULL,
                                           trust_level INTEGER NOT NULL
-                                        );
+                                        ) STRICT;
                                         """);
             }
         }
@@ -192,7 +192,7 @@ public class AccountDatabase extends Database {
                                           record BLOB NOT NULL,
                                           created_timestamp INTEGER NOT NULL,
                                           UNIQUE(recipient_id, device_id, distribution_id)
-                                        );
+                                        ) STRICT;
                                         CREATE TABLE sender_key_shared (
                                           _id INTEGER PRIMARY KEY,
                                           recipient_id INTEGER NOT NULL REFERENCES recipient (_id) ON DELETE CASCADE,
@@ -200,7 +200,7 @@ public class AccountDatabase extends Database {
                                           distribution_id BLOB NOT NULL,
                                           timestamp INTEGER NOT NULL,
                                           UNIQUE(recipient_id, device_id, distribution_id)
-                                        );
+                                        ) STRICT;
                                         """);
             }
         }
@@ -208,7 +208,7 @@ public class AccountDatabase extends Database {
             logger.debug("Updating database: Adding urgent field");
             try (final var statement = connection.createStatement()) {
                 statement.executeUpdate("""
-                                        ALTER TABLE message_send_log_content ADD COLUMN urgent BOOLEAN NOT NULL DEFAULT TRUE;
+                                        ALTER TABLE message_send_log_content ADD COLUMN urgent INTEGER NOT NULL DEFAULT TRUE;
                                         """);
             }
         }
index e9db58f0ea42e7a421d9274bda4c4b9c277f0428..538ff2943c0e5e5f925a4306d90895f0e81889f4 100644 (file)
@@ -52,9 +52,9 @@ public class GroupStore {
                                       master_key BLOB NOT NULL,
                                       group_data BLOB,
                                       distribution_id BLOB UNIQUE NOT NULL,
-                                      blocked BOOLEAN NOT NULL DEFAULT FALSE,
-                                      permission_denied BOOLEAN NOT NULL DEFAULT FALSE
-                                    );
+                                      blocked INTEGER NOT NULL DEFAULT FALSE,
+                                      permission_denied INTEGER NOT NULL DEFAULT FALSE
+                                    ) STRICT;
                                     CREATE TABLE group_v1 (
                                       _id INTEGER PRIMARY KEY,
                                       group_id BLOB UNIQUE NOT NULL,
@@ -62,15 +62,15 @@ public class GroupStore {
                                       name TEXT,
                                       color TEXT,
                                       expiration_time INTEGER NOT NULL DEFAULT 0,
-                                      blocked BOOLEAN NOT NULL DEFAULT FALSE,
-                                      archived BOOLEAN NOT NULL DEFAULT FALSE
-                                    );
+                                      blocked INTEGER NOT NULL DEFAULT FALSE,
+                                      archived INTEGER NOT NULL DEFAULT FALSE
+                                    ) STRICT;
                                     CREATE TABLE group_v1_member (
                                       _id INTEGER PRIMARY KEY,
                                       group_id INTEGER NOT NULL REFERENCES group_v1 (_id) ON DELETE CASCADE,
                                       recipient_id INTEGER NOT NULL REFERENCES recipient (_id) ON DELETE CASCADE,
                                       UNIQUE(group_id, recipient_id)
-                                    );
+                                    ) STRICT;
                                     """);
         }
     }
index 205f4fa3d5e01e5862a34cd9aeb7e9b2b5cb248a..a70c6b8cee67ffb01f0d6575d6d15cbaacf97421 100644 (file)
@@ -35,7 +35,7 @@ public class PreKeyStore implements org.signal.libsignal.protocol.state.PreKeySt
                                       public_key BLOB NOT NULL,
                                       private_key BLOB NOT NULL,
                                       UNIQUE(account_id_type, key_id)
-                                    );
+                                    ) STRICT;
                                     """);
         }
     }
index 6c8787c92caedc5ebe44d37dcbd82282fff552d1..722bb56c598abeaa1c7d56c8ebef0fa79ec80431 100644 (file)
@@ -32,14 +32,14 @@ public class SignedPreKeyStore implements org.signal.libsignal.protocol.state.Si
             statement.executeUpdate("""
                                     CREATE TABLE signed_pre_key (
                                       _id INTEGER PRIMARY KEY,
-                                      account_id_type BLOB NOT NULL,
+                                      account_id_type INTEGER NOT NULL,
                                       key_id INTEGER NOT NULL,
                                       public_key BLOB NOT NULL,
                                       private_key BLOB NOT NULL,
                                       signature BLOB NOT NULL,
                                       timestamp INTEGER DEFAULT 0,
                                       UNIQUE(account_id_type, key_id)
-                                    );
+                                    ) STRICT;
                                     """);
         }
     }
index e0f142502c1be5f4aa7d3b29c7a5781128fe607c..45da42b12a59e642b1f3ea9a7375ff4fffb69279 100644 (file)
@@ -60,9 +60,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
                                       color TEXT,
 
                                       expiration_time INTEGER NOT NULL DEFAULT 0,
-                                      blocked BOOLEAN NOT NULL DEFAULT FALSE,
-                                      archived BOOLEAN NOT NULL DEFAULT FALSE,
-                                      profile_sharing BOOLEAN NOT NULL DEFAULT FALSE,
+                                      blocked INTEGER NOT NULL DEFAULT FALSE,
+                                      archived INTEGER NOT NULL DEFAULT FALSE,
+                                      profile_sharing INTEGER NOT NULL DEFAULT FALSE,
 
                                       profile_last_update_timestamp INTEGER NOT NULL DEFAULT 0,
                                       profile_given_name TEXT,
@@ -73,7 +73,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
                                       profile_mobile_coin_address BLOB,
                                       profile_unidentified_access_mode TEXT,
                                       profile_capabilities TEXT
-                                    );
+                                    ) STRICT;
                                     """);
         }
     }
@@ -711,7 +711,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
 
         final var profileKeyCredential = getExpiringProfileKeyCredential(connection, recipientId);
         if (profileKeyCredential == null) {
-            final var toBeMergedProfileKeyCredential = getExpiringProfileKeyCredential(connection, toBeMergedRecipientId);
+            final var toBeMergedProfileKeyCredential = getExpiringProfileKeyCredential(connection,
+                    toBeMergedRecipientId);
             storeExpiringProfileKeyCredential(connection, recipientId, toBeMergedProfileKeyCredential);
         }
 
index c7e6cdb18c2eed250f4b62f8a6e8af6af7eeb818..d0034d1b67b04e83e1b0836e1c8b4d8994e8fe4d 100644 (file)
@@ -73,8 +73,8 @@ public class MessageSendLogStore implements AutoCloseable {
                                       timestamp INTEGER NOT NULL,
                                       content BLOB NOT NULL,
                                       content_hint INTEGER NOT NULL,
-                                      urgent BOOLEAN NOT NULL
-                                    );
+                                      urgent INTEGER NOT NULL
+                                    ) STRICT;
                                     CREATE INDEX mslc_timestamp_index ON message_send_log_content (timestamp);
                                     CREATE INDEX msl_recipient_index ON message_send_log (uuid, device_id, content_id);
                                     CREATE INDEX msl_content_index ON message_send_log (content_id);
index aeed8ccdc1448e4dddf233eaba7f96a52da7f576..6667d9789c9f3a00edfb8713a73183800dfd4b45 100644 (file)
@@ -26,8 +26,8 @@ public class StickerStore {
                                       _id INTEGER PRIMARY KEY,
                                       pack_id BLOB UNIQUE NOT NULL,
                                       pack_key BLOB NOT NULL,
-                                      installed BOOLEAN NOT NULL DEFAULT FALSE
-                                    );
+                                      installed INTEGER NOT NULL DEFAULT FALSE
+                                    ) STRICT;
                                     """);
         }
     }