Commits

Richo Healey  committed 8875291

Make migrations safer and more verbose

  • Participants
  • Parent commits 6fc36ab

Comments (0)

Files changed (1)

File lib/twat/migration.rb

   class Migrate
     def migrate!(filename)
       @file = filename
-      migration_1
+      @ran = []
+      migration_1 if migration_1?
+      if @ran.any?
+        puts "Successfully ran migrations: #{@ran.join(", ")}"
+      else
+        puts "Already up to date"
+      end
+    end
+
+    def migration_1?
+      current = YAML.load_file(@file)
+      return !current.include?(:accounts)
     end
 
     def migration_1
       end
 
       save(new)
+      @ran << "1"
     end
 
     def save(cf)