Skip to content

Commit

Permalink
-remove the db initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ronen4822 committed Aug 28, 2024
1 parent 8c80348 commit 11dc3c1
Showing 1 changed file with 0 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,6 @@


public class PostgresHandler {
private static final String CREATE_DB_STATEMENT = """
DO $$
BEGIN
IF NOT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'user_details')
THEN
CREATE TABLE user_details (
name varchar(255) PRIMARY KEY,
access_key varchar(1024),
csrf_token varchar(1024),
companies text ARRAY,
solved_questions int,
time_to_update timestamp,
access_key_expiration timestamp,
being_processed BOOLEAN
);
END IF;
END $$;
""";
private static final String UPDATE_USER_DETAILS = """
INSERT INTO user_details (name, access_key, csrf_token, companies, solved_questions, time_to_update, access_key_expiration, being_processed)
VALUES
Expand Down Expand Up @@ -67,17 +49,6 @@ public PostgresHandler(String serverName, int serverPort, String username, Strin
config.addDataSourceProperty("connectionTimeout", "30000");
ds = new HikariDataSource(config);
logger.info("Opened postgres connection pool successfully");
initializeUserTable();
}

protected void initializeUserTable() {
try (Connection connection = ds.getConnection()) {
connection.createStatement().execute(CREATE_DB_STATEMENT);
logger.info("PostgresDB successfully initialized");
} catch (SQLException e) {
logger.error("Failed initializing table due to exception", e);
System.exit(-1);
}
}

public boolean updateUserDetails(UserDetails userDetails) {
Expand Down

0 comments on commit 11dc3c1

Please # to comment.