“The problem”, explains Michael, our company’s token Irish programmer, “is that the script, getItemListing.sql, needs to run before getItemCosting.sql”.
“In fact that script really needs to run before any of the others”, he points out further. “Otherwise it will reference stored procedures that have not yet been created”.
“Right”, I say. “So what do we need to do to fix it?”.
“Well, we could rename getItemListing.sql to 1_getItemListing.sql”.
“Sounds messy. And then what happens when we have another script that should run before 1_getItemListing.sql?”, I conjecture.
“Yeah, I dunno, I guess we’d have to rename it to something like 11_*.sql”.
“Ah, it’s the motorway problem”, I say.
“When TRANSIT built the Auckland motorway system back in the 50s, they needed an algorithm for labeling exits”, I explain. “The most logical solution would have been to name them sequentially from south to north. But then of course what happens when, in five years time, they add a new exit between Exit 4 and Exit 5? They might call it Exit 4a, but in another five years time, there might be a another new exit between Exit 4 and Exit 4a.”
“And then later Exit 7 gets decommissioned”, adds Michael.
“Exactly. They needed a better solution. So, in the end what they decided to do was to label the exits based on the number of kilometers from Cape Reinga”.
“Hey, I hadn’t thought of that. That’s actually really clever!”
“Yeah, it seems to work reasonably well”, I say. “As you drive south, exit numbers are all unique and always increasing”.
“So then, do you have any suggestions for what I should rename my script to?”, Michael asks.
“Um no. Let’s just call it 1_getItemListing.sql”*
*Distance to database doesn’t seem to work