Multiple Batches in a single Transaction

Goal: Create a migration script that uses a transaction to roll back the changes in case one of the sql statements fail.

Problem: If you alter a table and add a column, and then attempt to use the new column in SQL statements that follow, you will discover that you get an error that indicates that the column does not exist. This is because the statements are in the same batch.

Sample problem code: Here is a little snippet showing TSQL that contains the problem. This is a classic example of adding a bit field to an existing table, setting the values all to true (1), and then updating the bit field to not allow NULLs.

BEGIN TRANSACTION

ALTER TABLE Employees ADD Active bit;

UPDATE Employees SET Active = 1;

ALTER TABLE Employees ALTER COLUMN Active bit NOT NULL;

COMMIT TRANSACTION;

 

So, what are we left to do? Well, we need to create a single transaction with multiple batches, separated by the GO keyword.

Read more

Migrating Databases in Amazon RDS

Amazon RDS

Amazon’s Relational Database Service (RDS) enables developers to launch database instances in the cloud that are “fully” managed by Amazon. What this means is that developers can focus more on development and less on minor upgrades to the database, replication, fault tolerance and backups. This all sounds great, but there is one minor issue: no file system access. While this is generally not an issue, it does become an issue if you are attempting to create/restore a SQL Server backup (.bak) file.

Read more

Learning Nginx on OS X

Nginx

 

I have long been a big fan of Apache’s web server. It’s powerful, versatile, and free. For the most part, the website that I have worked on are not mega websites, so I have never run into performance issues using Apache (or IIS for that matter). However, I still wanted to play with nginx. What is it? It’s a web server, and much more:

Nginx (pronounced engine-x) is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server.

So, let’s dive in…

Read more

chmod directories (and not files)

Here is a quick snippet that I used today, and that I might end up needing in the future. I needed to give all directories the execute permission for Apache to be able to traverse the directories.

Here is the error in my Apache error log:

[Thu Mar 26 12:37:24.857559 2015] [core:crit] [pid 14413] (13)Permission denied: [client 127.0.0.1:59372] AH00529: /www/local.brianflove.com/www/scripts/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that ‘/www/local.brianflove.com/www/scripts/’ is executable

 

chmod all directories recursively

So, I used the find command in terminal to update the permission on the files.

$ sudo find /www/local.brianflove.com/www -type d -exec chmod chmod 775 {} +

Now all directories have the following permissions:

  • User: 7 – read/write/execute
  • Group: 7 – read/write/execute
  • World: 5 – read/execute

 

Mac Permissions Table

Just in case it is helpful, here is a permissions table for Mac (from freebsd.org).

Value Permission Directory Listing
0 No read, no write, no execute ---
1 No read, no write, execute --x
2 No read, write, no execute -w-
3 No read, write, execute -wx
4 Read, no write, no execute r--
5 Read, no write, execute r-x
6 Read, write, no execute rw-
7 Read, write, execute rwx

Lucee on Mac OS X Yosemite Quick Start

Lucee Application Server

After the news of Railo being forked to a new project called Lucee, I wanted to try it out. Why not? I could have started with the express installation, but I wanted to deploy the WAR to my Tomcat 8 installation.

Quick Start:

  1. Install Tomcat 8 via Homebrew
  2. Configure Tomcat Manager app
  3. Download Lucee WAR
  4. Redeploy Lucee as ROOT web application
  5. Set credentials for Lucee Server and Web Admins

Read more

Hash Any ColdFusion Type

In order to generate a unique identifier for caching an object I needed to create a function to accept any data type, and to return a unique hash from that object. I thought this was a pretty useful function, so I thought I would share it here.

The use case for this function is to generatethe id for caching a query. I am using the cacheregion and cacheid attributes for a <cfquery> tag.

<cfquery datasource="#getDatasource()#" name="local.q" cacheregion="#region.getRegion()#" cacheid="#region.getId()#">
  ....
</cfquery>

I simply have a Region object that has to methods:

  1. public string function getRegion()
  2. public string function getId()

In the getId() method I need to generate a unique identifier. To do this, the Region object needed to be able to create a unique ID (or hash) from any variable.

Read more

Find-and-Replace in Multiple SVN Repositories

Subversion

 

This may not be a very useful blog post for everyone, but I needed a solution to be able to do a find-and-replace in all of the files in multiple SVN repositories. I ended up writing a bash shell script to accomplish this.

Here is what I wanted the script to do:

  1. Prompt the user for the value to find
  2. Prompt the user for the value to replace the “find” value with
  3. Prompt the user for the SVN commit message
  4. For each repository, check out and update a working copy on my machine, then do the find and replace, and finally, commit the changes to the SVN server

Read more

ColdFusion 10 Install on OS X Yosemite

Apache 2.4 on OS X Yosemite

If you have just downloaded Adobe ColdFusion 10 on your OS X Yosemite development environment you might be surprised to find out that the installation will cause your Apache 2.4.x server to stop working. The issue is that The ColdFusion 10 installer includes the web server connector utility that does not support Apache 2.4, which ships with OS X Yosemite.

When testing my Apache configuration after the installation was complete, I received the following error:

httpd: Syntax error on line 549 of /private/etc/apache2/httpd.conf: Syntax error on line 2 of /private/etc/apache2/mod_jk.conf: Cannot load /Applications/ColdFusion10/config/wsconfig/1/mod_jk.so into server: dlopen(/Applications/ColdFusion10/config/wsconfig/1/mod_jk.so, 10): Symbol not found: _ap_log_error\n  Referenced from: /Applications/ColdFusion10/config/wsconfig/1/mod_jk.so\n  Expected in: flat namespace\n in /Applications/ColdFusion10/config/wsconfig/1/mod_jk.so

Read more

IIS and HTTPS Binding with Host Header

Well, the title may not be entirely accurate. Honestly, I didn’t know what to title this post — let me explain what I observed and how I was able to get around the issue.

The default behavior in IIS is that you can only bind a SSL certificate to a specific site. And, by default, you cannot specify the host header value for the binding. What this means is that the SSL certificate is now bound to port 443 for all sites using the IP address specified. If you look at the screen shot below, you will notice that the Host name field is grayed out, and we are unable to populate this.

The default behavior for binding an SSL certificate is to only allow the certificate to be bound to a single site, without a host name specified.

The default behavior for binding an SSL certificate is to only allow the certificate to be bound to a single site, without a host name specified.

Read more