Permalink
Browse files

Fixed some migrations failing when no data in db

  • Loading branch information...
1 parent 8993e44 commit 2ba594f78a7f50605bfdc263e771dacbe07be198 @zk committed Oct 12, 2010
View
@@ -15,15 +15,29 @@ GEM
autotest-fsevent (0.2.3)
sys-uname
autotest-growl (0.2.6)
+ capistrano (2.5.19)
+ highline
+ net-scp (>= 1.0.0)
+ net-sftp (>= 2.0.0)
+ net-ssh (>= 2.0.14)
+ net-ssh-gateway (>= 1.0.0)
chronic (0.2.3)
hoe (>= 1.2.1)
flexmock (0.8.7)
+ highline (1.6.1)
hoe (2.6.2)
rake (>= 0.8.7)
rubyforge (>= 2.0.4)
json_pure (1.4.6)
levenshtein (0.2.0)
mysql (2.8.1)
+ net-scp (1.0.4)
+ net-ssh (>= 1.99.1)
+ net-sftp (2.0.5)
+ net-ssh (>= 2.0.9)
+ net-ssh (2.0.23)
+ net-ssh-gateway (1.0.1)
+ net-ssh (>= 1.99.1)
rack (1.0.1)
rack-openid (1.0.3)
rack (>= 0.4)
@@ -54,6 +68,7 @@ DEPENDENCIES
ZenTest (= 4.4.0)
autotest-fsevent (= 0.2.3)
autotest-growl (= 0.2.6)
+ capistrano (= 2.5.19)
chronic (= 0.2.3)
flexmock (= 0.8.7)
levenshtein (= 0.2.0)
@@ -1,32 +1,36 @@
class AddVersions < ActiveRecord::Migration
-
+
def self.up
-
+
add_column :functions, :version, :string
add_column :namespaces, :version, :string
add_column :libraries, :version, :string
add_column :libraries, :current, :boolean
-
+
cclib = Library.find_by_name("Clojure Core")
- cclib.version = "1.2.0"
- cclib.current = true
- cclib.save
-
+ if cclib
+ cclib.version = "1.2.0"
+ cclib.current = true
+ cclib.save
+ end
+
cont_lib = Library.find_by_name("Clojure Contrib")
- cont_lib.version = "1.2.0"
- cont_lib.current = true
- cont_lib.save
-
+ if cont_lib
+ cont_lib.version = "1.2.0"
+ cont_lib.current = true
+ cont_lib.save
+ end
+
Function.find_all_by_library("Clojure Core").each do |f|
f.version = "1.2.0"
f.save
end
-
+
Function.find_all_by_library("Clojure Contrib").each do |f|
f.version = "1.2.0"
f.save
end
-
+
Namespace.find(:all, :conditions => ["name LIKE ?", "clojure.%"]).each do |n|
n.version = "1.2.0"
n.save
@@ -2,6 +2,10 @@ class AddVersionNumsToThirdParty < ActiveRecord::Migration
def self.set_lib_version(lib_name, version)
lib = Library.find_by_name(lib_name)
+ if not lib
+ puts "Couldn't find #{lib_name}"
+ return
+ end
lib.version = version
lib.current = true
lib.namespaces.each do |n|

0 comments on commit 2ba594f

Please sign in to comment.