diff --git a/service/config/sample.yml b/service/config/sample.yml index 82da08ba3..88c2d1060 100644 --- a/service/config/sample.yml +++ b/service/config/sample.yml @@ -221,12 +221,6 @@ abuseDatabase: # Postgresql database configuration password: password url: jdbc:postgresql://example.com:5432/abusedb -accountsDatabase: # Postgresql database configuration - driverClass: org.postgresql.Driver - user: example - password: password - url: jdbc:postgresql://example.com:5432/accountsdb - accountDatabaseCrawler: chunkSize: 10 # accounts per run chunkIntervalMs: 60000 # time per run diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java index 9cf3989fc..f60b92628 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java @@ -15,7 +15,6 @@ import javax.validation.Valid; import javax.validation.constraints.NotNull; import org.whispersystems.textsecuregcm.configuration.AbusiveMessageFilterConfiguration; import org.whispersystems.textsecuregcm.configuration.AccountDatabaseCrawlerConfiguration; -import org.whispersystems.textsecuregcm.configuration.AccountsDatabaseConfiguration; import org.whispersystems.textsecuregcm.configuration.AccountsDynamoDbConfiguration; import org.whispersystems.textsecuregcm.configuration.ApnConfiguration; import org.whispersystems.textsecuregcm.configuration.AppConfigConfiguration; @@ -226,11 +225,6 @@ public class WhisperServerConfiguration extends Configuration { @JsonProperty private List maxDevices = new LinkedList<>(); - @Valid - @NotNull - @JsonProperty - private AccountsDatabaseConfiguration accountsDatabase; - @Valid @NotNull @JsonProperty @@ -462,10 +456,6 @@ public class WhisperServerConfiguration extends Configuration { return abuseDatabase; } - public AccountsDatabaseConfiguration getAccountsDatabaseConfiguration() { - return accountsDatabase; - } - public RateLimitsConfiguration getLimitsConfiguration() { return limits; } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java index 96ef71cef..d94b166e8 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java @@ -24,7 +24,6 @@ import io.dropwizard.auth.PolymorphicAuthDynamicFeature; import io.dropwizard.auth.PolymorphicAuthValueFactoryProvider; import io.dropwizard.auth.basic.BasicCredentialAuthFilter; import io.dropwizard.auth.basic.BasicCredentials; -import io.dropwizard.db.DataSourceFactory; import io.dropwizard.db.PooledDataSourceFactory; import io.dropwizard.jdbi3.JdbiFactory; import io.dropwizard.setup.Bootstrap; @@ -244,13 +243,6 @@ public class WhisperServerService extends Application("accountdb", "accountsdb.xml") { - @Override - public DataSourceFactory getDataSourceFactory(WhisperServerConfiguration configuration) { - return configuration.getAccountsDatabaseConfiguration(); - } - }); - bootstrap.addBundle(new NameableMigrationsBundle("abusedb", "abusedb.xml") { @Override public PooledDataSourceFactory getDataSourceFactory(WhisperServerConfiguration configuration) { @@ -313,11 +305,9 @@ public class WhisperServerService extends Application - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CREATE type device_t AS (id integer, "authToken" varchar(255), salt varchar(255), "signalingKey" varchar(255), "gcmId" text, "apnId" text); - CREATE type account_t AS (number varchar(255), "supportsSms" smallint, devices device_t array); - UPDATE accounts SET data = row_to_json(row(number, supports_sms, array[row(1, auth_token, salt, signaling_key, gcm_id, apn_id)::device_t])::account_t) - - - - - - - - - - - DROP type account_t; - DROP type device_t; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CREATE OR REPLACE FUNCTION "custom_json_object_set_key"( - "json" json, - "key_to_set" TEXT, - "value_to_set" anyelement - ) - RETURNS json - LANGUAGE sql - IMMUTABLE - STRICT - AS $function$ - SELECT COALESCE( - (SELECT ('{' || string_agg(to_json("key") || ':' || "value", ',') || '}') - FROM (SELECT * - FROM json_each("json") - WHERE "key" <> "key_to_set" - UNION ALL - SELECT "key_to_set", to_json("value_to_set")) AS "fields"), - '{}' - )::json - $function$; - UPDATE accounts SET data = custom_json_object_set_key(data, 'identityKey', k.identity_key) FROM keys k WHERE (data->>'identityKey')::text is null AND k.number = data->>'number' AND k.last_resort = 1; - UPDATE accounts SET data = custom_json_object_set_key(data, 'identityKey', k.identity_key) FROM keys k WHERE (data->>'identityKey')::text is null AND k.number = data->>'number'; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CREATE UNIQUE INDEX CONCURRENTLY uuid_index ON accounts (uuid); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CREATE INDEX CONCURRENTLY deleted_key_index ON keys (deleted); - - - - DROP INDEX CONCURRENTLY deleted_key_index; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CREATE INDEX CONCURRENTLY deleted_profile_index ON profiles (deleted); - - - diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountsManagerChangeNumberIntegrationTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountsManagerChangeNumberIntegrationTest.java index 4b4a7ea57..6025f852d 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountsManagerChangeNumberIntegrationTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountsManagerChangeNumberIntegrationTest.java @@ -13,9 +13,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.opentable.db.postgres.embedded.LiquibasePreparer; -import com.opentable.db.postgres.junit5.EmbeddedPostgresExtension; -import com.opentable.db.postgres.junit5.PreparedDbExtension; import java.time.Clock; import java.util.ArrayList; import java.util.Optional; @@ -44,10 +41,6 @@ import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType; class AccountsManagerChangeNumberIntegrationTest { - @RegisterExtension - static PreparedDbExtension ACCOUNTS_POSTGRES_EXTENSION = - EmbeddedPostgresExtension.preparedDatabase(LiquibasePreparer.forClasspathLocation("accountsdb.xml")); - private static final String ACCOUNTS_TABLE_NAME = "accounts_test"; private static final String NUMBERS_TABLE_NAME = "numbers_test"; private static final String PNI_ASSIGNMENT_TABLE_NAME = "pni_assignment_test";