1. 20 5月, 2015 1 次提交
  2. 18 5月, 2015 1 次提交
    • Y
      better `add_reference` documentation. [ci skip] · 41e5e898
      Yves Senn 提交于
      This patch
        - reduces the duplication among the `reference`-family methods.
        - better explains all the optians available for `add_reference`.
        - redirects to user from `references` to `add_reference`.
      
      Originated by #20184.
      41e5e898
  3. 15 5月, 2015 1 次提交
  4. 04 5月, 2015 2 次提交
  5. 03 5月, 2015 1 次提交
  6. 15 4月, 2015 1 次提交
    • P
      Fix missing index when using timestamps with index · c0abeadc
      Paul Mucur 提交于
      The `index` option used with `timestamps` should be passed to both
      `column` definitions for `created_at` and `updated_at` rather than just
      the first.
      
      This was happening because `Hash#delete` is used to extract the `index`
      option passed to `timestamps`, thereby mutating the `options` hash
      in-place. Now take a copy of the `options` before deleting so that the
      original is not modified.
      c0abeadc
  7. 06 4月, 2015 1 次提交
  8. 03 3月, 2015 1 次提交
  9. 02 3月, 2015 1 次提交
  10. 23 2月, 2015 1 次提交
  11. 22 2月, 2015 1 次提交
  12. 11 2月, 2015 1 次提交
  13. 30 1月, 2015 1 次提交
  14. 24 1月, 2015 1 次提交
  15. 04 1月, 2015 1 次提交
  16. 03 1月, 2015 1 次提交
  17. 29 12月, 2014 1 次提交
  18. 28 12月, 2014 2 次提交
  19. 24 12月, 2014 1 次提交
    • S
      Refactor a common class to reduce the duplication for `references` · d26704a1
      Sean Griffin 提交于
      The code for `TableDefinition#references` and
      `SchemaStatements#add_reference` were almost identical both
      structurally, and in terms of domain knowledge. This removes that
      duplication into a common class, using the `Table` API as the expected
      interface of its collaborator.
      d26704a1
  20. 23 12月, 2014 3 次提交
    • S
      Add `foreign_key` as an option to `references` for `change_table` · 82afeaf2
      Sean Griffin 提交于
      This has the same comments as 9af90ffa00ba35bdee888e3e1ab775ba0bdbe72c,
      however it affects the `add_reference` method, and `t.references` in the
      context of a `change_table` block.
      
      There is a lot of duplication of code between creating and updating
      tables. We should re-evaluate the structure of this code from a high
      level so changes like this don't need to be made in two places. (Note to
      self)
      82afeaf2
    • S
      Add a `foreign_key` option to `references` while creating the table · 99a6f9e6
      Sean Griffin 提交于
      Rather than having to do:
      
          create_table :posts do |t|
            t.references :user
          end
      
          add_foreign_key :posts, :users
      
      You can instead do:
      
          create_table :posts do |t|
            t.references :user, foreign_key: true
          end
      
      Similar to the `index` option, you can also pass a hash. This will be
      passed as the options to `add_foreign_key`. e.g.:
      
          create_table :posts do |t|
            t.references :user, foreign_key: { primary_key: :other_id }
          end
      
      is equivalent to
      
          create_table :posts do |t|
            t.references :user
          end
      
          add_foreign_key :posts, :users, primary_key: :other_id
      99a6f9e6
    • S
      Convert `references` to kwargs · a9c0c462
      Sean Griffin 提交于
      While we aren't taking PRs with these kinds of changes just yet, they
      are fine if we're actively working on the method and it makes things
      easier.
      a9c0c462
  21. 04 12月, 2014 1 次提交
    • N
      Failure to rollback t.timestamps when within a change_table migration · b64fb302
      noam 提交于
      When running the following migration:
      
          change_table(:table_name) { |t| t/timestamps }
      
      The following error was produced:
      
          wrong number of arguments (2 for 1) .... /connection_adapters/abstract/schema_statements.rb:851:in `remove_timestamps'
      
      This is due to `arguments` containing an empty hash as its second
      argument.
      b64fb302
  22. 20 11月, 2014 1 次提交
    • Y
      synchronize code and docs for `timestamps` and `add_timestamps`. · d56be864
      Yves Senn 提交于
      This makes the following changes:
        * warn if `:null` is not passed to `add_timestamps`
        * `timestamps` method docs link to `add_timestamps` docs
        * explain where additional options go
        * adjust examples to include `null: false` (to prevent deprecation warnings)
      d56be864
  23. 11 11月, 2014 1 次提交
  24. 07 11月, 2014 1 次提交
  25. 29 10月, 2014 2 次提交
    • X
      edit pass over all warnings · e595d91a
      Xavier Noria 提交于
      This patch uniformizes warning messages. I used the most common style
      already present in the code base:
      
      * Capitalize the first word.
      
      * End the message with a full stop.
      
      * "Rails 5" instead of "Rails 5.0".
      
      * Backticks for method names and inline code.
      
      Also, converted a few long strings into the new heredoc convention.
      e595d91a
    • X
      let's warn with heredocs · b3bfa361
      Xavier Noria 提交于
      The current style for warning messages without newlines uses
      concatenation of string literals with manual trailing spaces
      where needed.
      
      Heredocs have better readability, and with `squish` we can still
      produce a single line.
      
      This is a similar use case to the one that motivated defining
      `strip_heredoc`, heredocs are super clean.
      b3bfa361
  26. 25 10月, 2014 1 次提交
    • D
      Use type column first in multi-column indexes · 9cdd0a1f
      Derek Prior 提交于
      `add_reference` can very helpfully add a multi-column index when you use
      it to add a polymorphic reference. However, the first column in the
      index is the `id` column, which is less than ideal.
      
      The [PostgreSQL docs][1] say:
      > A multicolumn B-tree index can be used with query conditions that
      > involve any subset of the index's columns, but the index is most
      > efficient when there are constraints on the leading (leftmost)
      > columns.
      
      The [MySQL docs][2] say:
      > MySQL can use multiple-column indexes for queries that test all the
      > columns in the index, or queries that test just the first column, the
      > first two columns, the first three columns, and so on. If you specify
      > the columns in the right order in the index definition, a single
      > composite index can speed up several kinds of queries on the same
      > table.
      
      In a polymorphic relationship, the type column is much more likely to be
      useful as the first column in an index than the id column. That is, I'm
      more likely to query on type without an id than I am to query on id
      without a type.
      
      [1]: http://www.postgresql.org/docs/9.3/static/indexes-multicolumn.html
      [2]: http://dev.mysql.com/doc/refman/5.0/en/multiple-column-indexes.html
      9cdd0a1f
  27. 16 10月, 2014 3 次提交
  28. 03 9月, 2014 1 次提交
  29. 02 9月, 2014 1 次提交
  30. 29 8月, 2014 1 次提交
    • G
      Avoid using heredoc for user warnings · 8c52480b
      Godfrey Chan 提交于
      Using heredoc would enforce line wrapping to whatever column width we decided to
      use in the code, making it difficult for the users to read on some consoles.
      
      This does make the source code read slightly worse and a bit more error-prone,
      but this seems like a fair price to pay since the primary purpose for these
      messages are for the users to read and the code will not stick around for too
      long.
      8c52480b
  31. 20 8月, 2014 1 次提交
  32. 13 8月, 2014 1 次提交
    • S
      Change the default `null` value for timestamps · ea3ba345
      Sean Griffin 提交于
      As per discussion, this changes the model generators to specify
      `null: false` for timestamp columns. A warning is now emitted if
      `timestamps` is called without a `null` option specified, so we can
      safely change the behavior when no option is specified in Rails 5.
      ea3ba345
  33. 22 7月, 2014 1 次提交