Skip to content
Open
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
2 changes: 1 addition & 1 deletion api/src/org/labkey/api/mcp/McpService.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ default User getUser(ToolContext toolContext)
default void incrementResourceRequestCount(String resource)
{
if (!OptionalFeatureService.get().isFeatureEnabled(ENABLE_MCP_SERVER_FLAG))
throw new RuntimeException("The MCP server is not enabled for external requests. Consider toggling the experimental feature flag.");
throw new RuntimeException("The MCP server is not enabled for external requests. Consider toggling the optional feature flag.");

get().incrementResourceRequestCount(resource);
}
Expand Down
7 changes: 7 additions & 0 deletions api/src/org/labkey/api/module/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.JSONObject;
import org.labkey.api.Constants;
import org.labkey.api.data.Container;
import org.labkey.api.data.DbSchema;
import org.labkey.api.data.DbScope;
Expand Down Expand Up @@ -444,4 +445,10 @@ default String getBuildTime()
default void registerMigrationHandlers(@NotNull DatabaseMigrationService service)
{
}

// Override in cases such as a module transitioning from unmanaged to managed
default double getEarliestUpgradeVersion()
{
return Constants.getEarliestUpgradeVersion();
}
}
20 changes: 14 additions & 6 deletions api/src/org/labkey/api/module/ModuleLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,21 @@ private void doInit(Execution execution) throws ServletException
.filter(ctx -> ctx.getSchemaVersion() != null)
.collect(Collectors.toMap(ModuleContext::getName, ctx->ctx));

record ModuleAndModuleContext(Module module, ModuleContext context)
{
boolean isTooOld()
{
return context.getInstalledVersion() < module.getEarliestUpgradeVersion();
}
}

// List of "<name> (<installedSchemaVersion>)" of LabKey-managed modules with schemas where the installed
// version is less than "earliest upgrade version"
// version is less than the module's earliest upgrade version
var tooOld = labkeyModules.stream()
.map(m -> moduleContextMap.get(m.getName()))
.filter(Objects::nonNull)
.filter(ctx -> ctx.getInstalledVersion() < Constants.getEarliestUpgradeVersion())
.map(UpgradeInfo::new)
.map(m -> new ModuleAndModuleContext(m, moduleContextMap.get(m.getName())))
.filter(mmc -> mmc.context() != null)
.filter(ModuleAndModuleContext::isTooOld)
.map(mmc -> new UpgradeInfo(mmc.context()))
.toList();

if (!tooOld.isEmpty())
Expand All @@ -655,7 +663,7 @@ private void doInit(Execution execution) throws ServletException

// Now that we know if this is a new install...
setDatabaseMigrationConfiguration(labkeyRoot);
boolean coreRequiredUpgrade = upgradeCoreModule(lockFile);
upgradeCoreModule(lockFile);

// Issue 40422 - log server and session GUIDs during startup. Do it after the core module has
// been bootstrapped/upgraded to ensure that AppProps is ready
Expand Down
4 changes: 4 additions & 0 deletions core/src/org/labkey/core/admin/sql/SqlScriptController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,10 @@ private static String getTheOtherScriptDir(SqlDialect dialect)
}

private static final String MIGRATE_TO_PG_PROMPT = """
Note that `ENTITYID`, `UNIQUEIDENTIFIER`, and `USERID` data types are available on both databases. Maintain
these data types when migrating the script (do not replace `ENTITYID` with `VARCHAR(36)` or `USERID` with `INT`,
for example).

Include a summary of the changes you made at the end.
""";

Expand Down