| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
|
|\
| |
| |
| | |
Enforce frozen string in Rubocop
|
| | |
|
|\ \
| | |
| | |
| | | |
Make ActiveSupport frozen-string-literal friendly.
|
| | | |
|
| |/
|/|
| |
| |
| |
| | |
`test_middleware_caches` is sometimes failed since #29454.
The failure is due to schema statements are affected by query caching.
Bypassing query caching for schema statements to avoid the issue.
|
|/
|
|
|
|
| |
Because identifiers in SQL could include a single quote.
Related #24950, #26784.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Another fix for #28780 based on discussions at #28789
- In PostgreSQL 10 each sequence does not know its `min_value`.
A new system catalog `pg_sequence` shows it as `seqmin`.
Refer https://github.com/postgres/postgres/commit/1753b1b027035029c2a2a1649065762fafbf63f3
- `setval` 3rd argument needs to set to `false` only when the table has no rows
to avoid `nextval(<sequence_name>)` returns `2` where `1` is expected.
- `min_value` is only necessary when the table has no rows. It used to be necessary
since the 3rd argument of `setval` is always `false`.
|
|
|
|
|
|
|
|
|
|
| |
Formerly, `rename_table` only renamed primary key index name if the
column's data type was sequential (serial, etc in PostgreSQL). The
problem with that is tables whose primary keys had other data types
(e.g. UUID) maintained the old primary key name. So for example,
if the `cats` table has a UUID primary key, and the table is renamed to
`felines`, the primary key index will still be called `cats_pkey`
instead of `felines_pkey`. This PR corrects it.
|
| |
|
|
|
|
|
|
|
| |
* Use keyword arguments in `IndexDefinition` to ease to ignore unused
options and to avoid to initialize incorrect empty value.
* Place it in `SchemaStatements` for consistency.
* And tiny tweaks.
|
|
|
|
|
|
| |
Also, explicitly apply the order: generate_subscripts is unlikely to
start returning values out of order, but we should still be clear about
what we want.
|
|\
| |
| | |
Fix `primary_keys` across multiple schemas
|
| |
| |
| |
| | |
Fixes #28470.
|
|/ |
|
|\
| |
| | |
Extract `data_source_sql` to refactor data source statements
|
| | |
|
| | |
|
| |
| |
| |
| |
| | |
Actually `index_name_length` depend on `max_identifier_length`, not
always 63.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently `change_column` cannot drop default if `null: false` is
specified at the same time. This change fixes the issue.
```ruby
# cannot drop default
change_column "tests", "contributor", :boolean, default: nil, null: false
# we need the following workaround currently
change_column "tests", "contributor", :boolean, null: false
change_column "tests", "contributor", :boolean, default: nil
```
Closes #26582
|
|
|
|
|
|
| |
Fixes CI failure caused by #27961.
https://travis-ci.org/rails/rails/jobs/201472146#L2390-L2409
|
|
|
|
|
|
|
|
|
|
|
|
| |
primary_keys(table) needs to query various metadata tables in Postgres
to determine the primary key for the table. Previously, it did so using
a complex common table expression against pg_constraint and
pg_attribute.
This patch simplifies the query by using information_schema tables.
This simplifies the logic, making the query far easier to understand,
and additionally avoids an expensive unnest, window function query, and
common table expression.
|
| |
|
|
|
|
|
|
| |
The `default` arg of `index_name_exists?` is only used the adapter does
not implemented `indexes`. But currently all adapters implemented
`indexes` (See #26688). Therefore the `default` arg is never used.
|
|
|
|
| |
This reverts commit d6529af2954a67bd57fda45286fa9cfd0ff6b5ac.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
primary_keys(table) needs to query various metadata tables in Postgres to
determine the primary key for the table. Previously, it did so using a
complex common table expression against pg_constraint and pg_attribute.
This patch simplifies the query by joining pg_index against pg_attribute
instead of going through pg_constraint. This avoids an expensive unnest,
window function query, and common table expression.
EXPLAINing these queries in Postgres against a database with a single
table with a composite primary key shows a 66% reduction in the plan and
execute latencies. This is significant during application startup time,
especially against very large schemas, where these queries would be even
slower and more numerous.
Closes #27949
|
|
|
|
|
|
| |
Column options are passed as an hash args then used as `options` hash in
`add_column_options!`. Converting args to attributes is inconvinient for
using options as an hash.
|
|
|
|
|
| |
Passing `name` to `tables` is already deprecated at #21601.
Passing `name` to `indexes` is also unused.
|
| |
|
| |
|
|
|
|
| |
that accepts results of SHOW FIELDS
|
|
|
|
| |
If does not quote table name properly, invalid SQL is generated.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Follow up to #26735.
If `table_options` returns `{ comment: nil }`, `create_table` line is
broken.
Example:
```ruby
create_table "accounts", force: :cascade, do |t|
```
|
|
|
|
|
|
|
|
|
| |
Recently, the Rails team made an effort to keep the source code consistent, using Ruboco
(bb1ecdcc677bf6e68e0252505509c089619b5b90 and below). Some of the case
statements were missed.
This changes the case statements' formatting and is consistent with changes
in 810dff7c9fa9b2a38eb1560ce0378d760529ee6b and db63406cb007ab3756d2a96d2e0b5d4e777f8231.
|
| |
|
|
|
|
|
|
|
|
| |
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces
Fix all violations in the repository.
|
| |
|
| |
|
|
|
|
|
| |
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
|
|\
| |
| | |
Prevent `table_comment` query if a table doesn't have a comment
|
| | |
|
| |
| |
| |
| | |
`ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements#default_sequence_name`
|
|\ \
| | |
| | |
| | |
| | | |
kamipo/extract_foreign_key_action_from_information_schema
Extract foreign key action from `information_schema`
|
| |/ |
|
|/
|
|
| |
Fixes #25391
|
|
|
|
|
|
| |
Follow up of 1683410.
Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Example:
create_table :users do |t|
t.string :name
t.index 'lower(name) varchar_pattern_ops'
end
Fixes #19090.
Fixes #21765.
Fixes #21819.
Fixes #24359.
Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
|
|
|
|
| |
Follow up to 1683410.
|
|
|
|
|
|
| |
* Switch to keyword args where we can without breaking compat.
* Use add_table_options! for :options, too.
* Some code polish.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Comments are specified in migrations, stored in database itself (in its schema),
and dumped into db/schema.rb file.
This allows to generate good documentation and explain columns and tables' purpose
to everyone from new developers to database administrators.
For PostgreSQL and MySQL only. SQLite does not support comments at the moment.
See docs for PostgreSQL: http://www.postgresql.org/docs/current/static/sql-comment.html
See docs for MySQL: http://dev.mysql.com/doc/refman/5.7/en/create-table.html
|