aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/schema_migration.rb
Commit message (Collapse)AuthorAgeFilesLines
* Revert schema dumper to use strings rather than integerseileencodes2019-06-201-1/+1
| | | | | | | | | | | I think we should change this, but not in 6-0-stable since that's already in RC and I was trying to only make changes that won't require any app changes. This reverts a portion of https://github.com/rails/rails/pull/36439 that made all schema migration version numbers get dumped as an integer. While it doesn't _really_ matter it did change behavior. We should bring this back in 6.1 with a deprecation.
* Move SchemaMigration to migration_contexteileencodes2019-06-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This PR moves the `schema_migration` to `migration_context` so that we can access the `schema_migration` per connection. This does not change behavior of the SchemaMigration if you are using one database. This also does not change behavior of any public APIs. `Migrator` is private as is `MigrationContext` so we can change these as needed. We now need to pass a `schema_migration` to `Migrator` so that we can run migrations on the right connection outside the context of a rake task. The bugs this fixes were discovered while debugging the issues around the SchemaCache on initialization with multiple database. It was clear that `get_all_versions` wouldn't work without these changes outside the context of a rake task (because in the rake task we establish a connection and change AR::Base.connection to the db we're running on). Because the `SchemaCache` relies on the `SchemaMigration` information we need to make sure we store it per-connection rather than on ActiveRecord::Base. [Eileen M. Uchitelle & Aaron Patterson]
* 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/+1
|
* 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.
* [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
|
* Extract `SchemaMigration.all_versions`Ryuta Kamizono2017-03-061-1/+5
| | | | | Use `SchemaMigration.all_versions` instead of `SchemaMigration.all.map(&:version)` to avoid to instantiate AR objects.
* `#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.
* Avoid extra `show variables` in migrationRyuta Kamizono2016-02-011-3/+2
| | | | | | | | | | | | | `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-7/+2
|
* Make `SchemaMigration.drop_table` to one SQLRyuta Kamizono2016-01-301-4/+1
| | | | | `SchemaMigration.drop_table` is only used in tests. Simply we can use `drop_table if_exists: true`.
* Clean up internal metadata definitionRyuta Kamizono2016-01-151-1/+1
| | | | | | | | | | | | | | 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
* Get update_attributes working with SchemaMigrationschneems2016-01-081-1/+1
| | | | You cannot use `update_attributes` on models that do not have a primary key. Since SchemaMigration versions are guaranteed to be unique (they have a unique index on them) we can safely use them as a primary key.
* Deprecate `#table_exists?`, `#tables` and passing arguments to `#talbes`yui-knk2015-11-091-1/+1
| | | | | | | | | | Reported on #21509, how views is treated by `#tables` are differ by each adapters. To fix this different behavior, after Rails 5.0 is released, deprecate `#tables`. And `#table_exists?` would check both tables and views. To make their behavior consistent with `#tables`, after Rails 5.0 is released, deprecate `#table_exists?`.
* Doc SchemaMigration class.schneems2015-09-141-1/+5
|
* Fix circular import warning on buildYoong Kang Lim2015-05-311-1/+0
|
* Extract AR::SchemaMigration.normalized_versions methodViktar Basharymau2014-06-271-0/+4
|
* `ActiveRecord::SchemaMigration` has no primary key.Yves Senn2014-06-061-0/+3
| | | | | | | | | | Before this patch, using `ActiveRecord::Base.primary_key_prefix_type` with `:table_name_with_underscore` would change the `SchemaMigration` model to have a primary key. This resulted in broken queries for PG because it tried to return the inserted PK (which does not exist). Closes #15051. Closes #15419.
* `bin/rake db:migrate:status` works with legacy migration numbers.Yves Senn2014-06-061-0/+4
| | | | | | | The migration numbers were normalized different ways. This left the task output in an inconsistent state. Closes #15538.
* added schema_migrations_table_name to ActiveRecord::Base in order that the ↵Jerad Phelps2013-10-271-2/+2
| | | | | | | | | | | | | | | | | | | | name of the schema migrations table can be configured. consolidated test_schema_migrations_table_name tests Added changelog entry edited changelog removed commented lines removed reader ensure the schema migrations table is reset at end of test added entry to configuration guide guides typo and changelog order
* Minor refactor of ActiveRecord::SchemaMigration to remove references to ↵Kyle Rippey2013-05-261-18/+24
| | | | Base, override table_exists method, and switch to preferred style for class method definitions.
* sets limit 191 for schema_migrations#version in mysql2 if the encoding is ↵Xavier Noria2013-03-171-5/+8
| | | | | | "utf8mb4" Please, see rationale in the included CHANGELOG patch.
* Move to the schema-migrations-metadata branch.Jeremy Kemper2012-12-091-36/+3
| | | | | | | | | | | | | | | | | | | | | | | | Pending work on graceful app upgrades. Revert "Merge pull request #8439 from joshsusser/fixes" This reverts commit ce8ac39338f86388e70356b3a470b3ea443802ae, reversing changes made to b0e7b6f67c984d4b1502e801781ed75fad681633. Revert "Merge pull request #8431 from joshsusser/schemadump" This reverts commit 036d3e1c2b65c4b8cbd23de2e20ad67b9b756182, reversing changes made to 0c692f4d121792117b6a71e5ed590a31c3b9d12e. Revert "Merge branch 'joshsusser-master' into merge" This reverts commit 0c692f4d121792117b6a71e5ed590a31c3b9d12e, reversing changes made to 2e299fca715b083a60222a85e48f9d3b8dd8ce93. Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb activerecord/test/cases/schema_dumper_test.rb
* Oracle needs table to check index existenceJosh Susser2012-12-061-3/+3
|
* style cleanupJosh Susser2012-12-031-4/+4
|
* Add migration history to schema.rb dumpJosh Susser2012-12-021-0/+12
|
* Add metadata to schema_migrationsJosh Susser2012-12-011-4/+25
| | | | | migrated_at: timestamp when migration run fingerprint: md5 hash of migration source name: filename without version or extension
* Remove mass assignment security from ActiveRecordGuillermo Iguaran2012-09-161-1/+0
|
* Remove duplicated unique index name.kennyj2012-07-141-4/+7
|
* allow mass-assign version attribute in AR::SchemaMigrationSergey Nartimov2012-02-061-0/+2
|
* make sure the migration table is alive and emptyAaron Patterson2012-01-131-2/+1
|
* refactor schema migration table creation to the schema migration modelAaron Patterson2012-01-131-0/+18
|
* convert the migration list to a Set, remove duplicate codeAaron Patterson2012-01-131-0/+4
|
* use the schema migration model to dump schema infoAaron Patterson2012-01-131-1/+3
|
* add a migration schema modelAaron Patterson2012-01-131-0/+9