diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3581d8851e495ba9682050acd0ea0b83dfacb649..e4e276d61642a9c19f2ee9b9a7b89acba80579c2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Bugfixes
 
+* Fixed an issue where .template and .substitutions files with the same name would build incorrectly
+
 ### Other changes
 
 * Replaced `tclx` script to expand .dbd files with a python script
diff --git a/require-ess/tools/driver.makefile b/require-ess/tools/driver.makefile
index d650d0f5391d371285530502a45907272d6dea94..25bd11eeb16bc054290cfcca645bca6be5b7233d 100644
--- a/require-ess/tools/driver.makefile
+++ b/require-ess/tools/driver.makefile
@@ -269,16 +269,16 @@ db_internal: $(COMMON_DIR)
 VPATH += $(dir $(TMPS))
 VPATH += $(dir $(SUBS))
 
-$(COMMON_DIR)/%.db: %.template
-	@printf "Inflating database ... %44s >>> %40s \n" "$^" "$@"
-	$(QUIET)$(MSI) -D $(USR_DBFLAGS) -o $(COMMON_DIR)/$(notdir $(basename $@).db) $^ > $(COMMON_DIR)/$(notdir $(basename $@).db).d
-	$(QUIET)$(MSI)    $(USR_DBFLAGS) -o $(COMMON_DIR)/$(notdir $(basename $@).db) $^
-
 $(COMMON_DIR)/%.db: %.substitutions
 	@printf "Inflating database ... %44s >>> %40s \n" "$^" "$@"
 	$(QUIET)$(MSI) -D $(USR_DBFLAGS) -o $(COMMON_DIR)/$(notdir $(basename $@).db) -S $^ > $(COMMON_DIR)/$(notdir $(basename $@).db).d
 	$(QUIET)$(MSI)    $(USR_DBFLAGS) -o $(COMMON_DIR)/$(notdir $(basename $@).db) -S $^
 
+$(COMMON_DIR)/%.db: %.template
+	@printf "Inflating database ... %44s >>> %40s \n" "$^" "$@"
+	$(QUIET)$(MSI) -D $(USR_DBFLAGS) -o $(COMMON_DIR)/$(notdir $(basename $@).db) $^ > $(COMMON_DIR)/$(notdir $(basename $@).db).d
+	$(QUIET)$(MSI)    $(USR_DBFLAGS) -o $(COMMON_DIR)/$(notdir $(basename $@).db) $^
+
 
 install build debug::
 	@echo "MAKING EPICS VERSION ${EPICSVERSION}"