jeudi 10 décembre 2015

Insert a row using db migration - ruby

I am new to ruby on rails. I need to insert a row into existing table using db migration, the table already have more than 200 rows of data and i need to insert one more row also.

I already created a migration file and it looks like below,

class AddNewGrowingMethodToEnumValues < ActiveRecord::Migration
  execute "INSERT INTO enum_values (enum_type, name, gdsn, created_at, updated_at) VALUES ('growing', 'Organic', '', now(), now())"
end

Is it correct/good?

Can any one help me to do migration to insert single row in correct/standard way.

Aucun commentaire:

Enregistrer un commentaire