为什么 rake db:migrate:reset 没有在 rake -T 中列出?

发布于 2024-09-27 23:30:39 字数 3902 浏览 1 评论 0原文

为什么 rake -T 没有列出一些 rake 任务?就像db:migrate:reset?我可以毫无问题地执行它,但为什么它没有列出来?有没有办法获得真正完整的 rake 任务列表?

% rake -T
(in /home/zeus/projects/my_project)
rake about              # List versions of all Rails frameworks and the environment
rake db:create          # Create the database from config/database.yml for the current Rails.env (use db:create:all to create all dbs in the config)
rake db:drop            # Drops the database for the current Rails.env (use db:drop:all to drop all databases)
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 steps w/ STEP=n).
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:seed            # Load the seed data from db/seeds.rb
rake db:setup           # Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first)
rake db:structure:dump  # Dump the database structure to an SQL file
rake db:version         # Retrieves the current schema version number
rake doc:app            # Generate docs for the app -- also availble doc:rails, doc:guides, doc:plugins (options: TEMPLATE=/rdoc-template.rb, TITLE="Custom Title")
rake erd                # Generate an Entity-Relationship Diagram based on your models
rake log:clear          # Truncates all *.log files in log/ to zero bytes
rake middleware         # Prints out your Rack middleware stack
rake notes              # Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)
rake notes:custom       # Enumerate a custom annotation, specify with ANNOTATION=CUSTOM
rake rails:template     # Applies the template supplied by LOCATION=/path/to/template
rake rails:update       # Update both configs and public/javascripts from Rails (or use just update:javascripts or update:configs)
rake routes             # Print out all defined routes in match order, with names.
rake secret             # Generate a crytographically secure secret key (this is typically used to generate a secret for cookie sessions).
rake spec               # Run all specs in spec directory (excluding plugin specs)
rake spec:acceptance    # Run the code examples in spec/acceptance
rake spec:controllers   # Run the code examples in spec/controllers
rake spec:helpers       # Run the code examples in spec/helpers
rake spec:lib           # Run the code examples in spec/lib
rake spec:mailers       # Run the code examples in spec/mailers
rake spec:models        # Run the code examples in spec/models
rake spec:rcov          # Run all specs with rcov
rake spec:requests      # Run the code examples in spec/requests
rake spec:routing       # Run the code examples in spec/routing
rake spec:views         # Run the code examples in spec/views
rake stats              # Report code statistics (KLOCs, etc) from the application
rake test               # Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile, test:plugins)
rake test:recent        # Run tests for recenttest:prepare / Test recent changes
rake test:uncommitted   # Run tests for uncommittedtest:prepare / Test changes since last checkin (only Subversion and Git)
rake time:zones:all     # Displays all time zones, also available: time:zones:us, time:zones:local -- filter with OFFSET parameter, e.g., OFFSET=-6
rake tmp:clear          # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear)
rake tmp:create         # Creates tmp directories for sessions, cache, sockets, and pids

Why are some rake tasks not listed by rake -T? Like db:migrate:reset? I can execute it without a problem, but why is it not listed there? Is there a way to get a real full list of rake tasks?

% rake -T
(in /home/zeus/projects/my_project)
rake about              # List versions of all Rails frameworks and the environment
rake db:create          # Create the database from config/database.yml for the current Rails.env (use db:create:all to create all dbs in the config)
rake db:drop            # Drops the database for the current Rails.env (use db:drop:all to drop all databases)
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 steps w/ STEP=n).
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:seed            # Load the seed data from db/seeds.rb
rake db:setup           # Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first)
rake db:structure:dump  # Dump the database structure to an SQL file
rake db:version         # Retrieves the current schema version number
rake doc:app            # Generate docs for the app -- also availble doc:rails, doc:guides, doc:plugins (options: TEMPLATE=/rdoc-template.rb, TITLE="Custom Title")
rake erd                # Generate an Entity-Relationship Diagram based on your models
rake log:clear          # Truncates all *.log files in log/ to zero bytes
rake middleware         # Prints out your Rack middleware stack
rake notes              # Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)
rake notes:custom       # Enumerate a custom annotation, specify with ANNOTATION=CUSTOM
rake rails:template     # Applies the template supplied by LOCATION=/path/to/template
rake rails:update       # Update both configs and public/javascripts from Rails (or use just update:javascripts or update:configs)
rake routes             # Print out all defined routes in match order, with names.
rake secret             # Generate a crytographically secure secret key (this is typically used to generate a secret for cookie sessions).
rake spec               # Run all specs in spec directory (excluding plugin specs)
rake spec:acceptance    # Run the code examples in spec/acceptance
rake spec:controllers   # Run the code examples in spec/controllers
rake spec:helpers       # Run the code examples in spec/helpers
rake spec:lib           # Run the code examples in spec/lib
rake spec:mailers       # Run the code examples in spec/mailers
rake spec:models        # Run the code examples in spec/models
rake spec:rcov          # Run all specs with rcov
rake spec:requests      # Run the code examples in spec/requests
rake spec:routing       # Run the code examples in spec/routing
rake spec:views         # Run the code examples in spec/views
rake stats              # Report code statistics (KLOCs, etc) from the application
rake test               # Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile, test:plugins)
rake test:recent        # Run tests for recenttest:prepare / Test recent changes
rake test:uncommitted   # Run tests for uncommittedtest:prepare / Test changes since last checkin (only Subversion and Git)
rake time:zones:all     # Displays all time zones, also available: time:zones:us, time:zones:local -- filter with OFFSET parameter, e.g., OFFSET=-6
rake tmp:clear          # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear)
rake tmp:create         # Creates tmp directories for sessions, cache, sockets, and pids

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

狂之美人 2024-10-04 23:30:39

没有描述的任务将不会显示。

编辑:看起来 DHH 删除了 Rails 3 中一些任务的描述,以“减少噪音”。 rake db:setup 有一个关于 db:reset 的注释。

http://github.com/rails/rails/commit/983815632cc1d316c7c803a47be28f1abe6698fb

Tasks that don't have a description will not show up.

EDIT: Looks like DHH removed the description from Rails 3 for a few tasks to 'cut down on noise'. rake db:setup has a note about db:reset though.

http://github.com/rails/rails/commit/983815632cc1d316c7c803a47be28f1abe6698fb

晨曦÷微暖 2024-10-04 23:30:39

您还可以使用 rake db -T -A 来显示所有任务,甚至是未注释的任务。作为参考,这些开关正在执行以下操作:

-T, --tasks [PATTERN]    Display the tasks (matching optional PATTERN) with 
                         descriptions, then exit.
-A, --all                Show all tasks, even uncommented ones (in combination 
                         with -T or -D)

You can also use rake db -T -A to show all tasks, even uncommented ones. For reference these switches are doing the following:

-T, --tasks [PATTERN]    Display the tasks (matching optional PATTERN) with 
                         descriptions, then exit.
-A, --all                Show all tasks, even uncommented ones (in combination 
                         with -T or -D)
一梦等七年七年为一梦 2024-10-04 23:30:39

您可以使用 rake -P | grep rake 显示所有 Rake 任务的名称。

You can use rake -P | grep rake to show the names of all Rake tasks.

执手闯天涯 2024-10-04 23:30:39

作为 Thomas Obermüller 回答的后续内容,由于 -T 标志采用位置参数,因此要仅获取“db”命名空间任务(至少对于 rake 10.0.3),您需要执行以下操作:rake -T db -一个

As a follow up to Thomas Obermüller's answer, since the -T flag takes a positional argument, to get just the 'db' namespace tasks (at least with rake 10.0.3) you need to do: rake -T db -A

笙痞 2024-10-04 23:30:39

在此 WIKI - Ruby on Rails/ActiveRecord/Migrations 上,您可以找到一些更多信息。

On this WIKI - Ruby on Rails/ActiveRecord/Migrations you can find some more information.

GRAY°灰色天空 2024-10-04 23:30:39

对于 Windows 用户,您可以执行此操作rake -P |找到“耙子”

For windows user, you do this rake -P | find "rake"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文