Class: Ez::Settings::ActiveRecordMigrationsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/ez/settings/active_record_migrations_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_migrationObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/generators/ez/settings/active_record_migrations_generator.rb', line 5

def create_migration
  create_file "db/migrate/#{Time.now.strftime('%Y%m%d%H%M%S')}_create_ez_settings.rb",
              "class CreateEzSettings < ActiveRecord::Migration[5.0]
  def change
create_table :ez_settings do |t|
  t.string :group, null: false
  t.string :key, null: false
  t.string :value, null: false

  t.timestamps
end

add_index :ez_settings, :key
add_index :ez_settings, :group
add_index :ez_settings, [:key, :group], unique: true
  end
end
"
end