1. 31 12月, 2015 1 次提交
  2. 18 12月, 2015 1 次提交
  3. 15 12月, 2015 4 次提交
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 28 9月, 2015 1 次提交
  10. 09 9月, 2015 2 次提交
  11. 07 9月, 2015 1 次提交
  12. 29 8月, 2015 1 次提交
  13. 24 8月, 2015 2 次提交
  14. 23 8月, 2015 2 次提交
  15. 21 8月, 2015 1 次提交
  16. 18 8月, 2015 1 次提交
  17. 07 8月, 2015 1 次提交
  18. 23 7月, 2015 1 次提交
  19. 25 6月, 2015 1 次提交
  20. 14 6月, 2015 1 次提交
  21. 22 5月, 2015 1 次提交
  22. 12 5月, 2015 1 次提交
  23. 11 5月, 2015 1 次提交
  24. 24 2月, 2015 1 次提交
  25. 19 2月, 2015 1 次提交
  26. 02 1月, 2015 1 次提交
  27. 29 11月, 2014 1 次提交
  28. 26 11月, 2014 1 次提交
    • Y
      bring back `db:test:prepare`. · 5c449553
      Yves Senn 提交于
      This reverts deprecations added in #13528.
      The task is brought back for two reasons:
        1. Give plugins a way to hook into the test database initialization process
        2. Give the user a way to force a test database synchronization
      
      While `test:prepare` is still a dependency of every test task, `db:test:prepare`
      no longer hooks into it. This means that `test:prepare` runs before the schema
      is synchronized. Plugins, which insert data can now hook into `db:test:prepare`.
      
      The automatic schema maintenance can't detect when a migration is rolled-back,
      modified and reapplied. In this case the user has to fall back to `db:test:prepare`
      to force the synchronization to happen.
      5c449553
  29. 24 11月, 2014 1 次提交
  30. 01 11月, 2014 2 次提交
  31. 21 8月, 2014 2 次提交
  32. 14 8月, 2014 1 次提交
    • J
      Correctly determine if migration is needed. · 838e1832
      Jeremy McNevin 提交于
      This method would assume that if last migration in the migrations
      directory matched the current schema version, that the database was up
      to date, but this does not account for new migrations with older
      timestamps that may be pending.
      838e1832