mirror of
https://github.com/aljazceru/signal-cli.git
synced 2025-12-24 09:34:20 +01:00
Fix missing unique constraint on storage_id table
This commit is contained in:
@@ -495,7 +495,7 @@ public class AccountDatabase extends Database {
|
||||
CREATE TABLE storage_id (
|
||||
_id INTEGER PRIMARY KEY,
|
||||
type INTEGER NOT NULL,
|
||||
storage_id BLOB NOT NULL
|
||||
storage_id BLOB UNIQUE NOT NULL
|
||||
) STRICT;
|
||||
ALTER TABLE group_v1 ADD COLUMN storage_id BLOB;
|
||||
ALTER TABLE group_v1 ADD COLUMN storage_record BLOB;
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class UnknownStorageIdStore {
|
||||
@@ -26,7 +27,7 @@ public class UnknownStorageIdStore {
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<StorageId> getUnknownStorageIds(Connection connection) throws SQLException {
|
||||
public Set<StorageId> getUnknownStorageIds(Connection connection) throws SQLException {
|
||||
final var sql = (
|
||||
"""
|
||||
SELECT s.type, s.storage_id
|
||||
@@ -35,7 +36,7 @@ public class UnknownStorageIdStore {
|
||||
).formatted(TABLE_STORAGE_ID);
|
||||
try (final var statement = connection.prepareStatement(sql)) {
|
||||
try (var result = Utils.executeQueryForStream(statement, this::getStorageIdFromResultSet)) {
|
||||
return result.toList();
|
||||
return result.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user