Deploying: From Make to Shell Scripts

reading time ( words)

In my previous post, Handling Database Schema Changes, I explained the strategy for managing database schema changes using GNU Make. However, after further consideration and testing, I have found that this approach may not be suitable for all deployment environments, particularly those that have strict security restrictions such as AWS Lambda.

The switch from a database deployment strategy based on GNU Make to one based on shell scripts is driven by the need to support deployment on cloud platforms such as AWS Lambda. AWS Lambda imposes security restrictions on process profiling system calls that prevent GNU Make from completing its calls to the commands specified in the Makefile. By using shell scripts instead, the deployment process can bypass these restrictions and run smoothly on AWS Lambda. The shell script approach provides a flexible and efficient way to deploy databases on cloud platforms and ensure the deployment process runs without any issues. Additionally, the use of shell scripts can simplify the deployment process and make it easier to automate and manage.

The update is now my schema-skel repo.

For any new applications you should plan on invoking the following scripts instead of the corresponding Makefile targets.

Script Replaces make target Purpose
./deploy.sh deploy Deploys a pristine database schema without any additional schema deltas.
./deltas.sh deltas Applies all pending deltas.
./destroy.sh destroy Destroys the schema and its data using your provided scripts.
./test.sh test Run database test suite with pg_prove.

This change in strategy is a significant update to my previous post and I wanted to share this information with my readers to ensure they are aware of what I consider the best practices for deploying database schema templates in a variety of environments. I hope this update will be helpful and informative for those looking to deploy their database schema templates on cloud platforms such as AWS Lambda.