The world's simplest database migrations
A delightfully simple way to run your database migrations with PostgreSQL functions. You only need one file and it's so fast you can even run it at application startup...
Welcome to my little node on the network! My name is Petar, you can follow me here while I'm figuring out how computers work.
A delightfully simple way to run your database migrations with PostgreSQL functions. You only need one file and it's so fast you can even run it at application startup...
For a few years now, I've been partaking in the age-old ritual of running. I began my journey like many others, swathed in quality athletic wear and armed with a meticulous training schedule...
For an exercism exercise I wanted to do multiplication with the pipe operator, and simply using *
does not work, neither does (*)
.
Now, it turns out the arithmetic operations are functions part of the Kernel
module, and you can also call them as an actual function with Kernel.*(2, 2)
, which is equal to writing 2 * 2
.
This enables you do do arithmetic as part of the pipe operation, see:
def monthly_rate(hourly_rate, discount) do
hourly_rate
|> daily_rate
|> apply_discount(discount)
|> Kernel.*(22)
|> ceil()
end