PostgreSQL schema migration

For any PostgreSQL schema defined through JugglingDB, it needs to be automigrated or autoupdated. The automigrate function destroys the table if it exists, and re-create it. The autoupdate function alters the table.

Below shows the automigrate/autoupdate function invocation that JugglingDB failed to point out:

schema.automigrate(); // or autoupdate

Since automigrate and autoupdate are async in nature, one shall not access the table before it is created. In this case, you can use the q module or callback mechanism to tackle this problem. A code snippet using the q module solution is illustrated at:

https://gist.github.com/woonketwong/7619585

Consequently, a pull request was submitted to JugglingDB. The fix updated its spec description in migrating PostgreSQL schema (and setting attributes in table). The request was accepted and merged to the master repo at:

https://github.com/1602/jugglingdb/commit/5702d41e2cca2383715ad6b7263b25b7da2f181c


To many beginners in Ruby programming, the differences of Symbol and String can often be vaguely understood. There are key attributes of Symbol that make it different from String and useful in Ruby. This topic is often asked in preliminary job interview, and one who intends to develop a career in Ruby shall master it. In this post, the differences of Symbol and String are listed and briefly described to give readers a quick grasp of the idea.

Symbol always start with a colon ( : )
Symbol can be generated using the :name and :“string” literals syntax and by the various to_sym methods. …


Suppose you have had some experience writing raw SQL queries, and learned what a powerful and essential part a database can be to your app, you may have noticed some of the drawbacks of SQL.

First of all, it is a domain specific language that gets mixed into your code as strings. It doesn’t look elegant and it can be messy. It will not take you long to observe the repetitive INSERT and SELECT statements, and what complicates more is the pain involved in changing a schema after an application goes live should it be necessary. All of the these can slow development.

Image for post
Image for post

Fortunately, there are many off the shelf solutions for these problems. Let’s examine two of the solutions here: Object Relational Mapping (ORM) and schema-less (NoSQL) database.
ORM is a programming technique for converting data between incompatible type systems in relational databases and object oriented programming languages. This provides a nice interface to programmer to interact with the underlying SQL statements. The popular ORMs that are used in frameworks like Node.s and Ruby on Rails are Sequelize and Active Record, respectively. …


A RESTful HTTP request contains all the information it needs to manipulate a resource without relying on server state.

Here are the examples of RESTful and not RESTful request:

1) If we have a database table called “user”, and we want to retrieve the name of a user with id=3523423, a RESTful HTTP request looks like this:

GET /user/3523423?name=true

2) In contrast, here is a not RESTful HTTP request:

GET /user/3523423 // In this 1st request, server saves the table name and id

GET /user/name // In this 2nd request, server pulls out the 1st request state, and proceeds to find the user name in the table

Woon Ket

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store