Class: Hstore::Setup
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Hstore::Setup
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/activerecord-postgres-hstore/railties.rb
Overview
Creates the hstore:setup generator. This generator creates a migration that adds hstore support for your database. If fact, it’s just the sql from the contrib inside a migration. But it’ s handy, isn’t it?
To use your generator, simply run it in your project:
rails g hstore:setup
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/activerecord-postgres-hstore/railties.rb', line 36 def self.next_migration_number(dirname) if ActiveRecord::Base. Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end |
.source_root ⇒ Object
32 33 34 |
# File 'lib/activerecord-postgres-hstore/railties.rb', line 32 def self.source_root @source_root ||= File.join(File.dirname(__FILE__), '../templates') end |
Instance Method Details
#create_migration_file ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/activerecord-postgres-hstore/railties.rb', line 44 def create_migration_file pgversion = ActiveRecord::Base.connection.send(:postgresql_version) if pgversion < 90100 migration_template 'setup_hstore.rb', 'db/migrate/setup_hstore.rb' else migration_template 'setup_hstore91.rb', 'db/migrate/setup_hstore.rb' end end |