aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/schema_cache.rb
Commit message (Collapse)AuthorAgeFilesLines
* Also deduplicate schema cache structure when they are read from the databaseJean Boussier2019-07-011-5/+15
|
* Schema Cache: extract deduplication commonalityKasper Timm Hansen2019-06-211-10/+15
|
* Also deduplicate schema cache data when using the init_with interfaceJean Boussier2019-06-211-6/+6
|
* Stop serializing and parsing columns_hash in Active Record schema cachesJean Boussier2019-06-191-8/+5
|
* Deduplicate various Active Record schema cache structuresJean Boussier2019-06-031-1/+20
| | | | | | | | | | | | Real world database schemas contain a lot of duplicated data. Some column names like `id`, `created_at` etc can easily be repeated hundreds of times. Same for SqlTypeMetada, most database will contain only a limited number of possible combinations. This result in a lot of wasted memory. The idea here is to make these data sctructures immutable, use a registry to substitute similar instances with pre-existing ones.
* Cache database version in schema cacheAli Ibrahim2019-04-031-14/+21
| | | | | | | | | | | | | | | * The database version will get cached in the schema cache file during the schema cache dump. When the database version check happens, the version will be pulled from the schema cache and thus avoid querying the database for the version. * If the schema cache file doesn't exist, we'll query the database for the version and cache it on the schema cache object. * To facilitate this change, all connection adapters now implement #get_database_version and #database_version. #database_version returns the value from the schema cache. * To take advantage of the cached database version, the database version check will now happen after the schema cache is set on the connection in the connection pool.
* Revert "Remove Marshal support from SchemaCache"Rafael Mendonça França2019-03-131-0/+11
| | | | This reverts commit 65f2eeaaf5774f0891fff700f4defb0b90a05789.
* Schema Cache: cache table indexesKasper Timm Hansen2019-03-131-5/+15
| | | | | | Useful to not query for indexes when an application uses schema cache. Ref https://github.com/rails/rails/pull/35546
* Merge branch 'test-remove-marshal-support-from-schema-cache'Kasper Timm Hansen2019-03-121-10/+0
|\
| * Remove Marshal support from SchemaCacheKasper Timm Hansen2019-03-121-10/+0
| | | | | | | | | | YAML has been used to serialize the schema cache ever since 2016 with Rails 5.1: 4c00c6ed
* | Modernize size calculation in Schema CacheKasper Timm Hansen2019-03-121-1/+1
|/ | | | | Not looking for other contributions like this, but I took the liberty since I was already working on this.
* Only define attribute methods from schema cacheEugene Kenny2018-09-281-0/+5
| | | | | | | | | | | | | 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.
* Refactor migration to move migrations paths to connectioneileencodes2018-01-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* `#tables` and `#table_exists?` and returns only tables and not viewsRafael Mendonça França2016-12-291-6/+0
|
* Use YAML to serialize schema cacheKir Shatrov2016-11-271-0/+16
|
* Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-071-1/+0
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-3/+3
|
* introduce `conn.data_source_exists?` and `conn.data_sources`.Yves Senn2015-09-221-22/+29
| | | | | | | | | | | | | | | | | These new methods are used from the Active Record model layer to determine which relations are viable to back a model. These new methods allow us to change `conn.tables` in the future to only return tables and no views. Same for `conn.table_exists?`. The goal is to provide the following introspection methods on the connection: * `tables` * `table_exists?` * `views` * `view_exists?` * `data_sources` (views + tables) * `data_source_exists?` (views + tables)
* Apply schema cache dump when creating connectionsEugene Kenny2015-04-291-0/+8
| | | | | | | | | | | | | | | The `db:schema:cache:dump` rake task dumps the database schema structure to `db/schema_cache.dump`. If this file is present, the schema details are loaded into the currently checked out connection by a railtie while Rails is booting, to avoid having to query the database for its schema. The schema cache dump is only applied to the initial connection used to boot the application though; other connections from the same pool are created with an empty schema cache, and still have to load the structure of each table directly from the database. With this change, a copy of the schema cache is associated with the connection pool and applied to connections as they are created.
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-3/+1
|
* change to empty? from blank?tsukasaoishi2014-08-081-1/+1
|
* Tables existence check query is executed in large quantitiestsukasaoishi2014-08-071-0/+7
| | | | | | | | | | | | | | When Rails starts, tables existence check query is executed number of models. In case of mysql, SHOW TABLES LIKE 'table1'; SHOW TABLES LIKE 'table2'; SHOW TABLES LIKE 'table3'; ... SHOW TABLES LIKE 'table999'; Add process to get the names of all tables by one query.
* remove blank lines in the start of the ActiveRecord filesPonomarev Nikolay2014-07-291-1/+0
|
* Simplify the code in schema cacheSean Griffin2014-05-231-31/+11
| | | | | The use of default procs was unnessecary, made the code confusing to follow, and made marshalling needlessly complex.
* Removed unsued deprecation requireRashmi Yadav2013-07-041-1/+0
|
* Remove deprecated nil-passing to `SchemaCache` methods.Yves Senn2013-07-041-28/+8
|
* fix hash duping on 1.9Aaron Patterson2013-03-141-1/+1
|
* just access the ivars rather than rb_iv_getAaron Patterson2013-03-141-5/+3
|
* hide more data in the schema cacheAaron Patterson2013-03-141-1/+21
|
* safely publish columns and columns hash infoAaron Patterson2013-03-141-4/+12
|
* dup and set the default proc to nil rather than looping through everythingAaron Patterson2013-03-141-1/+3
|
* schema cache already has the columns as a hash, so use thatAaron Patterson2012-11-251-1/+11
|
* speed up fixture loading by querying the schema cache for column namesAaron Patterson2012-11-251-1/+10
|
* Support judgement expired schema cache dump.kennyj2012-03-011-3/+6
|
* Load db/schema_cache.dump duaring boot time.kennyj2012-03-011-1/+1
|
* Add db:schema:cache:dump and db:schema:cache:clear tasks.kennyj2012-03-011-0/+9
|
* Add support schema cache dump and load.kennyj2012-03-011-14/+34
|
* columns method doesn't have name argumentRafael Mendonça França2012-02-021-1/+1
|
* Should clear the primary keys cache alsoJon Leighton2011-12-161-0/+1
|
* Don't store defaults in the schema cacheJon Leighton2011-12-161-3/+2
|
* Defaults hash can go on the modelJon Leighton2011-12-161-14/+1
|
* Cache columns at the model level.Jon Leighton2011-12-161-9/+2
| | | | Allows two models to use the same table but have different primary keys.
* Use `table_exists?` from the schema cache.Aaron Patterson2011-12-091-4/+2
|
* pushing caching and visitors down to the connectionAaron Patterson2011-11-191-0/+72