Sha256: 7f134200e5d39e7b0f66bfa1642ced97a95136f1c6f7dbb4bf14e35f961da596
Contents?: true
Size: 468 Bytes
Versions: 2
Compression:
Stored size: 468 Bytes
Contents
desc "Nullify all the nullable text columns in the model specified in MODEL" task :nullify_blanks do raise RuntimeError, "Please specify a model to nullify" if ENV["MODEL"].blank? Rake::Task[:environment].invoke klass = ENV["MODEL"].constantize klass.columns.each do |column| quoted_column = klass.connection.quote_column_name(column.name) klass.update_all("#{quoted_column} = NULL", "#{quoted_column} = ''") if column.text? && column.null end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
pixeltrix-nullify_blanks-1.0.0 | tasks/nullify_blanks_tasks.rake |
nullify_blanks-1.0.0 | tasks/nullify_blanks_tasks.rake |