数据类型
引用
# :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 删除当前 droRAILS_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

db:create creates the database for the current env
db:create:all creates the databases for all envs
db:drop drops the database for the current env
db:drop:all drops the databases for all envs
db:migrate runs migrations for the current env that have not run yet
db:migrate:up runs one specific migration
db:migrate:down rolls back one specific migration
db:migrate:status shows current migration status
db:rollback rolls back the last migration
db:forward advances the current schema version to the next one
db:seed (only) runs the db/seed.rb file
db:schema:load loads the schema into the current env's database
db:schema:dump dumps the current env's schema (and seems to create the db as well)
db:setup runs db:schema:load, db:seed
db:reset runs db:drop db:setup
db:migrate:redo runs (db:migrate:down db:migrate:up) or (db:rollback db:migrate) depending on the specified migration
db:migrate:reset runs db:drop db:create db:migrate

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

migrate的更多相关文章

  1. PHP工作笔记:使用yii migrate管理、生成数据库

    第一步:进入yii migrate 通过dos(我是win7系统,其他系统类似,就是进入字符界面)打开网站目录 phpStudy/WWW/local/ddc_dlss 输入 ./yii migrate ...

  2. Migrate Instance 操作详解 - 每天5分钟玩转 OpenStack(40)

    Migrate 操作的作用是将 instance 从当前的计算节点迁移到其他节点上. Migrate 不要求源和目标节点必须共享存储,当然共享存储也是可以的. Migrate 前必须满足一个条件:计算 ...

  3. Live Migrate 操作 - 每天5分钟玩转 OpenStack(42)

    Migrate 操作会先将 instance 停掉,也就是所谓的“冷迁移”.而 Live Migrate 是“热迁移”,也叫“在线迁移”,instance不会停机. Live Migrate 分两种: ...

  4. South - 在 Django 中 Migrate Database

    Web 开发避免不了经常修改表结构,手工修改表结构不仅容易出错,而且涉及到多人协作开发时,这么土的做法很不经济. Django 的第三方 app South 就是专门做数据库表结构自动迁移的.Jaco ...

  5. 使用migrate.exe执行EF code first 迁移

    Code First 迁移可用于从 Visual Studio 内部更新数据库,但也可通过命令行工具 migrate.exe 来执行.本页简单介绍如何使用 migrate.exe 对数据库执行迁移. ...

  6. How to migrate from VMware and Hyper-V to OpenStack

    Introduction I migrated >120 VMware virtual machines (Linux and Windows) from VMware ESXi to Open ...

  7. mybatis migrate常用指令

    0.制定db和配置文件 --path=xxx --env=dev 1.初始化Migrations工作目录 migrate init 2.创建数据库变更 migrate new "liyq a ...

  8. South——谁说Django不能migrate!

    零.前言 最近改一个项目,需要对已有的model进行更改.大家都知道Django自带的syncdb只能创建数据库,但是无法将已经改变的model应用的数据库中. 大概两年前遇到这个问题的时候,网上的答 ...

  9. 当用DJANGO的migrate不成功时。。。。

    URL:http://my.oschina.net/u/862582/blog/355421 因为操作SQL数据库时不规范,或是多人开发时产生了同步问题,就可能导致正规的MIGRATE时不能完成. 已 ...

  10. Yii2的相关学习记录,前后台分离及migrate使用(七)

    最近一直忙其它的(其实是懒!),将<深入理解Yii2>看了一遍,一些当初没明白的稍微明了了点,然后又看yii2的图片上传等处理.富文本.restful什么的,但由于没进行到这里,只看也不管 ...

随机推荐

  1. Android提供支持不同屏幕大小的各种方法

    1 http://blog.csdn.net/guolin_blog/article/details/8830286  (手机平板,通过large-layout来区分两条布局文件) 2 http:// ...

  2. VS2012 未找到与约束ContractName Microsoft.VisualStudio.Text.ITextDocumentFactoryService 未找到与约束ContractName,无法打开项目的解决方案 SQLyog 注册码

    VS2012 未找到与约束ContractName Microsoft.VisualStudio.Text.ITextDocumentFactoryService   最近新换了系统还真是问题多多呀! ...

  3. 通过Cloudera Manager安装CDH 5.6

    CDH的简介 大家常常说CDH.其全称是:Cloudera's Distribution Including Apache Hadoop.简单的说是Cloudera公司的Hadoop平台,是在Apac ...

  4. flume配置和说明(转)

    Flume是什么 收集.聚合事件流数据的分布式框架 通常用于log数据 采用ad-hoc方案,明显优点如下: 可靠的.可伸缩.可管理.可定制.高性能 声明式配置,可以动态更新配置 提供上下文路由功能 ...

  5. Maven环境下搭建SSH框架之Spring整合Hibernate

    © 版权声明:本文为博主原创文章,转载请注明出处 1.搭建环境 Spring:4.3.8.RELEASE Hibernate:5.1.7.Final MySQL:5.7.17 注意:其他版本在某些特性 ...

  6. web.xml中url-pattern匹配规则

    小知识 一般的URL组成 URL = 服务器地址 + RequestURI 例如URI:http://localhost:8080/practice/main [http://localhost:80 ...

  7. NFS网络文件系统服务(配置实战)

    NFS网络文件系统服务(实战) NFS(Network File System)即网络文件系统,它允许网络中的计算机之间通过TCP/IP网络共享资源.让不同的主机系统(NFS的客户端)可以透明地读写位 ...

  8. Weblogic配置故障转移

    前提:实现负载均衡,即当访问项目时,会通过代理服务器将请求分发到不同的服务器上. weblogic的故障转移配置 在项目的WEB-INF目录下创建weblogic.xml <!DOCTYPE w ...

  9. git学习之时光机穿梭(四)

    时光机穿梭 我们已经成功地添加并提交了一个readme.txt文件,现在,是时候继续工作了,于是,我们继续修改readme.txt文件,改成如下内容: Git is a distributed ver ...

  10. horizontalDragMaxWidth:0;就没有水平滚动条了

    jquery.jscrollpane.css JScrollPane工作所必须的基本的CSS样式.jquery.min.jsjQuery作为javascript库必须提前引入.jquery.mouse ...