rails学习笔记: rake db
命令行
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
数据类型
引用
# :string, :text, :integer, :float,:decimal, :datetime, :timestamp, :time, :date,
# :binary, :boolean
与db有关的rake任务
db:charset 检索当前环境下数据库的字符设置
db:collation 检索当前环境下数据库的校对
db:create 用config\database.yml中的定义创建当前 RAILS_ENV 项目环境下的数据库
db:create:all 用config\database.yml中的定义创建所有数据库
db:drop 删除当前 RAILS_ENV项目环境中的数据库
db:drop:all 删除所有在 config\database.yml中定义的数据库
db:reset 从db\schema.rb中为当前环境重建数据库(先删后建).
db:rollback 回滚(清华出版社一本SQLSERVER书的名词[很奇怪为什么不直接用滚回])数据库到前一个版本. 指定回滚到哪一步要用 STEP=n 参数
db:version 检索当前模式下的版本
备份数据库
rake db:backup:create 根据database.yml的信息备份数据库
rake db:backup:destroy 默认删除一天前的备份数据
rake db:backup:rebuild 默认恢复最新的备份数据
注意:这里设置的备份目录是db的backup目录,可以修改
添加索引
引用
add_index :acls, ["action_id","group_id"],:unique=>true
add_index :acls, :action_id
drop all tables 删除全部表
rake db:migrate VERSION=0
指定恢复/删除:
rake db:migrate:down/up VERSION = version_of_migrati
定义数字精确度
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 # Installs all 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
命令行
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
数据类型
引用
# :string, :text, :integer, :float,:decimal, :datetime, :timestamp, :time, :date,
# :binary, :boolean
与db有关的rake任务
db:charset 检索当前环境下数据库的字符设置
db:collation 检索当前环境下数据库的校对
db:create 用config\database.yml中的定义创建当前 RAILS_ENV 项目环境下的数据库
db:create:all 用config\database.yml中的定义创建所有数据库
db:drop 删除当前 RAILS_ENV项目环境中的数据库
db:drop:all 删除所有在 config\database.yml中定义的数据库
db:reset 从db\schema.rb中为当前环境重建数据库(先删后建).
db:rollback 回滚(清华出版社一本SQLSERVER书的名词[很奇怪为什么不直接用滚回])数据库到前一个版本. 指定回滚到哪一步要用 STEP=n 参数
db:version 检索当前模式下的版本
备份数据库
rake db:backup:create 根据database.yml的信息备份数据库
rake db:backup:destroy 默认删除一天前的备份数据
rake db:backup:rebuild 默认恢复最新的备份数据
注意:这里设置的备份目录是db的backup目录,可以修改
添加索引
引用
add_index :acls, ["action_id","group_id"],:unique=>true
add_index :acls, :action_id
drop all tables 删除全部表
rake db:migrate VERSION=0
指定恢复/删除:
rake db:migrate:down/up VERSION = version_of_migrati
定义数字精确度
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 # Installs all 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
相关推荐
来自practical rails social networking sites上的第二章的实例,应用了数据导入,导入数据到mysql后就可以使用,命令: rake db:migrate(进入文件夹"railscoder")
### Java基础之Rails命令大全知识点解析 #### 一、Rails 命令概述 Rails 是一个用于 Web 开发的框架,它基于 Ruby 语言。Rails 遵循 MVC(Model-View-Controller)架构模式,使得 Web 应用程序的开发更加高效、简洁...
Capistrano :: Rails :: Db Capistrano v3的Rails迁移任务: 在终端中运行cap -T deploy:db以获取迁移任务的完整列表: ...cap deploy:db:migrate # Run rake db:migrate Migrate the database (opti
Mongoid的数据迁移。 宝石文件: gem "mongoid_rails_migrations" 如何使用 创建迁移 $ rails generate mongoid:migration 运行迁移: $ rails db:migrate $ rails db:migrate:down VERSION=...$ rails db:version
添加 Rake 命令以转储和恢复应用程序的数据库。 委托常规转储实用程序,例如mysqldump和pg_dump 。 与它们不同的是,您不必记住任何正确的语法。 您也不必指定连接参数; 如果应用程序工作,转储程序也工作。 ...
### Ruby 命令集合(一些有用的命令) 在Ruby编程语言的世界里,Rails是一个非常流行的Web应用框架。本文将详细介绍一些常用的Rails命令...通过学习并熟练掌握这些命令,可以大大提高开发效率,使项目更加健壮和稳定。
Rails::API 是 Rails 的精简版本,针对不需要使用完整 Rails 功能的开发者。 Rails::API 移除了 ActionView 和其他一些渲染功能,不关心Web前端的开发者可更容易、快速地开发应用程序,因此运行速度比正常的 Rails ...
没有Rails的ActiveRecord 只是在没有Rails的情况下使用ActiveRecord迁移的简单示例您可以执行的任务: rake db:create rake db:migrate rake db:dropRails 5+的注意事项请注意,即使使用Rails 5,您也需要rake db:...
Rails命令允许我们快速地构建应用程序、管理数据库、生成代码以及执行各种自动化任务。以下是一些关键的Rails命令及其详细解释: 1. **创建Rails应用程序**: - `rails new demo`:这将创建一个新的Rails应用程序...
rake db:migrate 用法 定义设置 class User < ActiveRecord xss=removed> { :theme => 'blue' , :view => 'monthly' , :filter => false } s . key :calendar , :defaults => { :scope => 'company' } end end
学习Ruby on Rails 4.0的逐步指南。 它包括针对Ruby 2.0.0的基本教程,是为至少了解另一种编程语言并熟悉HTML的程序员编写的。
rails_app 这是一个Rails应用程序,具有初始设置和您每次所需的宝石。 版本 Ruby 2.7.1 Rails 6.0.3.3 纱1.22.5 ...rake db:seed_fu 命令 启动 bundle exec foreman start 测试运行 bundle exec rspec
rake db:migrate rails g backbone:scaffold Post title:string content:string 你现在已经安装了backbone-rails gem,为你的前端主干代码设置了一个默认的目录结构。 然后你生成了通常的 rails 服务器端 crud ...
Beginning Google Maps Applications with Rails and Ajax: From Novice to Professional
7. **启动后台任务**: 使用 `rake` 命令加上任务名称即可启动任务,例如 `rake background_task`。如果使用 DJ 或 Resque,还需要启动对应的 worker。 8. **错误处理与日志记录**: 在后台任务中,确保捕获并记录...
标题 "rails查询学习笔记" 涉及的是Ruby on Rails框架中的数据库查询技术。Ruby on Rails,简称Rails,是一款基于Ruby语言的开源Web应用程序框架,它遵循MVC(模型-视图-控制器)架构模式,使得开发Web应用更加高效...
本书教您如何使用Ruby on Rails开发和部署真正的,具有工业实力的Web应用程序,Ruby on Rails是为诸如Twitter,Hulu,GitHub和Yellow Pages等顶级网站提供支持的开源Web框架。
Rails ::虚拟 使用RSpec或Test :: Unit为引擎生成虚拟应用程序的简单任务。 安装 将此行添加到您的应用程序的Gemfile中: gem 'rails-dummy' 然后执行: $ bundle 或自己安装为: $ gem install rails-dummy ...
例如,`db:migrate`命令就是`rake`的一个典型应用,用于执行数据库的迁移操作。 在提供的文件列表中,`rake-0.8.7.gem`是rake库的gem包,它是Ruby的包管理系统,用于安装和管理Ruby库。通过运行`gem install rake-...
自制 命令: rails doc cd doc rake rails:freeze:gems 或 rake rails:freeze:edge rake doc:rails 在rails_app/doc/doc/目录中就生成了一个API目录,即可