File: migrations.rb

package info (click to toggle)
camping 3.2.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,312 kB
  • sloc: ruby: 5,032; javascript: 2,362; makefile: 29
file content (97 lines) | stat: -rw-r--r-- 2,267 bytes parent folder | download | duplicates (2)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
require "camping"

Camping.goes :Migrations

module Migrations
  module Models
		class BadDude < Base; end
		class TableCreation < V 1.0
	  	def self.up
	    	puts "FORCE THE TABLES"
	    	create_table BadDude.table_name, :force=>true do |t|
	      	t.string :name, :limit => 255
		  	t.integer :bad
		  	t.timestamps
	    	end
	  	end
	  	def self.down
	    	drop_table BadDude.table_name
	  	end
		end
		class StartingDudes < V 1.3
	  	def self.up
	    	puts "There is only one way to make sure Bruce is the baddest"
	    	BadDude.create :name => "Bruce", :bad => 1
	    	BadDude.create :name => "Bruce", :bad => 2
	    	BadDude.create :name => "Bruce", :bad => 5
	  	end
	  	def self.down
	    	BadDude.delete_by_name "Bruce"
	  	end
		end
		class WeNeedMoreDudes < V 2.7
	  	def self.up
	    	puts "Maybe a non Bruce would help our worst case scenario planning"
	    	BadDude.create :name => "Bob", :bad => 3
	    	BadDude.create :name => "Samantha", :bad => 3
	  	end
	  	def self.down
	    	BadDude.delete_by_name "Bob"
			BadDude.delete_by_name "Samantha"
	  	end
		end
		class NoIMeanWeNeedBadderDudes < V 3.14159
			def self.up
				puts "just in case things get ugly"
				sam = BadDude.find_by_name "Samantha"
				sam.bad = 9001
				sam.save
			end
			def self.down
				sam = BadDude.find_by_name "Samantha"
				sam.bad = 3
				sam.save
			end
		end
		class WaitWeShouldDoThisEarlier < V 3.11
	  	def self.up
	    	puts "for workgroups"
	    	bruce = BadDude.find_by_name "Bob"
	    	bruce.bad = 45
	    	bruce.save
	  	end
	  	def self.down
	    	bruce = BadDude.find_by_name "Bob"
				bruce.bad = 3
				bruce.save
	  	end
		end
  end
  module Controllers
		class Bad < R '/(\d+)?'
			def get enough
				@dudes = BadDude.all :conditions => ["bad >= ?", enough.to_i]
				@howbad = enough
				render :savethepresident
			end
		end
  end
  module Views
		def savethepresident
			h1.ohnoes "The President Has Been Kidnapped By #{@howbad} Ninjas!"
			if @dudes.empty?
				diveq2 "None of the dudes are bad enough to rescue him, We are doomed!"
			else
				div "Please get the following dudes:"
				ul.dudes do
					@dudes.each do |dude|
						li.dude dude.name
					end
				end
			end
		end
  end
end
def Migrations.create
  Migrations::Models.create_schema
end