mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Fix missing unique constraint on storage_id table
This commit is contained in:
parent
67fd10b978
commit
cd88e896fa
2 changed files with 4 additions and 3 deletions
|
@ -495,7 +495,7 @@ public class AccountDatabase extends Database {
|
||||||
CREATE TABLE storage_id (
|
CREATE TABLE storage_id (
|
||||||
_id INTEGER PRIMARY KEY,
|
_id INTEGER PRIMARY KEY,
|
||||||
type INTEGER NOT NULL,
|
type INTEGER NOT NULL,
|
||||||
storage_id BLOB NOT NULL
|
storage_id BLOB UNIQUE NOT NULL
|
||||||
) STRICT;
|
) STRICT;
|
||||||
ALTER TABLE group_v1 ADD COLUMN storage_id BLOB;
|
ALTER TABLE group_v1 ADD COLUMN storage_id BLOB;
|
||||||
ALTER TABLE group_v1 ADD COLUMN storage_record BLOB;
|
ALTER TABLE group_v1 ADD COLUMN storage_record BLOB;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class UnknownStorageIdStore {
|
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 = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
SELECT s.type, s.storage_id
|
SELECT s.type, s.storage_id
|
||||||
|
@ -35,7 +36,7 @@ public class UnknownStorageIdStore {
|
||||||
).formatted(TABLE_STORAGE_ID);
|
).formatted(TABLE_STORAGE_ID);
|
||||||
try (final var statement = connection.prepareStatement(sql)) {
|
try (final var statement = connection.prepareStatement(sql)) {
|
||||||
try (var result = Utils.executeQueryForStream(statement, this::getStorageIdFromResultSet)) {
|
try (var result = Utils.executeQueryForStream(statement, this::getStorageIdFromResultSet)) {
|
||||||
return result.toList();
|
return result.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue