bivouac 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/README +15 -0
  2. data/bin/bivouac +45 -8
  3. data/doc/rdoc/classes/BivouacHelpers/FormView.html +157 -122
  4. data/doc/rdoc/classes/BivouacHelpers/JavaScriptView.html +1 -1
  5. data/doc/rdoc/created.rid +1 -1
  6. data/doc/rdoc/files/README.html +41 -1
  7. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/form_rb.html +1 -1
  8. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/javascript_rb.html +1 -1
  9. data/examples/bivouac_sample/Rakefile +20 -0
  10. data/examples/bivouac_sample/app/bivouac_sample.rb +12 -4
  11. data/examples/bivouac_sample/app/controllers/edit_in_place.rb +17 -0
  12. data/examples/bivouac_sample/app/controllers/index.rb +11 -1
  13. data/examples/bivouac_sample/app/controllers/not_found.rb +16 -0
  14. data/examples/bivouac_sample/app/helpers/_helpers.rb +5 -3
  15. data/examples/bivouac_sample/app/views/edit_in_place.rb +52 -0
  16. data/examples/bivouac_sample/app/views/index.rb +21 -11
  17. data/examples/bivouac_sample/app/views/not_found.rb +13 -0
  18. data/examples/bivouac_sample/config/database.yml +3 -0
  19. data/examples/bivouac_sample/config/environment.rb +3 -2
  20. data/examples/bivouac_sample/config/postamble.rb +104 -44
  21. data/examples/bivouac_sample/script/generate +6 -0
  22. data/examples/bivouac_sample/test/test_edit_in_place.rb +22 -0
  23. data/examples/bivouac_sample/test/test_index.rb +22 -0
  24. data/lib/bivouac/commands/generate.rb +34 -13
  25. data/lib/bivouac/commands/generate.rb_OLD +342 -0
  26. data/lib/bivouac/helpers/view/goh/form.rb +33 -9
  27. data/lib/bivouac/helpers/view/goh/javascript.rb +1 -1
  28. data/lib/bivouac/template/application/postamble.rb +3 -3
  29. data/lib/bivouac/template/application_goh.rb +21 -3
  30. data/lib/bivouac/template/environment.rb +7 -2
  31. data/lib/bivouac/template/generate/create.rb +3 -5
  32. data/lib/bivouac/template/generate/migrate.rb +1 -2
  33. data/lib/bivouac/template/generate/migrate_begin.rb +11 -0
  34. data/lib/bivouac/template/generate/migrate_column.rb +1 -0
  35. data/lib/bivouac/template/generate/migrate_end.rb +8 -0
  36. data/lib/bivouac/template/generate/migration_add.rb +1 -0
  37. data/lib/bivouac/template/generate/migration_begin.rb +10 -0
  38. data/lib/bivouac/template/generate/migration_end.rb +3 -0
  39. data/lib/bivouac/template/generate/migration_middle.rb +3 -0
  40. data/lib/bivouac/template/generate/migration_remove.rb +1 -0
  41. data/lib/bivouac/template/static/default_layout_view.rb +33 -0
  42. data/lib/bivouac/template/static/not_found_controller.rb +16 -0
  43. data/lib/bivouac/template/static/not_found_view.rb +13 -0
  44. data/lib/cookies_sessions.rb +39 -0
  45. metadata +23 -3
@@ -245,8 +245,9 @@ module Bivouac
245
245
  else
246
246
  model_list = [ model ]
247
247
  end
248
-
249
- model_list.each do |model_name|
248
+
249
+ model_name = model_list.shift
250
+ #model_list.each do |model_name|
250
251
  # Model class name, passed to the template
251
252
  @model_class_name = model_name.classify
252
253
 
@@ -255,8 +256,8 @@ module Bivouac
255
256
  io.puts template( "generate/model", binding )
256
257
  end
257
258
 
258
- migration( model_name )
259
- end
259
+ migration( [model_name] + model_list )
260
+ #end
260
261
  end
261
262
 
262
263
  def migration( model = nil )
@@ -283,7 +284,7 @@ module Bivouac
283
284
  model = @script_arguments
284
285
  from_model = false
285
286
  else
286
- model = [ model ]
287
+ # model = [ model ]
287
288
  from_model = true
288
289
  end
289
290
 
@@ -313,23 +314,43 @@ module Bivouac
313
314
  end
314
315
 
315
316
  puts "\t* Migration from version #{old_version} to version #{@new_version}" if old_version > 0.0
316
-
317
- model.each do |model_name|
317
+
318
+ model_name = model.shift
319
+ # model.each do |model_name|
318
320
  # Model class name
319
321
  @model_class_name = model_name.classify
320
322
 
321
- # Model class name
322
- @model_table_name = (@app.environment.appname.downcase + "_" + model_name).tableize
323
-
324
323
  destination_file = File.dirname( $0 ) + "/../db/migrate/" + file_prefix + "_" + model_name.underscore + ".rb"
325
324
  createFile( destination_file ) do |io|
326
325
  if from_model
327
- io.puts template( "generate/migrate", binding )
326
+ # Model table name
327
+ @model_table_name = (@app.environment.appname.downcase + "_" + model_name).tableize
328
+
329
+ io.puts template( "generate/migrate_begin", binding )
330
+
331
+ model.each do |column|
332
+ @model_data_name, @model_data_type = column.split( /:/ )
333
+ io.puts template( "generate/migrate_column", binding )
334
+ end
335
+
336
+ io.puts template( "generate/migrate_end", binding )
328
337
  else
329
- io.puts template( "generate/migration", binding )
338
+ # Model table name
339
+ @model_table_name = (@app.environment.appname.downcase + "_" + (model_name.underscore.split( /_/ ))[-1]).tableize
340
+ io.puts template( "generate/migration_begin", binding )
341
+ model.each do |column|
342
+ @model_data_name, @model_data_type = column.split( /:/ )
343
+ io.puts template( "generate/migration_add", binding )
344
+ end
345
+ io.puts template( "generate/migration_middle", binding )
346
+ model.each do |column|
347
+ @model_data_name, @model_data_type = column.split( /:/ )
348
+ io.puts template( "generate/migration_remove", binding )
349
+ end
350
+ io.puts template( "generate/migration_end", binding )
330
351
  end
331
352
  end
332
- end
353
+ # end
333
354
 
334
355
  destination_file = File.dirname( $0 ) + "/../db/create.rb"
335
356
  createFile( destination_file, false, false ) do |io|
@@ -0,0 +1,342 @@
1
+ #!/usr/bin/env ruby
2
+ # bivouac
3
+ # (c)2007, 2008 Grégoire Lejeune
4
+
5
+ require 'rubygems'
6
+ require 'optparse'
7
+ require 'ostruct'
8
+ require 'bivouac/template'
9
+ require 'bivouac/utils'
10
+ require 'active_support'
11
+ require 'active_record'
12
+ require 'find'
13
+ require File.dirname($0) + '/../config/environment.rb'
14
+
15
+ module Bivouac
16
+ class Generate
17
+ include Bivouac::Template
18
+ # Initialize the optionnal generators table
19
+ add_generator []
20
+
21
+ def initialize( argv )
22
+ # Generator type (controller, model, migration, view, ...)
23
+ @generator_type = argv.shift
24
+
25
+ # Display help if asked
26
+ if ['-h', '--help'].include?( @generator_type )
27
+ help
28
+ exit
29
+ end
30
+
31
+ # Generator arguments.
32
+ # Example :
33
+ # script/generate controller Hello World
34
+ # @script_arguments = ['Hello', 'World']
35
+ @script_arguments = argv.dup
36
+
37
+ # Application environment
38
+ @app = Bivouac::Environment.new( )
39
+
40
+ # Database configuration
41
+ @database_configuration = @app.environment.db
42
+ if @database_configuration[:adapter] =~ /sqlite/
43
+ @database_configuration[:database] = File.expand_path( File.dirname( $0 ) + "/../" + @database_configuration[:database] )
44
+ end
45
+ end
46
+
47
+ def run
48
+ # If the générator is not installed, display help and exit
49
+ unless ( ["controller", "model", "migration", "view", "test"] + @@plugins_generators ).include?( @generator_type )
50
+ help
51
+ exit
52
+ end
53
+
54
+ # Call generator
55
+ send( @generator_type.to_sym )
56
+ return
57
+ end
58
+
59
+ private
60
+ def help
61
+ puts "Usage: script/generate generator [options] [args]"
62
+ puts ""
63
+ puts "Generators"
64
+ puts " Builtin: controller, model, migration, view, test"
65
+ puts " Plugins: " + @@plugins_generators.join(", ") if @@plugins_generators.size > 0
66
+ puts ""
67
+ puts "Commun options:"
68
+ puts " -h, --help Show general help message"
69
+ end
70
+
71
+ def controller
72
+ # controller generator options
73
+ controller_options = OpenStruct.new( :noview => false, :notest => false, :default_route => true, :routes => [] )
74
+
75
+ # Controller options
76
+ argument_options = OptionParser.new do |opts|
77
+ opts.banner = ""
78
+ opts.separator "controller generator options:"
79
+ opts.on("-v", "--no-view", "Do not generate any view for the controller") { |controller_options.noview|
80
+ controller_options.noview = true
81
+ }
82
+ opts.on("-d", "--no-route", "Do not add the default route to the controller (/controller_name)") { |controller_options.default_route|
83
+ controller_options.default_route = false
84
+ }
85
+ opts.on("-r", "--route ROUTE,ROUTE,...", "Add ROUTES to the controller") { |routes|
86
+ controller_options.routes = routes.split(',')
87
+ }
88
+ opts.on("-t", "--no-test", "Do not generate any test for the controller") { |controller_options.notest|
89
+ controller_options.notest = true
90
+ }
91
+
92
+ opts.separator ""
93
+ opts.on_tail("-h", "--help", "Show this message") do
94
+ help
95
+ puts opts
96
+ exit
97
+ end
98
+ end
99
+
100
+ # parse options
101
+ argument_options.parse! @script_arguments
102
+ if @script_arguments.length < 1
103
+ help
104
+ puts argument_options
105
+ exit
106
+ end
107
+
108
+ @script_arguments.each do |controller_name|
109
+ # Controller class name, passed to the template
110
+ @controller_class_name = controller_name.classify
111
+ # File name for the template
112
+ controller_file_name = @controller_class_name.underscore
113
+
114
+ # Destination file
115
+ destination_file = File.dirname( $0 ) + "/../app/controllers/" + controller_file_name + ".rb"
116
+
117
+ # Set view name, passed to the template
118
+ @view_name = @controller_class_name.underscore
119
+
120
+ # Set routes, passed to the template
121
+ default_route = @view_name
122
+ controller_options.routes << default_route if controller_options.default_route and controller_options.routes.include?( default_route ) == false
123
+ @controller_routes = if controller_options.routes.size > 0
124
+ " < R '/" + controller_options.routes.join("', '/") + "'"
125
+ else
126
+ ""
127
+ end
128
+
129
+ # Create controller
130
+ createFile( destination_file ) do |io|
131
+ io.puts template( "generate/controller", binding )
132
+ end
133
+
134
+ # Create view @view_name
135
+ view( @view_name ) if controller_options.noview == false
136
+
137
+ # Create test for @view_name with routes controller_options.routes
138
+ test( @view_name, controller_options.routes ) if controller_options.notest == false
139
+ end
140
+ end
141
+
142
+ def view( view_name = nil )
143
+ if @app.environment.orgtype.downcase == "erb"
144
+ raise "ERB applications are no longer supported. Sorry!"
145
+ end
146
+
147
+ # View options
148
+ argument_options = OptionParser.new do |opts|
149
+ opts.banner = ""
150
+ opts.separator "view generator options:"
151
+ opts.on_tail("-h", "--help", "Show this message") do
152
+ help
153
+ puts opts
154
+ exit
155
+ end
156
+ end
157
+
158
+ # parse options if view name is not passed
159
+ if view_name.nil?
160
+ argument_options.parse! @script_arguments
161
+ if @script_arguments.length < 1
162
+ help
163
+ puts argument_options
164
+ exit
165
+ end
166
+
167
+ view_name = @script_arguments
168
+ else
169
+ view_name = [ view_name ]
170
+ end
171
+
172
+ view_name.each do |view|
173
+ # Set view name, passed to the template
174
+ @view_name = view.underscore
175
+
176
+ # Set destination file, passed to the template
177
+ @destination_file = File.dirname( $0 ) + "/../app/views/" + @view_name.underscore + ".rb"
178
+
179
+ # Create view file
180
+ createFile( @destination_file ) do |io|
181
+ io.puts template( "generate/view_goh", binding )
182
+ end
183
+ end
184
+ end
185
+
186
+ def test( test_name = nil, routes = nil )
187
+ # Test options
188
+ argument_options = OptionParser.new do |opts|
189
+ opts.banner = ""
190
+ opts.separator "test generator options:"
191
+ opts.on_tail("-h", "--help", "Show this message") do
192
+ help
193
+ puts opts
194
+ exit
195
+ end
196
+ end
197
+
198
+ # parse options if view name is not passed
199
+ if test_name.nil?
200
+ argument_options.parse! @script_arguments
201
+ if @script_arguments.length < 1
202
+ help
203
+ puts argument_options
204
+ exit
205
+ end
206
+
207
+ test_name = @script_arguments.shift
208
+ routes = @script_arguments
209
+ end
210
+
211
+ # Create test file
212
+ destination_file = File.dirname( $0 ) + "/../test/test_" + test_name.underscore + ".rb"
213
+ createFile( destination_file ) do |io|
214
+ io.puts template( "generate/test_begin", binding )
215
+
216
+ routes.each do |@test_route|
217
+ io.puts template( "generate/test_views", binding )
218
+ end
219
+
220
+ io.puts template( "generate/test_end", binding )
221
+ end
222
+ end
223
+
224
+ def model( model = nil )
225
+ # Model options
226
+ argument_options = OptionParser.new do |opts|
227
+ opts.banner = ""
228
+ opts.separator "model generator options:"
229
+ opts.on_tail("-h", "--help", "Show this message") do
230
+ help
231
+ puts opts
232
+ exit
233
+ end
234
+ end
235
+
236
+ # parse options
237
+ if model.nil?
238
+ argument_options.parse! @script_arguments
239
+ if @script_arguments.length < 1
240
+ help
241
+ puts argument_options
242
+ exit
243
+ end
244
+ model_list = @script_arguments
245
+ else
246
+ model_list = [ model ]
247
+ end
248
+
249
+ model_list.each do |model_name|
250
+ # Model class name, passed to the template
251
+ @model_class_name = model_name.classify
252
+
253
+ destination_file = File.dirname( $0 ) + "/../app/models/" + @model_class_name.underscore + ".rb"
254
+ createFile( destination_file ) do |io|
255
+ io.puts template( "generate/model", binding )
256
+ end
257
+
258
+ migration( model_name )
259
+ end
260
+ end
261
+
262
+ def migration( model = nil )
263
+ # Test options
264
+ argument_options = OptionParser.new do |opts|
265
+ opts.banner = ""
266
+ opts.separator "migration generator options:"
267
+ opts.on_tail("-h", "--help", "Show this message") do
268
+ help
269
+ puts opts
270
+ exit
271
+ end
272
+ end
273
+
274
+ # parse options if view name is not passed
275
+ if model.nil?
276
+ argument_options.parse! @script_arguments
277
+ if @script_arguments.length < 1
278
+ help
279
+ puts argument_options
280
+ exit
281
+ end
282
+
283
+ model = @script_arguments
284
+ from_model = false
285
+ else
286
+ model = [ model ]
287
+ from_model = true
288
+ end
289
+
290
+ # Get old and new version
291
+ old_version = 0.0
292
+ begin
293
+ ActiveRecord::Base.establish_connection @database_configuration
294
+ conn = ActiveRecord::Base.connection
295
+ table = nil
296
+ conn.tables.each { |t| table = t if t =~ /_schema_infos$/ }
297
+ version_info = conn.select_all( "select * from #{table}" )
298
+ old_version = version_info[0]['version'].to_f
299
+ rescue
300
+ end
301
+ @new_version = old_version + 1
302
+
303
+ # Get prefix for file
304
+ files = []
305
+ Find.find( File.dirname( $0 ) + "/../db/migrate/" ) do |f|
306
+ fn = File.basename( f )
307
+ files << fn if fn =~ /^\d\d\d/
308
+ end
309
+ file_prefix = "001"
310
+ if files.size > 0
311
+ files = files.sort {|x,y| y[0,3] <=> x[0,3]}
312
+ file_prefix = sprintf( "%03d", (files[0][0,3].to_i + 1) )
313
+ end
314
+
315
+ puts "\t* Migration from version #{old_version} to version #{@new_version}" if old_version > 0.0
316
+
317
+ model.each do |model_name|
318
+ # Model class name
319
+ @model_class_name = model_name.classify
320
+
321
+ # Model class name
322
+ @model_table_name = (@app.environment.appname.downcase + "_" + model_name).tableize
323
+
324
+ destination_file = File.dirname( $0 ) + "/../db/migrate/" + file_prefix + "_" + model_name.underscore + ".rb"
325
+ createFile( destination_file ) do |io|
326
+ if from_model
327
+ io.puts template( "generate/migrate", binding )
328
+ else
329
+ io.puts template( "generate/migration", binding )
330
+ end
331
+ end
332
+ end
333
+
334
+ destination_file = File.dirname( $0 ) + "/../db/create.rb"
335
+ createFile( destination_file, false, false ) do |io|
336
+ io.puts template( "generate/create", binding )
337
+ end
338
+ end
339
+ end
340
+ end
341
+
342
+ Bivouac::Generate.new( ARGV ).run( )
@@ -16,17 +16,41 @@ module BivouacHelpers
16
16
  javascript_tag "new Ajax.Autocompleter( '#{field_id}', '#{choises_id}', '#{url}', #{options_for_javascript(options)} );"
17
17
  end
18
18
 
19
+ # http://blog.codahale.com/2006/01/14/a-rails-howto-simplify-in-place-editing-with-scriptaculous/
20
+ def editable_content(options)
21
+ options[:content] = { :element => 'span' }.merge(options[:content])
22
+ # options[:url] = {}.merge(options[:url])
23
+ options[:ajax] = { :okText => "'Save'", :cancelText => "'Cancel'"}.merge(options[:ajax] || {})
24
+ script = Array.new
25
+ script << "new Ajax.InPlaceEditor("
26
+ script << " '#{options[:content][:options][:id]}',"
27
+ script << " '#{options[:url]}',"
28
+ script << " {"
29
+ script << options[:ajax].map{ |key, value| "#{key.to_s}: #{value}" }.join(", ")
30
+ script << " }"
31
+ script << ")"
32
+
33
+ send(
34
+ options[:content][:element],
35
+ options[:content][:text],
36
+ options[:content][:options]
37
+ )
38
+
39
+ javascript_tag( script.join("\n") )
40
+ end
41
+
42
+
19
43
  # Autocomplete options :
20
44
  #
21
- # +:url+: URL to call for autocompletion results
22
- # +:tokens+:
23
- # +:frequency+:
24
- # +:minChars+:
25
- # +:indicator+: When sending the Ajax request Autocompleter shows this
26
- # +:updateElement+: Hook for a custom function called after the element has been updated (i.e. when the user has selected an entry).
27
- # +:afterUpdateElement+: Hook for a custom function called after the element has been updated (i.e. when the user has selected an entry).
28
- # +:callback+: This function is called just before the Request is actually made, allowing you to modify the querystring that is sent to the server.
29
- # +:parameters+: If you need to send any additional parameters through your search form, add them here, in the usual {field: 'value',another: 'value'} or 'field=value&another=value' manner.
45
+ # :url : URL to call for autocompletion results
46
+ # :tokens:
47
+ # :frequency :
48
+ # :minChars :
49
+ # :indicator : When sending the Ajax request Autocompleter shows this
50
+ # :updateElement : Hook for a custom function called after the element has been updated (i.e. when the user has selected an entry).
51
+ # :afterUpdateElement : Hook for a custom function called after the element has been updated (i.e. when the user has selected an entry).
52
+ # :callback : This function is called just before the Request is actually made, allowing you to modify the querystring that is sent to the server.
53
+ # :parameters : If you need to send any additional parameters through your search form, add them here, in the usual {field: 'value',another: 'value'} or 'field=value&another=value' manner.
30
54
  def text_field(field_name, value = "", options = {})
31
55
  autocomplete_options = nil
32
56
 
@@ -218,7 +218,7 @@ module BivouacHelpers
218
218
  def javascript_tag( content, options = {} )
219
219
  options[:type] = "text/javascript"
220
220
  script( options ) do
221
- "//<![CDATA[\n" + content + "\n//]]>"
221
+ "//<![CDATA[\n" + content + "\n//]]>\n"
222
222
  end
223
223
  end
224
224
 
@@ -27,11 +27,11 @@ SimpleDaemon::WORKING_DIRECTORY = DIRNAME + "/../log/"
27
27
  class <%= @conf.appname %>Daemon < SimpleDaemon::Base
28
28
  begin
29
29
  begin
30
- require 'thin'
31
- @@loaded_server = 'thin'
32
- rescue LoadError
33
30
  require 'mongrel/camping'
34
31
  @@loaded_server = 'mongrel'
32
+ rescue LoadError
33
+ require 'thin'
34
+ @@loaded_server = 'thin'
35
35
  end
36
36
  rescue LoadError
37
37
  require 'webrick/httpserver'
@@ -11,10 +11,22 @@
11
11
  #
12
12
  require 'rubygems'
13
13
  require 'camping'
14
- require 'camping/session'
15
14
  require 'mime/types'
16
15
  require 'bivouac'
17
16
 
17
+ <% if @conf.session == :db %>
18
+ require 'camping/session'
19
+ module <%= @conf.appname %>
20
+ include Camping::Session
21
+ end
22
+ <% else %>
23
+ require 'cookies_sessions'
24
+ module <%= @conf.appname %>
25
+ include Camping::CookieSessions
26
+ @@state_secret = "You want a really really long string of rubbish nobody could ever ever guess! Don't tell anyone! Not even your girlfriend or dog!"
27
+ end
28
+ <% end %>
29
+
18
30
  include Bivouac
19
31
 
20
32
  # Load libs
@@ -55,8 +67,14 @@ module <%= @conf.appname %>::Controllers
55
67
  else
56
68
  type = (MIME::Types.type_for(file)[0] || '/text/plain').to_s
57
69
  @headers['Content-Type'] = type
58
- @body = open( File.join( PATH, '..', 'public', file ) ).read
59
- # @headers['X-Sendfile'] = File.join PATH, '..', 'public', file
70
+ begin
71
+ @body = open( File.join( PATH, '..', 'public', file ) ).read
72
+ rescue Errno::ENOENT => e
73
+ @path = File.join '/public', file
74
+ @status = '404'
75
+ @headers['Content-Type'] = "text/html"
76
+ render :not_found
77
+ end
60
78
  end
61
79
  end
62
80
  end
@@ -6,6 +6,7 @@
6
6
  #
7
7
 
8
8
  require 'ostruct'
9
+ require 'yaml'
9
10
 
10
11
  module Bivouac
11
12
  class Environment
@@ -21,7 +22,7 @@ module Bivouac
21
22
  :port => <%= @conf.port %>,
22
23
 
23
24
  # Database configuration
24
- :db => <%= @conf.db %>,
25
+ :db => open("#{File.dirname( __FILE__ )}/database.yml") {|f| YAML.load(f)},
25
26
 
26
27
  # Name of the application
27
28
  # DO NOT CHANGE IT, OR YOU REALLY KNOW WHAT YOU ARE DOING!
@@ -33,7 +34,11 @@ module Bivouac
33
34
 
34
35
  # Organisation type of the application
35
36
  # DO NOT CHANGE IT, OR YOU REALLY KNOW WHAT YOU ARE DOING!
36
- :orgtype => "<%= @conf.orgtype %>"
37
+ :orgtype => "<%= @conf.orgtype %>",
38
+
39
+ # Session type
40
+ # DO NOT CHANGE IT, OR YOU REALLY KNOW WHAT YOU ARE DOING!
41
+ :session_type => "<%= @conf.session %>"
37
42
  )
38
43
  end
39
44
  end
@@ -5,11 +5,9 @@
5
5
  # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
6
6
  #
7
7
 
8
- module <%= @app.environment.appname %>
9
- include Camping::Session
10
- end
11
-
12
8
  def <%= @app.environment.appname %>.create
13
- Camping::Models::Session.create_schema
9
+ <% if @app.environment.session_type == :db %>
10
+ Camping::Models::Session.create_schema
11
+ <% end %>
14
12
  <%= @app.environment.appname %>::Models.create_schema
15
13
  end
@@ -9,8 +9,7 @@ module <%= @app.environment.appname %>::Models
9
9
  class Create<%= @model_class_name %> < V <%= @new_version %>
10
10
  def self.up
11
11
  create_table :<%= @model_table_name %> do |t|
12
- t.column :id, :integer, :null => false
13
- # ...
12
+
14
13
  end
15
14
  end
16
15
 
@@ -0,0 +1,11 @@
1
+ #
2
+ # Project <%= @app.environment.appname %>
3
+ #
4
+ # Created using bivouac on <%= Time.now %>.
5
+ # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
6
+ #
7
+
8
+ module <%= @app.environment.appname %>::Models
9
+ class Create<%= @model_class_name %> < V <%= @new_version %>
10
+ def self.up
11
+ create_table :<%= @model_table_name %> do |t|
@@ -0,0 +1 @@
1
+ t.<%= @model_data_type %> :<%= @model_data_name %>
@@ -0,0 +1,8 @@
1
+ end
2
+ end
3
+
4
+ def self.down
5
+ drop_table :<%= @model_table_name %>
6
+ end
7
+ end
8
+ end
@@ -0,0 +1 @@
1
+ add_column :<%= @model_table_name %>, :<%= @model_data_name %>, :<%= @model_data_type %>
@@ -0,0 +1,10 @@
1
+ #
2
+ # Project <%= @app.environment.appname %>
3
+ #
4
+ # Created using bivouac on <%= Time.now %>.
5
+ # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
6
+ #
7
+
8
+ module <%= @app.environment.appname %>::Models
9
+ class <%= @model_class_name %> < V <%= @new_version %>
10
+ def self.up
@@ -0,0 +1,3 @@
1
+ end
2
+ end
3
+ end
@@ -0,0 +1,3 @@
1
+ end
2
+
3
+ def self.down
@@ -0,0 +1 @@
1
+ remove_column :<%= @model_table_name %>, :<%= @model_data_name %>