Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
public class DatabaseVersion {

static final int CURRENT_VERSION = 10;
static final int CURRENT_VERSION = 11;
private static Logger log = LoggerFactory.getLogger(DatabaseVersion.class);
private final Connection codeConn;
private final Connection userConn;
Expand Down Expand Up @@ -149,6 +149,8 @@ private boolean updateDatabase(int onDiskVersion) throws NoSuchAlgorithmExceptio
update8To9();
} else if (onDiskVersion == 9) {
update9To10();
} else if (onDiskVersion == 10) {
update10To11();
}
setSchemaVersion(onDiskVersion + 1);
userConn.commit();
Expand Down Expand Up @@ -533,4 +535,74 @@ public void update9To10() throws SQLException {
}
codeConn.commit();
}

public void update10To11() throws SQLException {
// The codes database doesn't need to know about Tyler's environment
// Strips the "-stage" and "-prod" suffix off existing domain values so "illinois-stage" becomes
// "illinois", then renames the column to jurisdiction
final String stripEnvSuffix =
"UPDATE %s SET domain = regexp_replace(domain, '-(stage|prod)$', '')";
Comment thread
BryceStevenWilley marked this conversation as resolved.

final List<String> tableNames =
List.of(
"location",
"error",
"version",
"installedversion",
"country",
"state",
"filingstatus",
"datafieldconfig",
"answer",
"arrestlocation",
"bond",
"casecategory",
"casesubtype",
"casetype",
"chargephase",
"citationjurisdiction",
"crossreference",
"damageamount",
"degree",
"disclaimerrequirement",
"driverlicensetype",
"documenttype",
"ethnicity",
"eyecolor",
"filertype",
"filetype",
"filing",
"filingcomponent",
"generaloffense",
"haircolor",
"language",
"lawenforcementunit",
"motiontype",
"namesuffix",
"optionalservices",
"optionalservices_filinglist",
"partytype",
"physicalfeature",
"procedureremedy",
"question",
"race",
"refundreason",
"servicetype",
"statute",
"statutetype",
"vehiclecolor",
"vehiclemake",
"vehicletype");

try (Statement st = codeConn.createStatement()) {
for (String tableName : tableNames) {
st.executeUpdate(stripEnvSuffix.formatted(tableName));
}
for (String tableName : tableNames) {
st.executeUpdate(
"ALTER TABLE %s RENAME COLUMN domain TO jurisdiction".formatted(tableName));
}
}
codeConn.commit();
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package edu.suffolk.litlab.efsp.ecfcodes;

import edu.suffolk.litlab.efsp.Jurisdiction;
import edu.suffolk.litlab.efsp.db.Database;
import edu.suffolk.litlab.efsp.stdlib.SQLFunction;
import edu.suffolk.litlab.efsp.stdlib.SQLGetter;
import edu.suffolk.litlab.efsp.tyler.TylerDomain;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
Expand Down Expand Up @@ -33,11 +33,8 @@ public CodeDatabaseAPI(Connection conn) {
super(conn);
}

/**
* The domain (the juristiction + environment, e.g. illinois-stage) that this database is working
* over.
*/
public abstract TylerDomain getDomain();
/** The jurisdiction (e.g illinois) that this database is working over */
public abstract Jurisdiction getJurisdiction();

/**
* Gets all court location identifiers (CLI) stored in the database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import edu.suffolk.litlab.efsp.server.utils.SendMessage;
import edu.suffolk.litlab.efsp.server.utils.ServiceHelpers;
import edu.suffolk.litlab.efsp.server.utils.SoapExceptionMapper;
import edu.suffolk.litlab.efsp.tyler.TylerDomain;
import edu.suffolk.litlab.efsp.tyler.TylerEnv;
import edu.suffolk.litlab.efsp.tyler.ecfcodes.CodeDatabase;
import edu.suffolk.litlab.efsp.utils.InterviewToFilingInformationConverter;
Expand Down Expand Up @@ -162,8 +161,8 @@ private static void setupDatabases(DataSource codeDs, DataSource userDs)
@SuppressWarnings("resource")
LoginDatabase ld = new LoginDatabase(userConn);
@SuppressWarnings("resource")
// Jurisdiction and env args can be null, we're just making the tables
CodeDatabase cd = new CodeDatabase(new TylerDomain(null, null), codeConn);
// Jurisdiction can be null here, we're just checking if tables exist
CodeDatabase cd = new CodeDatabase(null, codeConn);
boolean brandNew = !ld.tablesExist() || !cd.tablesExist();

// Now we can tell if everything is being set up fresh. If so, we'll make everything now.
Expand Down Expand Up @@ -266,7 +265,6 @@ public static void main(String[] args) throws Exception {
var jurisdiction = jurisdictions.get(idx);
TylerModuleSetup.create(
jurisdiction,
tylerEnv,
togaKeys.get(idx),
codesUpdateTime,
converterMap,
Expand Down
Loading
Loading