]> git.openstreetmap.org Git - rails.git/blob - vendor/plugins/sql_session_store/generators/sql_session_store/sql_session_store_generator.rb
6af6bd0bc2eb8f47a0acb14242ddbeddd0e67752
[rails.git] / vendor / plugins / sql_session_store / generators / sql_session_store / sql_session_store_generator.rb
1 class SqlSessionStoreGenerator < Rails::Generator::NamedBase
2   def initialize(runtime_args, runtime_options = {})
3     runtime_args.insert(0, 'add_sql_session')
4     if runtime_args.include?('postgresql')
5       @_database = 'postgresql'
6     elsif runtime_args.include?('mysql')
7       @_database = 'mysql'
8     elsif runtime_args.include?('oracle')
9       @_database = 'oracle'
10     else
11       puts "error: database type not given.\nvalid arguments are: mysql or postgresql"
12       exit
13     end
14     super
15   end
16
17   def manifest
18     record do |m|
19       m.migration_template("migration.rb", 'db/migrate',
20                            :assigns => { :migration_name => "SqlSessionStoreSetup", :database => @_database },
21                            :migration_file_name => "sql_session_store_setup"
22                            )
23     end
24   end
25 end