1. 24 4月, 2018 1 次提交
    • D
      Update schema.rb documentation [CI SKIP] · 84718df8
      Derek Prior 提交于
      The documentation previously claimed that `db/schema.rb` was "the
      authoritative source for your database schema" while simultaneously
      also acknowledging that the file is generated. These two statements are
      incongruous and the guides accurately call out that many database
      constructs are unsupported by `schema.rb`. This change updates the
      comment at the top of `schema.rb` to remove the assertion that the file
      is authoritative.
      
      The documentation also previously referred vaguely to "issues" when
      re-running old migrations. This has been updated slightly to hint at the
      types of problems that one can encounter with old migrations.
      
      In sum, this change attempts to more accurately capture the pros, cons,
      and shortcomings of the two schema formats in the guides and in the
      comment at the top of `schema.rb`.
      
      [Derek Prior & Sean Griffin]
      Co-authored-by: NSean Griffin <sean@seantheprogrammer.com>
      84718df8
  2. 02 4月, 2018 1 次提交
  3. 22 3月, 2018 1 次提交
  4. 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
  5. 18 1月, 2018 1 次提交
    • E
      Refactor migration to move migrations paths to connection · a2827ec9
      eileencodes 提交于
      Rails has some support for multiple databases but it can be hard to
      handle migrations with those. The easiest way to implement multiple
      databases is to contain migrations into their own folder ("db/migrate"
      for the primary db and "db/seconddb_migrate" for the second db). Without
      this you would need to write code that allowed you to switch connections
      in migrations. I can tell you from experience that is not a fun way to
      implement multiple databases.
      
      This refactoring is a pre-requisite for implementing other features
      related to parallel testing and improved handling for multiple
      databases.
      
      The refactoring here moves the class methods from the `Migrator` class
      into it's own new class `MigrationContext`. The goal was to move the
      `migrations_paths` method off of the `Migrator` class and onto the
      connection. This allows users to do the following in their
      `database.yml`:
      
      ```
      development:
        adapter: mysql2
        username: root
        password:
      
      development_seconddb:
        adapter: mysql2
        username: root
        password:
        migrations_paths: "db/second_db_migrate"
      ```
      
      Migrations for the `seconddb` can now be store in the
      `db/second_db_migrate` directory. Migrations for the primary database
      are stored in `db/migrate`".
      
      The refactoring here drastically reduces the internal API for migrations
      since we don't need to pass `migrations_paths` around to every single
      method. Additionally this change does not require any Rails applications
      to make changes unless they want to use the new public API. All of the
      class methods from the `Migrator` class were `nodoc`'d except for the
      `migrations_paths` and `migrations_path` getter/setters respectively.
      a2827ec9
  6. 03 12月, 2017 1 次提交
  7. 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
  8. 25 10月, 2017 1 次提交
    • Y
      Implement `PostgreSQL::SchemaDumper#extensions` · cf4ba2fa
      Yasuo Honda 提交于
      and abstract `SchemaDumper#extensions` is now an empty method.
      
      Since #30337, every database adapter has its own `SchemaDumper`.
      `extensions` are only supported by PostgreSQL database and postgresql database adapter.
      cf4ba2fa
  9. 27 8月, 2017 1 次提交
  10. 24 8月, 2017 1 次提交
  11. 22 8月, 2017 1 次提交
  12. 05 8月, 2017 1 次提交
    • Y
      Allow `table_name_prefix` and `table_name_suffix` have `$` · b49c6dce
      Yasuo Honda 提交于
      MySQL 5.7 and PostgreSQL 9.6 allow table identifiers have the dollar sign.
      
      * MySQL 5.7
      https://dev.mysql.com/doc/refman/5.7/en/identifiers.html
      
      > Permitted characters in unquoted identifiers:
      >  ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore)
      
      * PostgreSQL 9.6
      https://www.postgresql.org/docs/9.6/static/sql-syntax-lexical.html
      
      > SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($). Note that dollar signs are not allowed in identifiers according to the letter of the SQL standard, so their use might render applications less portable. The SQL standard will not define a key word that contains digits or starts or ends with an underscore, so identifiers of this form are safe against possible conflict with future extensions of the standard.
      
      Address #30044
      
      [Yasuo Honda & Ryuta Kamizono]
      b49c6dce
  13. 20 7月, 2017 1 次提交
  14. 13 7月, 2017 1 次提交
    • J
      Sort enabled adapter extensions in schema dump · 8dca9219
      Jan Pieper 提交于
      The list of enabled adapter extensions in the schema dump isn't
      sorted by default, so it may happen that the sorting changes
      over time. If you're using a VCS, a change to the sorting results
      in a diff without any real change. Sorting the list should solve
      this problem.
      8dca9219
  15. 02 7月, 2017 1 次提交
  16. 01 7月, 2017 1 次提交
  17. 03 6月, 2017 1 次提交
  18. 16 5月, 2017 1 次提交
  19. 09 4月, 2017 1 次提交
    • R
      Tweaks #28678 · 1d05e64b
      Ryuta Kamizono 提交于
      * Fix the comment on `formatted_version`
      * Extract `define_params`
      * Remove duplicated guard clause for `@version`
      1d05e64b
  20. 06 4月, 2017 1 次提交
  21. 28 2月, 2017 1 次提交
  22. 14 2月, 2017 1 次提交
  23. 13 2月, 2017 1 次提交
  24. 29 10月, 2016 1 次提交
  25. 11 10月, 2016 2 次提交
  26. 10 10月, 2016 2 次提交
    • R
      `name` is not a column option · 24a1a6a8
      Ryuta Kamizono 提交于
      `migration_keys` includes `name` but `name` is not a column option.
      24a1a6a8
    • R
      Dump index options to pretty format · 5025fd3a
      Ryuta Kamizono 提交于
      ```ruby
        # Before
        t.index ["firm_id", "type", "rating"], name: "company_index", order: {"rating"=>:desc}, using: :btree
      
        # After
        t.index ["firm_id", "type", "rating"], name: "company_index", order: { rating: :desc }, using: :btree
      ```
      5025fd3a
  27. 08 10月, 2016 1 次提交
  28. 23 8月, 2016 2 次提交
  29. 17 8月, 2016 1 次提交
  30. 16 8月, 2016 1 次提交
  31. 07 8月, 2016 1 次提交
  32. 02 7月, 2016 1 次提交
  33. 10 6月, 2016 1 次提交
  34. 12 5月, 2016 1 次提交
  35. 20 4月, 2016 2 次提交
  36. 19 4月, 2016 1 次提交