1. 17 10月, 2018 1 次提交
  2. 22 9月, 2018 1 次提交
    • M
      Index option added for change_table migrations · 5e4c22df
      Mehmet Emin INAC 提交于
      In case if we want to add a column into the existing table
      with index on it, we have to add column and index in two
      seperate lines.
      With this feature we don't need to write an extra line to
      add index for column. We can just use `index` option.
      
      Old behaviour in action:
      ```
        change_table(:languages) do |t|
          t.string :country_code
          t.index: :country_code
        end
      ```
      
      New behaviour in action:
      ```
        change_table(:languages) do |t|
          t.string :country_code, index: true
        end
      ```
      
      Exactly same behaviour is already exist for `create_table` migrations.
      5e4c22df
  3. 02 6月, 2018 1 次提交
  4. 15 5月, 2018 1 次提交
  5. 13 5月, 2018 1 次提交
  6. 22 3月, 2018 1 次提交
  7. 20 3月, 2018 1 次提交
    • D
      Expose foreign key name ignore pattern in configuration · d3fd4e4e
      David Stosik 提交于
      When dumping the database schema, Rails will dump foreign key names only
      if those names were not generate by Rails. Currently this is determined
      by checking if the foreign key name is `fk_rails_` followed by
      a 10-character hash.
      
      At [Cookpad](https://github.com/cookpad), we use
      [Departure](https://github.com/departurerb/departure) (Percona's
      pt-online-schema-change runner for ActiveRecord migrations) to run migrations.
      Often, `pt-osc` will make a copy of a table in order to run a long migration
      without blocking it. In this copy process, foreign keys are copied too,
      but [their name is prefixed with an underscore to prevent name collision
      ](https://www.percona.com/doc/percona-toolkit/LATEST/pt-online-schema-change.html#cmdoption-pt-online-schema-change-alter-foreign-keys-method).
      
      In the process described above, we often end up with a development
      database that contains foreign keys which name starts with `_fk_rails_`.
      That name does not match the ignore pattern, so next time Rails dumps
      the database schema (eg. when running `rake db:migrate`), our
      `db/schema.rb` file ends up containing those unwanted foreign key names.
      This also produces an unwanted git diff that we'd prefer not to commit.
      
      In this PR, I'd like to suggest a way to expose the foreign key name
      ignore pattern to the Rails configuration, so that individual projects
      can decide on a different pattern of foreign keys that will not get
      their names dumped in `schema.rb`.
      d3fd4e4e
  8. 18 2月, 2018 1 次提交
  9. 03 12月, 2017 2 次提交
  10. 01 12月, 2017 1 次提交
  11. 30 11月, 2017 1 次提交
    • G
      Add support for PostgreSQL operator classes to add_index · 1dca75c2
      Greg Navis 提交于
      Add support for specifying non-default operator classes in PostgreSQL
      indexes. An example CREATE INDEX query that becomes possible is:
      
          CREATE INDEX users_name ON users USING gist (name gist_trgm_ops);
      
      Previously it was possible to specify the `gist` index but not the
      custom operator class. The `add_index` call for the above query is:
      
          add_index :users, :name, using: :gist, opclasses: {name: :gist_trgm_ops}
      1dca75c2
  12. 25 9月, 2017 1 次提交
  13. 23 9月, 2017 1 次提交
  14. 01 9月, 2017 1 次提交
  15. 20 7月, 2017 1 次提交
  16. 02 7月, 2017 1 次提交
  17. 01 7月, 2017 1 次提交
  18. 19 5月, 2017 1 次提交
  19. 17 4月, 2017 1 次提交
  20. 16 4月, 2017 1 次提交
  21. 04 3月, 2017 1 次提交
    • R
      Don't share `options` with a reference type column · 465357ae
      Ryuta Kamizono 提交于
      Sharing `options` causes some unexpected behavior. If `limit: 2` is
      specified, this means that 2 bytes integer for a reference id column and
      2 chars string for a reference type column. Another example, if
      `unsigned: true` is specified, this means that unsigned integer for a
      reference id column, but a invalid option for a reference type column.
      So `options` should not be shared with a reference type column.
      465357ae
  22. 09 2月, 2017 1 次提交
  23. 07 2月, 2017 1 次提交
  24. 02 2月, 2017 1 次提交
  25. 13 1月, 2017 1 次提交
  26. 23 12月, 2016 1 次提交
  27. 06 12月, 2016 1 次提交
  28. 20 10月, 2016 1 次提交
  29. 18 8月, 2016 1 次提交
    • T
      Added nil case handling to allow rollback migration in case of · 906ff07e
      travis.h.oneill@gmail.com 提交于
      invalid column type
          /activerecord/lib/active_record/connection_adapters
          /abstract/schema_definitions.rb:306
          type = type.to_sym
      
      Changed to the following to handle nil case:
          type = type.to_sym if type
      
      Added regression test for this case:
        /activerecord/test/cases/migration_test.rb:554
        if current_adapter?(:SQLite3Adapter)
          def test_allows_sqlite3_rollback_on_invalid_column_type
            Person.connection.create_table :something, force: true do |t|
              t.column :number, :integer
              t.column :name, :string
              t.column :foo, :bar
            end
            assert Person.connection.column_exists?(:something, :foo)
            assert_nothing_raised { Person.connection.remove_column :something, :foo, :bar }
            assert !Person.connection.column_exists?(:something, :foo)
            assert Person.connection.column_exists?(:something, :name)
            assert Person.connection.column_exists?(:something, :number)
          ensure
            Person.connection.drop_table :something, if_exists: true
          end
        end
      906ff07e
  30. 14 8月, 2016 1 次提交
  31. 07 8月, 2016 3 次提交
  32. 02 8月, 2016 1 次提交
  33. 02 6月, 2016 1 次提交
    • S
      Fix failing tests · 1b8a7b82
      Sean Griffin 提交于
      Currently CI is broken due to 56a61e0c and c4cb6862. This occurred because
      the failures are not present on SQLite which is what I normally run
      locally before pushing.
      
      The optimizations to our YAML size were dropping mutations, as
      `with_type` didn't set the previous value if it'd already been read
      (that method was never really designed to be used with values on
      individual objects, it was previously only used for defaults). I'm
      questioning whether there's a better place to be handling the exclusion
      of the type, but this will fix the failing build.
      
      Additionally, there was a bug in `remove_foreign_key` if you passed it
      an options hash containing `to_table`. This now occurs whenever removing
      a reference, as we always normalize to a hash.
      
      [Sean Griffin & Ryuta Kamizono]
      1b8a7b82
  34. 19 4月, 2016 2 次提交
  35. 16 4月, 2016 1 次提交
  36. 16 2月, 2016 1 次提交
    • G
      Let t.foreign_key use the same `to_table` twice · aedde2a3
      George Millo 提交于
      Previously if you used `t.foreign_key` twice within the same
      `create_table` block using the same `to_table`, all statements except
      the final one would fail silently. For example, the following code:
      
          def change
            create_table :flights do |t|
              t.integer :from_id, index: true, null: false
              t.integer :to_id,   index: true, null: false
      
              t.foreign_key :airports, column: :from_id
              t.foreign_key :airports, column: :to_id
            end
          end
      
      Would only create one foreign key, on the column `from_id`.
      
      This commit allows multiple foreign keys to the same table to be created
      within one `create_table` block.
      aedde2a3