summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjakefeasel <jfeasel@gmail.com>2013-09-14 17:41:46 -0700
committerjakefeasel <jfeasel@gmail.com>2013-09-14 17:41:46 -0700
commit30f6bcce893bc74b115d6029407d403c4b7295e2 (patch)
tree1a7fe883545dc3ed4c9585308ee98f22a2218a28
parentfeb22e49a0abff2c2a00bd995c8e1bc6f6358aae (diff)
downloadsqlfiddle-30f6bcce893bc74b115d6029407d403c4b7295e2.zip
sqlfiddle-30f6bcce893bc74b115d6029407d403c4b7295e2.tar.gz
sqlfiddle-30f6bcce893bc74b115d6029407d403c4b7295e2.tar.bz2
Removing cf datasources which have somehow gotten out of sync with db state
-rw-r--r--src/main/webapp/controllers/Tasks.cfc26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/main/webapp/controllers/Tasks.cfc b/src/main/webapp/controllers/Tasks.cfc
index 4d40da9..392b8c4 100644
--- a/src/main/webapp/controllers/Tasks.cfc
+++ b/src/main/webapp/controllers/Tasks.cfc
@@ -8,7 +8,7 @@
for (i = 1; i<= ArrayLen(stale_schemas); i++)
{
lock name="#stale_schemas[i].db_type_id#_#stale_schemas[i].short_code#" type="exclusive" timeout="60"
- {
+ {
stale_schemas[i].purgeDatabase(1);
}
}
@@ -24,11 +24,27 @@
</cffunction>
- <cffunction name="buildMetaData">
+ <cffunction name="cleanDatasources">
<cfscript>
-
- schemas = model("Schema_Def").findAll(where="structure_json IS NULL");
-
+ var loc = {};
+ loc.datasources = getDatasources(adminPassword=get('CFAdminPassword'));
+ loc.dsnArray = structKeyArray(loc.datasources);
+
+ for (loc.i = 1; loc.i <= ArrayLen(loc.dsnArray); loc.i++) {
+ loc.dsnMatch = reFind("^(\d+)_([a-z0-9]+)$", loc.dsnArray[loc.i], 0, true);
+ if (ArrayLen(loc.dsnMatch.len) IS 3) {
+ loc.db_type_id = mid(loc.dsnArray[loc.i], loc.dsnMatch.pos[2], loc.dsnMatch.len[2]);
+ loc.short_code = mid(loc.dsnArray[loc.i], loc.dsnMatch.pos[3], loc.dsnMatch.len[3]);
+ loc.active_database = model("Schema_Def").findOne(where="current_host_id IS NOT NULL AND db_type_id = #loc.db_type_id# AND short_code = '#loc.short_code#'", returnAs="object", select="db_type_id,short_code,current_host_id,id");
+ if (loc.active_database IS false) {
+ loc.host = model("Host");
+ loc.host.db_type_id = loc.db_type_id;
+ loc.host.dropDSN(loc.short_code);
+ }
+ }
+ }
+ abort;
+ renderNothing();
</cfscript>
</cffunction>