1 package org
.asamk
.signal
.manager
.storage
;
3 import com
.zaxxer
.hikari
.HikariDataSource
;
5 import org
.asamk
.signal
.manager
.storage
.recipients
.RecipientStore
;
6 import org
.asamk
.signal
.manager
.storage
.sendLog
.MessageSendLogStore
;
7 import org
.slf4j
.Logger
;
8 import org
.slf4j
.LoggerFactory
;
11 import java
.sql
.Connection
;
12 import java
.sql
.SQLException
;
14 public class AccountDatabase
extends Database
{
16 private final static Logger logger
= LoggerFactory
.getLogger(AccountDatabase
.class);
17 private static final long DATABASE_VERSION
= 2;
19 private AccountDatabase(final HikariDataSource dataSource
) {
20 super(logger
, DATABASE_VERSION
, dataSource
);
23 public static AccountDatabase
init(File databaseFile
) throws SQLException
{
24 return initDatabase(databaseFile
, AccountDatabase
::new);
28 protected void createDatabase(final Connection connection
) throws SQLException
{
29 RecipientStore
.createSql(connection
);
30 MessageSendLogStore
.createSql(connection
);
34 protected void upgradeDatabase(final Connection connection
, final long oldVersion
) throws SQLException
{
36 logger
.debug("Updating database: Creating recipient table");
37 try (final var statement
= connection
.createStatement()) {
38 statement
.executeUpdate("""
39 CREATE TABLE recipient (
40 _id INTEGER PRIMARY KEY AUTOINCREMENT,
44 profile_key_credential BLOB,
50 expiration_time INTEGER NOT NULL DEFAULT 0,
51 blocked BOOLEAN NOT NULL DEFAULT FALSE,
52 archived BOOLEAN NOT NULL DEFAULT FALSE,
53 profile_sharing BOOLEAN NOT NULL DEFAULT FALSE,
55 profile_last_update_timestamp INTEGER NOT NULL DEFAULT 0,
56 profile_given_name TEXT,
57 profile_family_name TEXT,
59 profile_about_emoji TEXT,
60 profile_avatar_url_path TEXT,
61 profile_mobile_coin_address BLOB,
62 profile_unidentified_access_mode TEXT,
63 profile_capabilities TEXT