1. 16 10月, 2017 1 次提交
    • B
      Fix `bin/rails db:setup` and `bin/rails db:test:prepare` create wrong... · 99b2bf8d
      bogdanvlviv 提交于
      Fix `bin/rails db:setup` and `bin/rails db:test:prepare` create  wrong ar_internal_metadata's data for a test database.
      
        Before:
        ```
        $ RAILS_ENV=test rails dbconsole
        > SELECT * FROM ar_internal_metadata;
        key|value|created_at|updated_at
        environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
        ```
      
        After:
        ```
        $ RAILS_ENV=test rails dbconsole
        > SELECT * FROM ar_internal_metadata;
        key|value|created_at|updated_at
        environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
        ```
      
        Fixes #26731.
      99b2bf8d
  2. 24 7月, 2017 1 次提交
    • E
      Avoid modifying frozen string in check_schema_file · 2b331e90
      Eugene Kenny 提交于
      This was missed when the frozen string literal pragma was added to this
      file because the string is only modified when running in the context of
      a full Rails app, which wasn't covered by the test suite.
      2b331e90
  3. 20 7月, 2017 1 次提交
  4. 11 7月, 2017 1 次提交
    • K
      * Don't eagerly require Rails' minitest plugin. · 0d72489b
      Kasper Timm Hansen 提交于
      By making the Rails minitest behave like a standard minitest plugin
      we're much more likely to not break when people use other minitest
      plugins. Like minitest-focus and pride.
      
      To do this, we need to behave like minitest: require files up front
      and then perform the plugin behavior via the at_exit hook.
      This also saves us a fair bit of wrangling with test file loading.
      
      Finally, since the environment and warnings options have to be applied
      as early as possible, and since minitest loads plugins at_exit, they
      have to be moved to the test command.
      
      * Don't expect the root method.
      
      It's likely this worked because we eagerly loaded the Rails minitest plugin
      and that somehow defined a root method on `Rails`.
      
      * Assign a backtrace to failed exceptions.
      
      Otherwise Minitest pukes when attempting to filter the backtrace (which
      Rails' backtrace cleaner then removes).
      
      Means the exception message test has to be revised too.
      
      This is likely caused by the rails minitest plugin now being loaded for
      these tests and assigning a default backtrace cleaner.
      0d72489b
  5. 02 7月, 2017 1 次提交
  6. 01 7月, 2017 1 次提交
  7. 24 5月, 2017 1 次提交
  8. 11 5月, 2017 1 次提交
    • A
      Defer loading each DB Tasks class from AR DatabaseTasks · f73b8456
      Akira Matsuda 提交于
      Because we don't need to load tasks for DBs that we don't use for the current app.
      Also, these Tasks classes load AR::Base in their class level, and so immediately kick :active_record on_load hooks.
      This used to happen when we were loading tasks, not when we run a task.
      f73b8456
  9. 27 4月, 2017 1 次提交
  10. 27 3月, 2017 1 次提交
    • P
      Fixes #28359 · 14739b5e
      Philippe Guay 提交于
      Add stronger assertions to rake migration tasks to make sure the user is providing a numeric VERSION
      An empty string was getting converted to version = 0. This would in turn pass the presence check.
      
      Address linting warning
      
      Add test for rake task and refactor code to meet expectations
      In particular passing VERSION=0 should not raise an error.
      
      Addressed Comments for PR #28485. Trimmed empty lines + change of wording for error message
      
      Adjust test for change of wording in error message
      
      Change condition to follow rails idioms
      14739b5e
  11. 12 1月, 2017 1 次提交
  12. 04 1月, 2017 1 次提交
  13. 02 1月, 2017 1 次提交
    • K
      Dump schema cache for custom connection · 6cd75796
      Kir Shatrov 提交于
      Today `rake db:schema:cache:dump` only supports dumping cache for a
      single connection (`ActiveRecord::Base.connection`). This doesn't work
      for apps with multiple databases.
      
      This PR makes `DatabaseTasks` to provide an API for dumping schema cache
      for any connection.
      6cd75796
  14. 30 12月, 2016 1 次提交
  15. 23 12月, 2016 1 次提交
    • K
      Make ActiveRecord structure load/dump configurable · b8f74860
      Kir Shatrov 提交于
      Without this patch it's impossible to pass extra flags to
      mysqldump/pg_dump when running `rake db:structure:dump` or `load`
      
      The following config variables (`structure_load_flags` and `structure_dump_flags`)
      make it better configurable.
      b8f74860
  16. 29 10月, 2016 1 次提交
  17. 08 8月, 2016 1 次提交
  18. 07 8月, 2016 3 次提交
  19. 25 5月, 2016 2 次提交
  20. 07 5月, 2016 1 次提交
  21. 06 5月, 2016 2 次提交
  22. 18 4月, 2016 1 次提交
  23. 25 3月, 2016 1 次提交
    • C
      Make 'migrate' clear the schema cache afterward · 16dadb12
      Chris Arcand 提交于
      Without clearing the caches afterward, removals done in migrations would
      not be reflected in a separate task in the same process. That is, given
      a table with a migration to remove a column, the schema cache would
      still reflect that a table has that in something such as the
      'db:seed' task:
      
      `rake db:migrate db:seed`
      (A common thing to do in a script for a project ala `bin/setup`)
      
      vs
      
      `rake db:migrate && rake db:seed`
      (Two processes)
      
      The first would not reflect that the column was removed.
      The second would (cache reset).
      16dadb12
  24. 15 3月, 2016 1 次提交
    • R
      Creates development and test databases in db:migrate task · 6ca9031b
      Rafael Mendonça França 提交于
      This reverts a334425c.
      
      The main reason is that now the workflow is inconsistent when using
      spring.
      
      When using spring `RAILS_ENV` is always set, so only one database is
      created.
      
      This means that in development `bin/rake db:create` and `bundle exec
      rake db:create` have different results.
      
      It also breaks the `bin/setup` script since `bin/rake db:setup
      db:test:prepare` will fail.
      6ca9031b
  25. 24 2月, 2016 1 次提交
  26. 09 1月, 2016 2 次提交
  27. 08 1月, 2016 3 次提交
    • S
    • S
      Add EnvironmentMismatchError · a76c4233
      schneems 提交于
      Raise an error when a destructive action is made on a database where the current environment is different from the environment stored in the database.
      a76c4233
    • S
      Prevent destructive action on production database · 900bfd94
      schneems 提交于
      This PR introduces a key/value type store to Active Record that can be used for storing internal values. It is an alternative implementation to #21237 cc @sgrif @matthewd.
      
      It is possible to run your tests against your production database by accident right now. While infrequently, but as an anecdotal data point, Heroku receives a non-trivial number of requests for a database restore due to this happening. In these cases the loss can be large.
      
      To prevent against running tests against production we can store the "environment" version that was used when migrating the database in a new internal table. Before executing tests we can see if the database is a listed in `protected_environments` and abort. There is a manual escape valve to force this check from happening with environment variable `DISABLE_DATABASE_ENVIRONMENT_CHECK=1`.
      900bfd94
  28. 18 12月, 2015 1 次提交
  29. 21 10月, 2015 2 次提交
    • J
      Exit with non-zero status when db:drop fails · c2e597a7
      Jay Hayes 提交于
      * If the drop task fails for a reason other than the database not
        existing, processing should end. This is indicated by a non-zero
        exit status.
      * Since the backtrace is already printed to screen, we forgo
        printing it again by using an explicit call to `exit`.
      *  This modifies the behavior of the db:create task slightly in
        that the stack trace is no longer printed by default. If the `--trace`
        option is used, it will print the trace _after_ the error message.
      c2e597a7
    • J
      Exit with non-zero status when db:create fails · 2893e6c0
      Jay Hayes 提交于
      * If the create task fails for a reason other than the database already
        existing, processing should end. This is indicated by a non-zero exit
        status.
      * Since the backtrace is already printed to screen, we forgo printing it
        again by using an explicit call to `exit`.
      *  This modifies the behavior of the db:create task slightly in
        that the stack trace is no longer printed by default. If the `--trace`
        option is used, it will print the trace _after_ the error message.
      2893e6c0
  30. 14 10月, 2015 2 次提交
    • Y
      applies new doc guidelines to Active Record. · 428d47ad
      Yves Senn 提交于
      The focus of this change is to make the API more accessible.
      References to method and classes should be linked to make it easy to
      navigate around.
      
      This patch makes exzessiv use of `rdoc-ref:` to provide more readable
      docs. This makes it possible to document `ActiveRecord::Base#save` even
      though the method is within a separate module
      `ActiveRecord::Persistence`. The goal here is to bring the API closer to
      the actual code that you would write.
      
      This commit only deals with Active Record. The other gems will be
      updated accordingly but in different commits. The pass through Active
      Record is not completely finished yet. A follow up commit will change
      the spots I haven't yet had the time to update.
      
      /cc @fxn
      428d47ad
    • Y
      fix RDoc list markup in `DatabaseTasks`. [ci skip] · 31af8c90
      Yves Senn 提交于
      31af8c90
  31. 09 9月, 2015 1 次提交