1. 19 10月, 2016 1 次提交
  2. 01 10月, 2016 1 次提交
    • L
      Add missing require for zlib · c16a70a4
      Lars Kanis 提交于
      Zlib is used to generate the advisory lock since commit 2c2a8755 .
      
      Using the Migrator fails since then, when it is called without the rails context:
      
          NameError: uninitialized constant ActiveRecord::Migrator::Zlib
      
      This patch fixes the above error.
      c16a70a4
  3. 14 9月, 2016 1 次提交
  4. 16 8月, 2016 1 次提交
  5. 07 8月, 2016 4 次提交
  6. 25 7月, 2016 1 次提交
  7. 24 7月, 2016 1 次提交
  8. 21 7月, 2016 1 次提交
  9. 13 5月, 2016 1 次提交
  10. 03 5月, 2016 1 次提交
  11. 01 5月, 2016 1 次提交
  12. 30 4月, 2016 1 次提交
  13. 10 4月, 2016 1 次提交
  14. 24 3月, 2016 1 次提交
  15. 14 3月, 2016 1 次提交
  16. 19 1月, 2016 1 次提交
  17. 15 1月, 2016 2 次提交
  18. 12 1月, 2016 3 次提交
  19. 09 1月, 2016 2 次提交
  20. 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
  21. 31 12月, 2015 1 次提交
  22. 18 12月, 2015 1 次提交
  23. 15 12月, 2015 4 次提交
  24. 18 11月, 2015 1 次提交
    • S
      Rename 'key' to 'lock_id' or 'lock_name' for advisory locking · 5ce21d4f
      Sam Davies 提交于
      - key was a poor choice of name. A key implies something that will
        unlock a lock. The concept is actually more like a 'lock identifier'
      - mysql documentation calls this a 'lock name'
      - postgres documentation calls it a 'lock_id'
      - Updated variable names to reflect the preferred terminology for the database in
        question
      5ce21d4f
  25. 09 11月, 2015 1 次提交
    • Y
      Deprecate `#table_exists?`, `#tables` and passing arguments to `#talbes` · 7429633b
      yui-knk 提交于
      Reported on #21509, how views is treated by `#tables` are differ
      by each adapters. To fix this different behavior, after Rails 5.0
      is released, deprecate `#tables`.
      
      And `#table_exists?` would check both tables and views.
      To make their behavior consistent with `#tables`, after Rails 5.0
      is released, deprecate `#table_exists?`.
      7429633b
  26. 02 11月, 2015 1 次提交
    • Y
      Make `db:migrate:status` to render `1_some.rb` format migrate files. · a7beeb7f
      yui-knk 提交于
      `1_valid_people_have_last_names.rb` and
      `20150823202140_create_users.rb` are valid migration file name.
      But `1_valid_people_have_last_names.rb` is rendered as
      `********** NO FILE **********` when `rake db:migrate:status`.
      
      Fix to this bug, this commit includes
      
      * define some API private methdos and a Constant
        `match_to_migration_filename?`, `parse_migration_filename`, and
        `MigrationFilenameRegexp`
      * use these methods in `db:migrate:status` task
      
      Example:
      
      These files are in `db/migrate`
      
      * 1_valid_people_have_last_names.rb
      * 20150819202140_irreversible_migration.rb
      * 20150823202140_add_admin_flag_to_users.rb
      * 20150823202141_migration_tests.rb
      * 2_we_need_reminders.rb
      * 3_innocent_jointable.rb
      
      we can migrate all of them.
      
      Before
      
      ```shell
      $ bundle exec rake db:migrate:status
      
      ...
      
       Status   Migration ID    Migration Name
      --------------------------------------------------
         up     001             ********** NO FILE **********
         up     002             ********** NO FILE **********
         up     003             ********** NO FILE **********
         up     20150819202140  Irreversible migration
         up     20150823202140  Add admin flag to users
         up     20150823202141  Migration tests
      ```
      
      After
      
      ```shell
      $ bundle exec rake db:migrate:status
      
      ...
      
       Status   Migration ID    Migration Name
      --------------------------------------------------
         up     001             Valid people have last names
         up     002             We need reminders
         up     003             Innocent jointable
         up     20150819202140  Irreversible migration
         up     20150823202140  Add admin flag to users
         up     20150823202141  Migration tests
      ```
      a7beeb7f
  27. 31 10月, 2015 1 次提交
    • S
      Use advisory locks to prevent concurrent migrations · 2c2a8755
      Sam Davies 提交于
      - Addresses issue #22092
      - Works on Postgres and MySQL
      - Uses advisory locks because of two important properties:
        1. The can be obtained outside of the context of a transaction
        2. They are automatically released when the session ends, so if a
        migration process crashed for whatever reason the lock is not left
        open perpetually
      - Adds get_advisory_lock and release_advisory_lock methods to database
        adapters
      - Attempting to run a migration while another one is in process will
        raise a ConcurrentMigrationError instead of attempting to run in
        parallel with undefined behavior. This could be rescued and
        the migration could exit cleanly instead. Perhaps as a configuration
        option?
      
      Technical Notes
      ==============
      
      The Migrator uses generate_migrator_advisory_lock_key to build the key
      for the lock. In order to be compatible across multiple adapters there
      are some constraints on this key.
      - Postgres limits us to 64 bit signed integers
      - MySQL advisory locks are server-wide so we have to scope to the
        database
      - To fulfil these requirements we use a Migrator salt (a randomly
        chosen signed integer with max length of 31 bits) that identifies
        the Rails migration process as the owner of the lock. We multiply
        this salt with a CRC32 unsigned integer hash of the database name to
        get a signed 64 bit integer that can also be converted to a string
        to act as a lock key in MySQL databases.
      - It is important for subsequent versions of the Migrator to use the
        same salt, otherwise different versions of the Migrator will not see
        each other's locks.
      2c2a8755
  28. 02 10月, 2015 1 次提交
    • Y
      [ci skip] Fix comment · e889a226
      yui-knk 提交于
      `alias :migrations_path= :migrations_paths=`, so
      `migrations_path = some_string` is correct.
      e889a226