20150828201023_second_software_release_date.rb
972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class SecondSoftwareReleaseDate < ActiveRecord::Migration
def up
softwares = SoftwareInfo.all
softwares.each do |software|
if software.community
name = software.community.name.strip
software.community.name = name
software.community.save
else
software.destroy
end
end
file = File.new("plugins/spb_migrations/files/date-communities.txt", "r")
while (line = file.gets)
result = line.split('|')
software_name = result[2].gsub("/n", "")
software = Community.where("name ILIKE ?", software_name.strip)
if software && software.count == 1
software = software.first
software.created_at = Time.zone.parse(result[1])
if software.save
print "."
else
print "F"
end
else
print "F"
puts software_name
end
end
file.close
puts ""
end
def down
say "This can't be reverted"
end
end