From 23698d64edc263f8382f09955971c30f69ca26f1 Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Wed, 10 Jun 2026 19:52:08 -0700 Subject: [PATCH 1/2] Let modules declare their earliest upgrade version. Provide guidance about ENTITYID, UNIQUEIDENTIFIER, and USER data types to the AIs. --- api/src/org/labkey/api/module/Module.java | 7 +++++++ .../org/labkey/api/module/ModuleLoader.java | 20 +++++++++++++------ .../core/admin/sql/SqlScriptController.java | 4 ++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/api/src/org/labkey/api/module/Module.java b/api/src/org/labkey/api/module/Module.java index 8785d11d9b4..5e954d45428 100644 --- a/api/src/org/labkey/api/module/Module.java +++ b/api/src/org/labkey/api/module/Module.java @@ -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; @@ -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(); + } } diff --git a/api/src/org/labkey/api/module/ModuleLoader.java b/api/src/org/labkey/api/module/ModuleLoader.java index 6248d1b0e75..37c1b040175 100644 --- a/api/src/org/labkey/api/module/ModuleLoader.java +++ b/api/src/org/labkey/api/module/ModuleLoader.java @@ -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 " ()" 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()) @@ -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 diff --git a/core/src/org/labkey/core/admin/sql/SqlScriptController.java b/core/src/org/labkey/core/admin/sql/SqlScriptController.java index 2fe3959e7de..24cc276833f 100644 --- a/core/src/org/labkey/core/admin/sql/SqlScriptController.java +++ b/core/src/org/labkey/core/admin/sql/SqlScriptController.java @@ -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. """; From cb9e13bb943933e6f3518473a0fe9768f9819be8 Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Fri, 12 Jun 2026 13:29:33 -0700 Subject: [PATCH 2/2] experimental -> optional flag --- api/src/org/labkey/api/mcp/McpService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/org/labkey/api/mcp/McpService.java b/api/src/org/labkey/api/mcp/McpService.java index 6ad04872537..eaebf476d70 100644 --- a/api/src/org/labkey/api/mcp/McpService.java +++ b/api/src/org/labkey/api/mcp/McpService.java @@ -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); }