Created
October 15, 2010 06:48
-
-
Save baileylo/627737 to your computer and use it in GitHub Desktop.
Modify migration files to add indexes and some database constraints on input size
This file contains hidden or 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
| class CreateBoards < ActiveRecord::Migration | |
| def self.up | |
| create_table :boards do |t| | |
| t.integer :id | |
| t.string :title, :limit => 50 | |
| t.timestamps | |
| end | |
| end | |
| def self.down | |
| drop_table :boards | |
| end | |
| end |
This file contains hidden or 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
| class CreateComments < ActiveRecord::Migration | |
| def self.up | |
| create_table :comments do |t| | |
| t.integer :id | |
| t.integer :user_id | |
| t.integer :conversation_id | |
| t.text :body | |
| t.timestamps | |
| end | |
| add_index :comments, :conversation_id | |
| add_index :comments, :user_id | |
| end | |
| def self.down | |
| drop_table :comments | |
| end | |
| end |
This file contains hidden or 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
| class CreateConversations < ActiveRecord::Migration | |
| def self.up | |
| create_table :conversations do |t| | |
| t.integer :id | |
| t.string :title, :limit => 50 | |
| t.integer :board_id | |
| t.integer :user_id | |
| t.timestamps | |
| end | |
| add_index :conversations, :board_id | |
| add_index :conversations, :user_id | |
| end | |
| def self.down | |
| drop_table :conversations | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment