Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactor migrations:

* Remove self from up and down method
* Use add_index helper to create index
* Use symbol everywhere
  • Loading branch information...
commit 4c6f8d34526113fdcecbd9da3f5bd853258596da 1 parent 5a045bd
@joneslee85 joneslee85 authored
View
140 db/migrate/009_initialize_db.rb
@@ -1,99 +1,99 @@
class InitializeDb < ActiveRecord::Migration
- def self.up
- create_table "comments" do |t|
- t.integer "post_id", :null => false
- t.string "author", :null => false
- t.string "author_url", :null => false
- t.string "author_email", :null => false
- t.string "author_openid_authority", :null => false
- t.text "body", :null => false
- t.text "body_html", :null => false
- t.datetime "created_at"
- t.datetime "updated_at"
+ def up
+ create_table :comments do |t|
+ t.integer :post_id, :null => false
+ t.string :author, :null => false
+ t.string :author_url, :null => false
+ t.string :author_email, :null => false
+ t.string :author_openid_authority, :null => false
+ t.text :body, :null => false
+ t.text :body_html, :null => false
+ t.datetime :created_at
+ t.datetime :updated_at
end
- add_index "comments", ["post_id"], :name => "index_comments_on_post_id"
- add_index "comments", ["created_at"], :name => "index_comments_on_created_at"
+ add_index :comments, :post_id, :name => 'index_comments_on_post_id'
+ add_index :comments, :created_at, :name => 'index_comments_on_created_at'
- create_table "open_id_authentication_associations" do |t|
- t.integer "issued"
- t.integer "lifetime"
- t.string "handle"
- t.string "assoc_type"
- t.binary "server_url"
- t.binary "secret"
+ create_table :open_id_authentication_associations do |t|
+ t.integer :issued
+ t.integer :lifetime
+ t.string :handle
+ t.string :assoc_type
+ t.binary :server_url
+ t.binary :secret
end
- create_table "open_id_authentication_nonces" do |t|
- t.integer "timestamp", :null => false
- t.string "server_url"
- t.string "salt", :null => false
+ create_table :open_id_authentication_nonces do |t|
+ t.integer :timestamp, :null => false
+ t.string :server_url
+ t.string :salt, :null => false
end
- create_table "pages" do |t|
- t.string "title", :null => false
- t.string "slug", :null => false
- t.text "body", :null => false
- t.text "body_html", :null => false
- t.datetime "created_at"
- t.datetime "updated_at"
+ create_table :pages do |t|
+ t.string :title, :null => false
+ t.string :slug, :null => false
+ t.text :body, :null => false
+ t.text :body_html, :null => false
+ t.datetime :created_at
+ t.datetime :updated_at
end
- add_index "pages", ["title"], :name => "index_pages_on_title"
- add_index "pages", ["created_at"], :name => "index_pages_on_created_at"
-
- create_table "posts" do |t|
- t.string "title", :null => false
- t.string "slug", :null => false
- t.text "body", :null => false
- t.text "body_html", :null => false
- t.boolean "active", :default => true, :null => false
- t.integer "approved_comments_count", :default => 0, :null => false
- t.string "cached_tag_list"
- t.datetime "published_at"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.datetime "edited_at", :null => false
+ add_index :pages, :title, :name => 'index_pages_on_title'
+ add_index :pages, :created_at, :name => 'index_pages_on_created_at'
+
+ create_table :posts do |t|
+ t.string :title, :null => false
+ t.string :slug, :null => false
+ t.text :body, :null => false
+ t.text :body_html, :null => false
+ t.boolean :active, :default => true, :null => false
+ t.integer :approved_comments_count, :default => 0, :null => false
+ t.string :cached_tag_list
+ t.datetime :published_at
+ t.datetime :created_at
+ t.datetime :updated_at
+ t.datetime :edited_at, :null => false
end
- add_index "posts", ["published_at"], :name => "index_posts_on_published_at"
+ add_index :posts, :published_at, :name => 'index_posts_on_published_at'
- create_table "sessions" do |t|
- t.string "session_id", :null => false
- t.text "data"
- t.datetime "created_at"
- t.datetime "updated_at"
+ create_table :sessions do |t|
+ t.string :session_id, :null => false
+ t.text :data
+ t.datetime :created_at
+ t.datetime :updated_at
end
- add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
- add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
+ add_index :sessions, :updated_at, :name => 'index_sessions_on_updated_at'
+ add_index :sessions, :session_id, :name => 'index_sessions_on_session_id'
- create_table "taggings" do |t|
- t.integer "tag_id"
- t.integer "taggable_id"
- t.datetime "created_at"
+ create_table :taggings do |t|
+ t.integer :tag_id
+ t.integer :taggable_id
+ t.datetime :created_at
end
- add_index "taggings", ["taggable_id"], :name => "index_taggings_on_taggable_id_and_taggable_type"
- add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
+ add_index :taggings, :taggable_id, :name => 'index_taggings_on_taggable_id_and_taggable_type'
+ add_index :taggings, :tag_id, :name => 'index_taggings_on_tag_id'
- create_table "tags" do |t|
- t.string "name"
- t.integer "taggings_count", :default => 0, :null => false
+ create_table :tags do |t|
+ t.string :name
+ t.integer :taggings_count, :default => 0, :null => false
end
- add_index "tags", ["name"], :name => "index_tags_on_name"
+ add_index :tags, :name, :name => 'index_tags_on_name'
- create_table "undo_items" do |t|
- t.string "type", :null => false
- t.datetime "created_at", :null => false
- t.text "data"
+ create_table :undo_items do |t|
+ t.string :type, :null => false
+ t.datetime :created_at, :null => false
+ t.text :data
end
- add_index "undo_items", ["created_at"], :name => "index_undo_items_on_created_at"
+ add_index :undo_items, :created_at, :name => 'index_undo_items_on_created_at'
end
- def self.down
+ def down
raise IrreversibleMigration
end
end
View
4 db/migrate/20081224020432_remove_openid_authority_from_comment.rb
@@ -1,9 +1,9 @@
class RemoveOpenidAuthorityFromComment < ActiveRecord::Migration
- def self.up
+ def up
remove_column :comments, :author_openid_authority
end
- def self.down
+ def down
add_column :comments, :author_openid_authority, :string, :null => false
end
end
View
16 db/migrate/20110709024316_add_indexes.rb
@@ -1,16 +1,6 @@
class AddIndexes < ActiveRecord::Migration
- def self.up
- execute <<-SQL
- CREATE INDEX posts_slug_unique_idx ON posts (slug)
- SQL
-
- execute <<-SQL
- CREATE UNIQUE INDEX pages_slug_unique_idx ON pages (slug)
- SQL
- end
-
- def self.down
- execute "DROP INDEX posts_slug_unique_idx"
- execute "DROP INDEX pages_slug_unique_idx"
+ def change
+ add_index :posts, :slug, :name => 'posts_slug_unique_idx'
+ add_index :pages, :slug, :name => 'pages_slug_unique_idx'
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.