Create a database that supports utf8 by default, createdatabasedb1defacharcharactersetutf8; command line rakedb: ***** scriptgeneratemodeltaskname: stringpriority: Role: stringscriptgeneratemigrationremove_de
Create a database that supports utf8 by default. createdatabasedb1defacharcharactersetutf8; command line: rakedb: ***** script/generatemodeltaskname: stringpriority: integer script/handler: string script/generatemigrationremove_de
Create a database that supports utf8 by default
Create database db1 default character set utf8;
Command Line
Rake db :*****
Script/generate model task name: string priority: integer
Script/generate migration add_description_to_task description: string
Script/generate migration remove_description_from_task description: string
Data Type
Reference
#: String,: text,: integer,: float,: decimal,: datetime,: timestamp,: time,: date,
#: Binary,: boolean
Db-related rake tasks
Db: charset: character settings for retrieving databases in the current environment
Db: collation
Db: create a database in the current RAILS_ENV project environment using the definition in config \ database. yml.
Db: create: all use the definition in config \ database. yml to create all databases
Db: drop Delete the database in the current RAILS_ENV Project Environment
Db: drop: all delete all databases defined in config \ database. yml
Db: reset: rebuild the database from db \ schema. rb for the current environment (delete and then create ).
Db
Db: version: Search for versions in Current Mode
Back up database
Rake db: backup: create backs up a database based on database. yml Information
Rake db: backup: destroy deletes the backup data one day ago by default.
Rake db: backup: rebuild restores the latest backup data by default
Note: The backup directory set here is the db backup Directory, which can be modified.
Add Index
Reference
Add_index: acls, ["action_id", "group_id"],: unique => true
Add_index: acls,: action_id
Drop all tables Delete all tables
Rake db: migrate VERSION = 0
Specify recovery/Deletion:
Rake db: migrate: down/up VERSION = version_of_migrati
Define numeric Accuracy
T. integer: total_price,: precision => 8,: scale => 2,: default => 0
========================================================== ========================================================== ========================================================== ======================================
Rake db: abort_if_pending_migrations # Raises an error if there are pending migrations
Rake db: charset # Retrieves the charset for the current environment's database
Rake db: collation # Retrieves the collation for the current environment's database
Rake db: create # Create the database defined in config/database. yml for the current RAILS_ENV
Rake db: create: all # Create all the local databases defined in config/database. yml
Rake db: drop # Drops the database for the current RAILS_ENV
Rake db: drop: all # Drops all the local databases defined in config/database. yml
Rake db: fixtures: identify # Search for a fixture given a LABEL or ID.
Rake db: fixtures: load # Load fixtures into the current environment's database.
Rake db: migrate # Migrate the database through scripts in db/migrate.
Rake db: migrate: down # Runs the "down" for a given migration VERSION.
Rake db: migrate: redo # Rollbacks the database one migration and re migrate up.
Rake db: migrate: reset # Resets your database using your migrations for the current environment
Rake db: migrate: up # Runs the "up" for a given migration VERSION.
Rake db: reset # Drops and recreates the database from db/schema. rb for the current environment.
Rake db: rollback # Rolls the schema back to the previous version.
Rake db: schema: dump # Create a db/schema. rb file that can be portably used against any DB supported by AR
Rake db: schema: load # Load a schema. rb file into the database
Rake db: sessions: clear # Clear the sessions table
Rake db: sessions: create # Creates a sessions migration for use with CGI: Session: ActiveRecordStore
Rake db: structure: dump # Dump the database structure to a SQL file
Rake db: test: clone # Recreate the test database from the current environment's database schema
Rake db: test: clone_structure # Recreate the test databases from the development structure
Rake db: test: load # Recreate the test database from the current schema. rb
Rake db: test: prepare # Check for pending migrations and load the test schema
Rake db: test: purge # Empty the test database
Rake db: version # Retrieves the current schema version number
Rake doc: app # Build the app HTML Files
Rake doc: clobber_app # Remove rdoc products
Rake doc: clobber_plugins # Remove plugin documentation
Rake doc: clobber_rails # Remove rdoc products
Rake doc: guides # Generate Rails guides
Rake doc: plugins # Generate documentation for all installed plugins
Rake doc: rails # Build the rails HTML Files
Rake doc: reapp # Force a rebuild of the RDOC files
Rake doc: rerails # Force a rebuild of the RDOC files
Rake gems # List the gems that this rails application depends on
Rake gems: build # Build any native extensions for unpacked gems
Rake gems: install # installall required gems for this application.
Rake gems: refresh_specs # Regenerate gem specifications in correct format.
Rake gems: unpack # Unpacks the specified gem into vendor/gems.
Rake gems: unpack: dependencies # Unpacks the specified gems and its dependencies into vendor/gems
Rake log: clear # Truncates all *. log files in log/to zero bytes
Rake notes # Enumerate all annotations
Rake notes: custom # Enumerate a custom annotation, specify with ANNOTATION = WTFHAX
Rake notes: fixme # Enumerate all FIXME annotations
Rake notes: optimize # Enumerate all OPTIMIZE annotations
Rake notes: todo # Enumerate all TODO annotations
Rake rails: freeze: edge # Lock to latest Edge Rails, for a specific release use RELEASE = 1.2.0
Rake rails: freeze: gems # Lock this application to the current gems (by unpacking them into vendor/rails)
Rake rails: unfreeze # Unlock this application from freeze of gems or edge and return to a fluid use of system gems
Rake rails: update # Update both configs, scripts and public/javascripts from Rails
Rake rails: update: configs # Update config/boot. rb from your current rails install
Rake rails: update: javascripts # Update your javascripts from your current rails install
Rake rails: update: scripts # Add new scripts to the application script/directory
Rake routes # Print out all defined routes in match order, with names.
Rake secret # Generate a crytographically secure secret key.
Rake stats # Report code statistics (KLOCs, etc) from the application
Rake test # Run all unit, functional and integration tests
Rake test: benchmark # Run tests for benchmarkdb: test: prepare/Benchmark the performance tests
Rake test: functionals # Run tests for functionalsdb: test: prepare/Run the functional tests in test/functional
Rake test: integration # Run tests for integrationdb: test: prepare/Run the integration tests in test/integration
Rake test: plugins # Run tests for pluginsenvironment/Run the plugin tests in vendor/plugins/*/**/test (or specify with PLUGIN = name)
Rake test: profile # Run tests for profiledb: test: prepare/Profile the performance tests
Rake test: recent # Run tests for recentdb: test: prepare/Test recent changes
Rake test: uncommitted # Run tests for uncommitteddb: test: prepare/Test changes since last checkin (only Subversion and Git)
Rake test: units # Run tests for unitsdb: test: prepare/Run the unit tests in test/unit
Rake time: zones: all # Displays names of all time zones recognized by the Rails TimeZone class, grouped by offset.
Rake time: zones: local # Displays names of time zones recognized by the Rails TimeZone class with the same offset as the system local time
Rake time: zones: us # Displays names of US time zones recognized by the Rails TimeZone class, grouped by offset.
Rake tmp: cache: clear # Clears all files and directories in tmp/cache
Rake tmp: clear # Clear session, cache, and socket files from tmp/
Rake tmp: create # Creates tmp directories for sessions, cache, and sockets
Rake tmp: pids: clear # Clears all files in tmp/pids
Rake tmp: sessions: clear # Clears all files in tmp/sessions
Rake tmp: sockets: clear # Clears all files in tmp/sockets