Created
October 6, 2012 02:38
-
-
Save chyld/3843533 to your computer and use it in GitHub Desktop.
activerecord
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
| ***database tasks | |
| add_column | |
| add_index | |
| change_column | |
| change_table | |
| create_table | |
| drop_table | |
| remove_column | |
| remove_index | |
| rename_column | |
| ***types | |
| :binary | |
| :boolean | |
| :date | |
| :datetime | |
| :decimal | |
| :float | |
| :integer | |
| :primary_key | |
| :string | |
| :text | |
| :time | |
| :timestamp | |
| ***creating a migration | |
| rails generate migration AddPartNumberToProducts | |
| ***creating a table | |
| create_table :products do |t| | |
| t.string :name | |
| t.text :description | |
| t.timestamps | |
| end | |
| ***adding a column to a table | |
| add_column :products, :part_number, :string | |
| ***rake db commands | |
| rake db:create # Create the database from config/database.yml for the curren... | |
| rake db:drop # Drops the database for the current Rails.env (use db:drop:a... | |
| rake db:fixtures:load # Load fixtures into the current environment's database. | |
| rake db:migrate # Migrate the database (options: VERSION=x, VERBOSE=false). | |
| rake db:migrate:status # Display status of migrations | |
| rake db:rollback # Rolls the schema back to the previous version (specify step... | |
| rake db:schema:dump # Create a db/schema.rb file that can be portably used agains... | |
| rake db:schema:load # Load a schema.rb file into the database | |
| rake db:seed # Load the seed data from db/seeds.rb | |
| rake db:setup # Create the database, load the schema, and initialize with t... | |
| rake db:structure:dump # Dump the database structure to db/structure.sql. Specify an... | |
| rake db:version # Retrieves the current schema version number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment