Skip to content

Backport support to Rails 6 for PostgreSQL generated columns

License

Notifications You must be signed in to change notification settings

sprk/pg_generated_column_support

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pg Generated Column Support

This is a backport of the generated column support that was added to Rails 7: rails/rails#41856

It also includes fixes from two other PRs: I also pulled in changes from two other related PRs: rails/rails#43263 rails/rails#44319

Much thanks and appreciation to everyone who worked on the generated columns support PRs. ❤️🎉

NOTE: Generated columns are supported since version 12.0 of PostgreSQL.

Usage

# db/migrate/20131220144913_create_users.rb
create_table :users do |t|
  t.string :name
  t.virtual :name_upcased, type: :string, as: 'upper(name)', stored: true
end
# app/models/user.rb
class User < ApplicationRecord
end
# Usage
user = User.create(name: 'John')
User.last.name_upcased # => "JOHN"

Installation

Add this line to your application's Gemfile:

gem 'pg_generated_column_support'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pg_generated_column_support

License

The gem is available as open source under the terms of the MIT License.

About

Backport support to Rails 6 for PostgreSQL generated columns

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 82.1%
  • HTML 14.1%
  • JavaScript 2.0%
  • CSS 1.8%