Creating Custom Postgres Data Types in Rails
29-Apr-2021 1121
Postgres ships with the most widely used common data types, like integers and text, built in, but it's also flexible enough to allow you to define your own data types if your project demands it.Say you're saving price data and you want to ensure that it’s never negative. You might create a not_negative_int type that you could then use to define columns on multiple tables. Or maybe you have data that makes more sense grouped together, like GPS coordinates. Postgres allows you to create a type to hold that data together in one column rather than spread it across multiple columns.
Creating Custom Postgres Data Types in Rails #ruby #rubydeveloper #rubyonrails #Creating #Custom #Postgres #Types #Rails #types https://rubyonrails.ba/link/creating-custom-postgres-data-types-in-rails