aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/internal_metadata.rb
Commit message (Collapse)AuthorAgeFilesLines
* Remove duplicated `table_exists?`Ryuta Kamizono2019-06-131-4/+0
| | | | | | `table_exists?` is already exist in `ModelSchema`. https://github.com/rails/rails/blob/5cab344494c340ea82a35b46efa06b94f0b7730b/activerecord/lib/active_record/model_schema.rb#L339-L341
* Respect table name prefix/suffix for `truncate_all`Ryuta Kamizono2019-04-041-1/+5
|
* Only define attribute methods from schema cacheEugene Kenny2018-09-281-0/+4
| | | | | | | | | | | | | To define the attribute methods for a model, Active Record needs to know the schema of the underlying table, which is usually achieved by making a request to the database. This is undesirable behaviour while the app is booting, for two reasons: it makes the boot process dependent on the availability of the database, and it means every new process will make one query for each table, which can cause issues for large applications. However, if the application is using the schema cache dump feature, then the schema cache already contains the necessary information, and we can define the attribute methods without causing any extra database queries.
* Deprecate update_attributes and update_attributes!Eddie Lebow2018-02-171-1/+1
| | | | Closes #31998
* [Active Record] require => require_relativeAkira Matsuda2017-10-211-2/+2
| | | | This basically reverts 9d4f79d3d394edb74fa2192e5d9ad7b09ce50c6d
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* [Active Record] require => require_relativeAkira Matsuda2017-07-011-2/+2
|
* `#tables` and `#table_exists?` and returns only tables and not viewsRafael Mendonça França2016-12-291-1/+1
|
* applies new string literal convention in activerecord/libXavier Noria2016-08-061-2/+2
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Revert "Rename `active_record_internal_metadatas` to `ar_internal_metadata`"Yasuo Honda2016-07-011-13/+0
| | | | This reverts commit 407e0ab5e5cddf6a8b6b278b12f50772d13b4d86.
* update record specified in keyyuuji.yaginuma2016-04-271-1/+1
| | | | | | `#first_or_initialize` does not use attributes to data acquisition. Therefore, there is a possibility of updating the different record than the one specified in the key, I think this is not expected behavior.
* Rename `active_record_internal_metadatas` to `ar_internal_metadata`Yasuo Honda2016-02-011-0/+13
| | | | for those who already migrated to Rails 5.0.0 beta
* Avoid extra `show variables` in migrationRyuta Kamizono2016-02-011-5/+3
| | | | | | | | | | | | | `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.
* Make to primary key instead of an unique index for internal tablesRyuta Kamizono2016-01-311-8/+2
|
* [close #23009] Limit key lengthschneems2016-01-211-2/+7
| | | | | | | Mysql has a weird bug where it cannot index a string column of utf8mb4 if it is over a certain character limit. To get compatibility with msql we can add a limit to the key column. 191 characters is a very long key, it seems reasonable to limit across all adapters since using a longer key wouldn't be supported in mysql. Thanks to @kamipo for the original PR and the test refactoring. Conversation: https://github.com/rails/rails/pull/23009#issuecomment-171416629
* Clean up internal metadata definitionRyuta Kamizono2016-01-151-3/+2
| | | | | | | | | | | | | | Use `t.index` in `create_table` instead of `add_index` It is slightly more efficient. Revert "Use `key` as primary key in schema." This reverts commit 350ae6cdc1ea83e21c23abd10e7e99c9a0bbdbd2. `:primary_key` option does nothing if `id: false`. https://github.com/rails/rails/blob/v5.0.0.beta1/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb#L251-L261
* [ci skip] fix typoAkshay Vishnoi2016-01-101-1/+1
|
* Use hash like syntax for InternalMetadataschneems2016-01-081-6/+4
| | | | Discussion: https://github.com/rails/rails/pull/22967#discussion_r49137035
* Use `key` as primary key in schema.schneems2016-01-081-1/+1
|
* Prevent destructive action on production databaseschneems2016-01-071-0/+49
This PR introduces a key/value type store to Active Record that can be used for storing internal values. It is an alternative implementation to #21237 cc @sgrif @matthewd. It is possible to run your tests against your production database by accident right now. While infrequently, but as an anecdotal data point, Heroku receives a non-trivial number of requests for a database restore due to this happening. In these cases the loss can be large. To prevent against running tests against production we can store the "environment" version that was used when migrating the database in a new internal table. Before executing tests we can see if the database is a listed in `protected_environments` and abort. There is a manual escape valve to force this check from happening with environment variable `DISABLE_DATABASE_ENVIRONMENT_CHECK=1`.