| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Follow up to #23508.
|
|\
| |
| | |
`schema_type` returns symbol rather than string
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
A return value of `schema_type` is used by:
1. primary key type: using as `symbol.inspect`
2. normal column type: using as `symbol.to_s`
It is better to return symbol.
|
|\ \
| |/
|/| |
Added numeric helper into `SchemaStatements` for MySQL and PostgreSQL
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
With this addition, you can add a column into the table like:
```
create_table(:numeric_types) do |t|
t.numeric :foo, precision: 10, scale: 2, default: 2.0
end
```
The result of the migration above is same with:
```
create_table(:numeric_types) do |t|
t.decimal :foo, precision: 10, scale: 2, default: 2.0
end
```
|
|/
|
|
| |
Fixes #22980.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If you set the DATABASE_URL environment variable to `mydatabase` by accident, you end up getting a series of errors that are hard to trace. For example:
```
warning: already initialized constant ActiveRecord::Base::OrmAdapter
```
Turns out the cascade of errors is due to the error raised by `.tr` being called on `nil`.
This commit makes sure that `scheme` is set before calling `.tr` on it. My previous iteration used `@uri.scheme.try(:tr, '-', '_')` but using the `&&` logical operator is a fair bit faster: http://stackoverflow.com/questions/26655032/try-vs-performance
With this change, the error message becomes much more understandable:
```
FATAL: database "mydatabase" does not exist (ActiveRecord::NoDatabaseError)
```
|
|\
| |
| |
| |
| | |
kamipo/innodb_supports_fulltext_and_spatial_indexes
InnoDB supports FULLTEXT and Spatial Indexes [ci skip]
|
| |
| |
| |
| |
| | |
https://dev.mysql.com/doc/refman/5.7/en/innodb-fulltext-index.html
https://dev.mysql.com/doc/refman/5.7/en/creating-spatial-indexes.html
|
|\ \
| | |
| | | |
Active Record supports MySQL >= 5.0
|
| |/
| |
| |
| |
| | |
Currently some features uses `information_schema` (e.g. foreign key
support). `information_schema` introduced since MySQL 5.0.
|
|/ |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a `before_commit` callback raises, the database is rolled back but
AR's record of the current transaction is not, leaving the connection in
a perpetually broken state that affects all future users of the
connection: subsequent requests, jobs, etc. They'll think a transaction
is active when none is, so they won't BEGIN on their own. This manifests
as missing `after_commit` callbacks and broken ROLLBACKs.
This happens because `before_commit` callbacks fire before the current
transaction is popped from the stack, but the exception-handling path
they hit assumes that the current transaction was already popped. So the
database ROLLBACK is issued, but the transaction stack is left intact.
Common cause: deadlocked `#touch`, which is now implemented with
`before_commit` callbacks.
What's next:
* We shouldn't allow active transaction state when checking in or out
from the connection pool. Verify that conns are clean.
* Closer review of txn manager sad paths. Are we missing other spots
where we'd end up with incorrect txn state? What's the worst that can
happen if txn state drifts? How can we guarantee it doesn't and
contain the fallout if it does?
Thanks for @tomafro for expert diagnosis!
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`initialize_schema_migrations_table` is called in every migrations.
https://github.com/rails/rails/blob/v5.0.0.beta1/activerecord/lib/active_record/migration.rb#L1080
https://github.com/rails/rails/blob/v5.0.0.beta1/activerecord/lib/active_record/schema.rb#L51
This means that extra `show variables` is called regardless of the
existence of `schema_migrations` table.
This change is to avoid extra `show variables` if `schema_migrations`
table exists.
|
| |
|
|
|
|
|
|
|
|
| |
p PostgreSQLAdapter::OID::Money.precision
# => 19
p PostgreSQLAdapter::OID::Money.new.precision
# => nil
|
|
|
|
|
|
|
| |
This reverts commit ff835f90800a3e4122d64606cb328908c2e0e071, reversing
changes made to c4d85dfbc71043e2a746acd310e32f4f04db801a.
Reason: This broke the tests. We will add back after investigated.
|
|\
| |
| |
| |
| | |
yui-knk/warning_when_composite_primary_key_is_detected
Warn if `AR.primary_key` is called for a table who has composite prim…
|
| |
| |
| |
| |
| |
| |
| |
| | |
If `AR.primary_key` is called for a table who has composite primary key,
the method returns `nil`. This behavior sometimes generates invalid SQL.
The first time developers notice to invalid SQL is when they execute
SQL. This commit enables developers to know they are doing something
dangerous as soon as possible.
|
|\ \
| | |
| | | |
Refactor `column_exists?` in `SchemaStatements`
|
| |/ |
|
|\ \
| | |
| | | |
Fix `bigint?` for Enum columns in MySQL
|
| |/
| |
| |
| | |
Follow up to #22896.
|
|\ \
| | |
| | |
| | |
| | | |
kamipo/remove_unused_lost_connection_error_messages
Remove unused `LOST_CONNECTION_ERROR_MESSAGES`
|
| |/
| |
| |
| |
| | |
`LOST_CONNECTION_ERROR_MESSAGES` was added by f384582.
But currently unused from anywhere.
|
|\ \
| | |
| | | |
Explicitly define `columns` method as an interface
|
| |/
| |
| |
| |
| |
| | |
`ActiveRecord::ConnectionAdapters::SchemaStatements#columns` is defined
here as an interface method here. So changes to raise `NotImplementedError`
same as `tables`, `views` ...etc.
|
|/ |
|
|\
| |
| | |
Remove `limit: 11` as backward-compatibility with Rails 2.0
|
| |
| |
| |
| |
| |
| |
| | |
Integer limit as a byte size was introduced from Rails 2.1.
`limit: 11` is not a byte size, but take care for backward-compatibility
with Rails 2.0 (a892af6). Integer limit out of range should be allowed
to raise by #6349. I think we should remove this backward-compatibility.
|
|\ \
| | |
| | | |
Clarify DatabaseStatements#execute docs re: memory usage.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This line causes an error when executing the command: `rails db:drop db:create db:schema:load`
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error at or near "{"
LINE 1: ...NSERT INTO "schema_migrations" (version) VALUES (#{v}), (#{v...
|
| |/
|/|
| |
| |
| |
| |
| | |
We found that inserting all 600 schema_migrations for our mid-sized app takes about a minute on a cloud based CI environment.
I assume that the original code did not use multi-row-insert because SQLite3 was not supporting the syntax back then,
but it's been supported since 3.7.11: http://www.sqlite.org/releaselog/3_7_11.html
|
|/
|
|
|
|
|
|
|
|
| |
- Using `references` or `belongs_to` in migrations will always add index
for the referenced column by default, without adding `index:true` option
to generated migration file.
- Users can opt out of this by passing `index: false`.
- Legacy migrations won't be affected by this change. They will continue
to run as they were before.
- Fixes #18146
|
|\
| |
| | |
Add `:expression` option support on the schema default
|
| | |
|
| |
| |
| |
| | |
The default 'now'::date is CURRENT_DATE.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Example:
create_table :posts do |t|
t.datetime :published_at, default: -> { 'NOW()' }
end
|
|\ \
| | |
| | |
| | |
| | | |
kamipo/sql_for_insert_returns_values_for_passing_to_exec_insert
`sql_for_insert` returns values for passing to `exec_insert`
|
| | | |
|
|/ /
| |
| |
| | |
These methods are private and unused from anywhere.
|
|/
|
|
| |
Arel handles substitution for bind parameters by now.
|
|
|
|
| |
Closes #22584.
|
|
|
|
| |
`connection_adapters/mysql/type_metadata.rb`
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is an alternate implementation to #22875, that generalizes a lot of
the logic that type decorators are going to need, in order to have them
work with arrays, ranges, etc. The types have the ability to map over a
value, with the default implementation being to just yield that given
value. Array and Range give more appropriate definitions.
This does not automatically make ranges time zone aware, as they need to
be added to the `time_zone_aware` types config, but we could certainly
make that change if we feel it is appropriate. I do think this would be
a breaking change however, and should at least have a deprecation cycle.
Closes #22875.
/cc @matthewd
|
|\
| |
| | |
Prevent destructive action on production database
|