| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|\
| |
| |
| | |
Remove dormant check
|
| |
| |
| |
| |
| | |
This check was introduced in 6edaa26 and moved through multiple refactorings.
No test are broken after removal and AFAICS there is no way to trigger it.
|
| |
| |
| |
| | |
Follow up of #31177.
|
| |
| |
| |
| |
| | |
Actually SQLite3 doesn't have JSON storage class (so it is stored as a
TEXT like Date and Time). But emulating JSON types is convinient for
making database agnostic migrations.
|
| |
| |
| |
| |
| |
| |
| | |
`options_for_index_columns`
And placed `add_options_for_index_columns` in `schema_statements.rb`
consistently to ease to find related code.
|
| | |
|
|\ \
| | |
| | | |
Extract sql fragment generators from PostgreSQL adapter
|
| | | |
|
| | |
| | |
| | |
| | | |
Add validate_constraint and update naming
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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}
|
|\ \ \
| |/ /
|/| | |
Flush idle database connections
|
| | | |
|
|\ \ \
| |/ /
|/| | |
Improve AR connection fork safety
|
| | |
| | |
| | |
| | |
| | |
| | | |
Use whatever adapter-provided means we have available to ensure forked
children don't send quit/shutdown/goodbye messages to the server on
connections that belonged to their parent.
|
|\ \ \
| |/ /
|/| | |
Switch to LIFO for the connection pool
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Using a FIFO for the connection pool can lead to issues when there are
upstream components (pgbouncer, haproxy, etc.) that terminate
connections that are idle after a period of time. Switching to a LIFO
reduces the probability that a thread will checkout a connection that is
about to be closed by an idle timeout in an upstream component.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
```
[NoMethodError]: undefined method `state' for nil:NilClass Method:[rescue in block in refresh]
```
In `within_new_transaction`, there is the possibility that
`begin_transaction` returns a `nil`. (i.e.: so `transaction = nil`)
So this method is checking `transaction` for nil in 2 spots.
Unfortunately, there is one line that is not checking `transaction` for `nil`
That line, `commit_transaction`, throws an exception for us in AR 5.0.0.1
The problem with the method is finally realized in the error checking itself.
it calls `transaction.state` (i.e.: nil.state) and that is the final exception
raised.
The actual underlying (user) issue is hidden by this line.
Solution is test transaction for nil.
|
| | |
| | |
| | |
| | |
| | |
| | | |
Replace the primary key type `integer` in docs with `bigint`.
ref #26266
|
| | | |
|
| | |
| | |
| | |
| | | |
`initialize_internal_metadata_table`
|
| | | |
|
| | |
| | |
| | |
| | | |
object
|
| | |
| | |
| | |
| | | |
This basically reverts 9d4f79d3d394edb74fa2192e5d9ad7b09ce50c6d
|
| | |
| | |
| | |
| | |
| | | |
Implemented by #22911
Related to #30677
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
I got this error in production using Puma in multi-threaded mode:
```
RuntimeError: Digest::Base cannot be directly inherited in Ruby
from active_support/security_utils.rb:23:in `variable_size_secure_compare'
from active_support/security_utils.rb:23:in `hexdigest'
from active_support/security_utils.rb:23:in `digest'
```
Looks like Digest uses const_missing to load Digest::SHA256 (https://github.com/ruby/ruby/blob/trunk/ext/digest/lib/digest.rb#L8)
- https://bugs.ruby-lang.org/issues/9494
- https://github.com/ruby/ruby/commit/c02fa39463a0c6bf698b01bc610135604aca2ff4
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | | |
Currently the normalization only exists in `primary_key` shorthand. It
should be moved to `new_column_definition` to also affect to
`add_column` with primary key.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Otherwise using reserved words as composite primary key names will be
failed as an invalid SQL.
Fixes #30518.
|
| | |
| | |
| | |
| | |
| | |
| | | |
type columns
Fixes #30496.
|
| | |
| | |
| | |
| | | |
- Closes #30441
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Currently `SchemaDumper` is only customizable for column options. But
3rd party connection adapters (oracle-enhanced etc) need to customizable
for table or index dumping also. To make it possible, I introduced
adapter specific `SchemaDumper` classes for that.
|
| | | |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
This is only used for the internal `column_spec` and
`column_spec_for_primary_key`.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
(#29944)
Since 213796f, it was lost the ability that SQL with binds for `insert`,
`update`, and `delete` (like `select_all`). This restores the ability
because `insert`, `update`, and `delete` are public API, so it should
not be removed without deprecation.
|
| | |
| | |
| | |
| | | |
Because `to_sql` is public API. I introduced `to_sql_and_binds` internal
API to return SQL and binds.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
refs: https://github.com/rails/rails/pull/30161
```
$ echo "+@size+" | rdoc --pipe
<p>+@size+</p>
$ echo "<tt>@size</tt>" | rdoc --pipe
<p><code>@size</code></p>
```
[ci skip]
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Otherwise `ConnectionPool#reap` may run before `@connections` has
initialized.
https://travis-ci.org/rails/rails/jobs/263037427#L888-L890
|
|\ \ \
| | | |
| | | | |
Add missed `require`
|
| | | |
| | | |
| | | |
| | | |
| | | | |
`ActiveRecord::ConnectionAdapters::QueryCache::ConnectionPoolConfiguration`
depends on `Concurrent::Map`.
|
|/ / / |
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
It seems that it accepts only HTTPS connections.
Ref: https://github.com/postgres/postgres/commit/7f77cbd996855a06fb742ea11adbe55c42b48fe2
|
| | |
| | |
| | |
| | |
| | | |
The limit option is ignored by PostgreSQL and may be ignored by 3rd
party backends. Make this clear in the docs. Fixes #29922.
|