-
Notifications
You must be signed in to change notification settings - Fork 21.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
r3190@asus: jeremy | 2005-11-19 20:20:48 -0800
Apply [3098] to stable. Introducing the session_migration generator. Creates an add_session_table migration. Closes #2958. git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/stable@3099 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
- Loading branch information
Showing
6 changed files
with
90 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
railties/lib/rails_generator/generators/components/session_migration/USAGE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Description: | ||
The session table migration generator creates a migration for adding a session table | ||
used by CGI::Session::ActiveRecordStore. | ||
|
||
The generator takes a migration name as its argument. The migration name may be | ||
given in CamelCase or under_score. | ||
|
||
The generator creates a migration class in db/migrate prefixed by its number | ||
in the queue. | ||
|
||
Example: | ||
./script/generate session_migration AddSessionTable | ||
|
||
With 4 existing migrations, this will create an AddSessionTable migration in the | ||
file db/migrate/5_add_session_table.rb |
13 changes: 13 additions & 0 deletions
13
...ib/rails_generator/generators/components/session_migration/session_migration_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class SessionMigrationGenerator < Rails::Generator::NamedBase | ||
def initialize(runtime_args, runtime_options = {}) | ||
runtime_args << 'add_session_table' if runtime_args.empty? | ||
super | ||
end | ||
|
||
def manifest | ||
record do |m| | ||
m.directory 'db/migrate' | ||
m.migration_template 'migration.rb', 'db/migrate' | ||
end | ||
end | ||
end |
15 changes: 15 additions & 0 deletions
15
railties/lib/rails_generator/generators/components/session_migration/templates/migration.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class <%= class_name %> < ActiveRecord::Migration | ||
def self.up | ||
create_table :sessions do |t| | ||
t.column :session_id, :string | ||
t.column :data, :text | ||
t.column :updated_at, :datetime | ||
end | ||
|
||
add_index :sessions, :session_id | ||
end | ||
|
||
def self.down | ||
drop_table :sessions | ||
end | ||
end |