mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Create database tables with strict mode
This commit is contained in:
parent
280d8d7f10
commit
adcc88823f
7 changed files with 40 additions and 39 deletions
|
@ -64,9 +64,9 @@ public class AccountDatabase extends Database {
|
||||||
color TEXT,
|
color TEXT,
|
||||||
|
|
||||||
expiration_time INTEGER NOT NULL DEFAULT 0,
|
expiration_time INTEGER NOT NULL DEFAULT 0,
|
||||||
blocked BOOLEAN NOT NULL DEFAULT FALSE,
|
blocked INTEGER NOT NULL DEFAULT FALSE,
|
||||||
archived BOOLEAN NOT NULL DEFAULT FALSE,
|
archived INTEGER NOT NULL DEFAULT FALSE,
|
||||||
profile_sharing BOOLEAN NOT NULL DEFAULT FALSE,
|
profile_sharing INTEGER NOT NULL DEFAULT FALSE,
|
||||||
|
|
||||||
profile_last_update_timestamp INTEGER NOT NULL DEFAULT 0,
|
profile_last_update_timestamp INTEGER NOT NULL DEFAULT 0,
|
||||||
profile_given_name TEXT,
|
profile_given_name TEXT,
|
||||||
|
@ -77,7 +77,7 @@ public class AccountDatabase extends Database {
|
||||||
profile_mobile_coin_address BLOB,
|
profile_mobile_coin_address BLOB,
|
||||||
profile_unidentified_access_mode TEXT,
|
profile_unidentified_access_mode TEXT,
|
||||||
profile_capabilities TEXT
|
profile_capabilities TEXT
|
||||||
);
|
) STRICT;
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,8 +89,8 @@ public class AccountDatabase extends Database {
|
||||||
_id INTEGER PRIMARY KEY,
|
_id INTEGER PRIMARY KEY,
|
||||||
pack_id BLOB UNIQUE NOT NULL,
|
pack_id BLOB UNIQUE NOT NULL,
|
||||||
pack_key BLOB 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,
|
signature BLOB NOT NULL,
|
||||||
timestamp INTEGER DEFAULT 0,
|
timestamp INTEGER DEFAULT 0,
|
||||||
UNIQUE(account_id_type, key_id)
|
UNIQUE(account_id_type, key_id)
|
||||||
);
|
) STRICT;
|
||||||
CREATE TABLE pre_key (
|
CREATE TABLE pre_key (
|
||||||
_id INTEGER PRIMARY KEY,
|
_id INTEGER PRIMARY KEY,
|
||||||
account_id_type INTEGER NOT NULL,
|
account_id_type INTEGER NOT NULL,
|
||||||
|
@ -115,7 +115,7 @@ public class AccountDatabase extends Database {
|
||||||
public_key BLOB NOT NULL,
|
public_key BLOB NOT NULL,
|
||||||
private_key BLOB NOT NULL,
|
private_key BLOB NOT NULL,
|
||||||
UNIQUE(account_id_type, key_id)
|
UNIQUE(account_id_type, key_id)
|
||||||
);
|
) STRICT;
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,9 +129,9 @@ public class AccountDatabase extends Database {
|
||||||
master_key BLOB NOT NULL,
|
master_key BLOB NOT NULL,
|
||||||
group_data BLOB,
|
group_data BLOB,
|
||||||
distribution_id BLOB UNIQUE NOT NULL,
|
distribution_id BLOB UNIQUE NOT NULL,
|
||||||
blocked BOOLEAN NOT NULL DEFAULT FALSE,
|
blocked INTEGER NOT NULL DEFAULT FALSE,
|
||||||
permission_denied BOOLEAN NOT NULL DEFAULT FALSE
|
permission_denied INTEGER NOT NULL DEFAULT FALSE
|
||||||
);
|
) STRICT;
|
||||||
CREATE TABLE group_v1 (
|
CREATE TABLE group_v1 (
|
||||||
_id INTEGER PRIMARY KEY,
|
_id INTEGER PRIMARY KEY,
|
||||||
group_id BLOB UNIQUE NOT NULL,
|
group_id BLOB UNIQUE NOT NULL,
|
||||||
|
@ -139,15 +139,15 @@ public class AccountDatabase extends Database {
|
||||||
name TEXT,
|
name TEXT,
|
||||||
color TEXT,
|
color TEXT,
|
||||||
expiration_time INTEGER NOT NULL DEFAULT 0,
|
expiration_time INTEGER NOT NULL DEFAULT 0,
|
||||||
blocked BOOLEAN NOT NULL DEFAULT FALSE,
|
blocked INTEGER NOT NULL DEFAULT FALSE,
|
||||||
archived BOOLEAN NOT NULL DEFAULT FALSE
|
archived INTEGER NOT NULL DEFAULT FALSE
|
||||||
);
|
) STRICT;
|
||||||
CREATE TABLE group_v1_member (
|
CREATE TABLE group_v1_member (
|
||||||
_id INTEGER PRIMARY KEY,
|
_id INTEGER PRIMARY KEY,
|
||||||
group_id INTEGER NOT NULL REFERENCES group_v1 (_id) ON DELETE CASCADE,
|
group_id INTEGER NOT NULL REFERENCES group_v1 (_id) ON DELETE CASCADE,
|
||||||
recipient_id INTEGER NOT NULL REFERENCES recipient (_id) ON DELETE CASCADE,
|
recipient_id INTEGER NOT NULL REFERENCES recipient (_id) ON DELETE CASCADE,
|
||||||
UNIQUE(group_id, recipient_id)
|
UNIQUE(group_id, recipient_id)
|
||||||
);
|
) STRICT;
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ public class AccountDatabase extends Database {
|
||||||
device_id INTEGER NOT NULL,
|
device_id INTEGER NOT NULL,
|
||||||
record BLOB NOT NULL,
|
record BLOB NOT NULL,
|
||||||
UNIQUE(account_id_type, recipient_id, device_id)
|
UNIQUE(account_id_type, recipient_id, device_id)
|
||||||
);
|
) STRICT;
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ public class AccountDatabase extends Database {
|
||||||
identity_key BLOB NOT NULL,
|
identity_key BLOB NOT NULL,
|
||||||
added_timestamp INTEGER NOT NULL,
|
added_timestamp INTEGER NOT NULL,
|
||||||
trust_level INTEGER NOT NULL
|
trust_level INTEGER NOT NULL
|
||||||
);
|
) STRICT;
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ public class AccountDatabase extends Database {
|
||||||
record BLOB NOT NULL,
|
record BLOB NOT NULL,
|
||||||
created_timestamp INTEGER NOT NULL,
|
created_timestamp INTEGER NOT NULL,
|
||||||
UNIQUE(recipient_id, device_id, distribution_id)
|
UNIQUE(recipient_id, device_id, distribution_id)
|
||||||
);
|
) STRICT;
|
||||||
CREATE TABLE sender_key_shared (
|
CREATE TABLE sender_key_shared (
|
||||||
_id INTEGER PRIMARY KEY,
|
_id INTEGER PRIMARY KEY,
|
||||||
recipient_id INTEGER NOT NULL REFERENCES recipient (_id) ON DELETE CASCADE,
|
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,
|
distribution_id BLOB NOT NULL,
|
||||||
timestamp INTEGER NOT NULL,
|
timestamp INTEGER NOT NULL,
|
||||||
UNIQUE(recipient_id, device_id, distribution_id)
|
UNIQUE(recipient_id, device_id, distribution_id)
|
||||||
);
|
) STRICT;
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ public class AccountDatabase extends Database {
|
||||||
logger.debug("Updating database: Adding urgent field");
|
logger.debug("Updating database: Adding urgent field");
|
||||||
try (final var statement = connection.createStatement()) {
|
try (final var statement = connection.createStatement()) {
|
||||||
statement.executeUpdate("""
|
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;
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,9 +52,9 @@ public class GroupStore {
|
||||||
master_key BLOB NOT NULL,
|
master_key BLOB NOT NULL,
|
||||||
group_data BLOB,
|
group_data BLOB,
|
||||||
distribution_id BLOB UNIQUE NOT NULL,
|
distribution_id BLOB UNIQUE NOT NULL,
|
||||||
blocked BOOLEAN NOT NULL DEFAULT FALSE,
|
blocked INTEGER NOT NULL DEFAULT FALSE,
|
||||||
permission_denied BOOLEAN NOT NULL DEFAULT FALSE
|
permission_denied INTEGER NOT NULL DEFAULT FALSE
|
||||||
);
|
) STRICT;
|
||||||
CREATE TABLE group_v1 (
|
CREATE TABLE group_v1 (
|
||||||
_id INTEGER PRIMARY KEY,
|
_id INTEGER PRIMARY KEY,
|
||||||
group_id BLOB UNIQUE NOT NULL,
|
group_id BLOB UNIQUE NOT NULL,
|
||||||
|
@ -62,15 +62,15 @@ public class GroupStore {
|
||||||
name TEXT,
|
name TEXT,
|
||||||
color TEXT,
|
color TEXT,
|
||||||
expiration_time INTEGER NOT NULL DEFAULT 0,
|
expiration_time INTEGER NOT NULL DEFAULT 0,
|
||||||
blocked BOOLEAN NOT NULL DEFAULT FALSE,
|
blocked INTEGER NOT NULL DEFAULT FALSE,
|
||||||
archived BOOLEAN NOT NULL DEFAULT FALSE
|
archived INTEGER NOT NULL DEFAULT FALSE
|
||||||
);
|
) STRICT;
|
||||||
CREATE TABLE group_v1_member (
|
CREATE TABLE group_v1_member (
|
||||||
_id INTEGER PRIMARY KEY,
|
_id INTEGER PRIMARY KEY,
|
||||||
group_id INTEGER NOT NULL REFERENCES group_v1 (_id) ON DELETE CASCADE,
|
group_id INTEGER NOT NULL REFERENCES group_v1 (_id) ON DELETE CASCADE,
|
||||||
recipient_id INTEGER NOT NULL REFERENCES recipient (_id) ON DELETE CASCADE,
|
recipient_id INTEGER NOT NULL REFERENCES recipient (_id) ON DELETE CASCADE,
|
||||||
UNIQUE(group_id, recipient_id)
|
UNIQUE(group_id, recipient_id)
|
||||||
);
|
) STRICT;
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class PreKeyStore implements org.signal.libsignal.protocol.state.PreKeySt
|
||||||
public_key BLOB NOT NULL,
|
public_key BLOB NOT NULL,
|
||||||
private_key BLOB NOT NULL,
|
private_key BLOB NOT NULL,
|
||||||
UNIQUE(account_id_type, key_id)
|
UNIQUE(account_id_type, key_id)
|
||||||
);
|
) STRICT;
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,14 +32,14 @@ public class SignedPreKeyStore implements org.signal.libsignal.protocol.state.Si
|
||||||
statement.executeUpdate("""
|
statement.executeUpdate("""
|
||||||
CREATE TABLE signed_pre_key (
|
CREATE TABLE signed_pre_key (
|
||||||
_id INTEGER PRIMARY KEY,
|
_id INTEGER PRIMARY KEY,
|
||||||
account_id_type BLOB NOT NULL,
|
account_id_type INTEGER NOT NULL,
|
||||||
key_id INTEGER NOT NULL,
|
key_id INTEGER NOT NULL,
|
||||||
public_key BLOB NOT NULL,
|
public_key BLOB NOT NULL,
|
||||||
private_key BLOB NOT NULL,
|
private_key BLOB NOT NULL,
|
||||||
signature BLOB NOT NULL,
|
signature BLOB NOT NULL,
|
||||||
timestamp INTEGER DEFAULT 0,
|
timestamp INTEGER DEFAULT 0,
|
||||||
UNIQUE(account_id_type, key_id)
|
UNIQUE(account_id_type, key_id)
|
||||||
);
|
) STRICT;
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,9 +60,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
||||||
color TEXT,
|
color TEXT,
|
||||||
|
|
||||||
expiration_time INTEGER NOT NULL DEFAULT 0,
|
expiration_time INTEGER NOT NULL DEFAULT 0,
|
||||||
blocked BOOLEAN NOT NULL DEFAULT FALSE,
|
blocked INTEGER NOT NULL DEFAULT FALSE,
|
||||||
archived BOOLEAN NOT NULL DEFAULT FALSE,
|
archived INTEGER NOT NULL DEFAULT FALSE,
|
||||||
profile_sharing BOOLEAN NOT NULL DEFAULT FALSE,
|
profile_sharing INTEGER NOT NULL DEFAULT FALSE,
|
||||||
|
|
||||||
profile_last_update_timestamp INTEGER NOT NULL DEFAULT 0,
|
profile_last_update_timestamp INTEGER NOT NULL DEFAULT 0,
|
||||||
profile_given_name TEXT,
|
profile_given_name TEXT,
|
||||||
|
@ -73,7 +73,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
||||||
profile_mobile_coin_address BLOB,
|
profile_mobile_coin_address BLOB,
|
||||||
profile_unidentified_access_mode TEXT,
|
profile_unidentified_access_mode TEXT,
|
||||||
profile_capabilities TEXT
|
profile_capabilities TEXT
|
||||||
);
|
) STRICT;
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -711,7 +711,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
||||||
|
|
||||||
final var profileKeyCredential = getExpiringProfileKeyCredential(connection, recipientId);
|
final var profileKeyCredential = getExpiringProfileKeyCredential(connection, recipientId);
|
||||||
if (profileKeyCredential == null) {
|
if (profileKeyCredential == null) {
|
||||||
final var toBeMergedProfileKeyCredential = getExpiringProfileKeyCredential(connection, toBeMergedRecipientId);
|
final var toBeMergedProfileKeyCredential = getExpiringProfileKeyCredential(connection,
|
||||||
|
toBeMergedRecipientId);
|
||||||
storeExpiringProfileKeyCredential(connection, recipientId, toBeMergedProfileKeyCredential);
|
storeExpiringProfileKeyCredential(connection, recipientId, toBeMergedProfileKeyCredential);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,8 @@ public class MessageSendLogStore implements AutoCloseable {
|
||||||
timestamp INTEGER NOT NULL,
|
timestamp INTEGER NOT NULL,
|
||||||
content BLOB NOT NULL,
|
content BLOB NOT NULL,
|
||||||
content_hint INTEGER 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 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_recipient_index ON message_send_log (uuid, device_id, content_id);
|
||||||
CREATE INDEX msl_content_index ON message_send_log (content_id);
|
CREATE INDEX msl_content_index ON message_send_log (content_id);
|
||||||
|
|
|
@ -26,8 +26,8 @@ public class StickerStore {
|
||||||
_id INTEGER PRIMARY KEY,
|
_id INTEGER PRIMARY KEY,
|
||||||
pack_id BLOB UNIQUE NOT NULL,
|
pack_id BLOB UNIQUE NOT NULL,
|
||||||
pack_key BLOB NOT NULL,
|
pack_key BLOB NOT NULL,
|
||||||
installed BOOLEAN NOT NULL DEFAULT FALSE
|
installed INTEGER NOT NULL DEFAULT FALSE
|
||||||
);
|
) STRICT;
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue