- 29 8月, 2018 1 次提交
-
-
由 Eileen Uchitelle 提交于
We originally did the whole `load_database_yaml` thing because this test wasn't cooperating and we needed to finish the namespaced rake tasks for multiple databases. However, it turns out that YAML can't eval ERB if you don't tell it it's ERB so you get Pysch parse errors if you're using multi-line ERB or ERB with conditionals. It's a hot mess. After trying a few things and thinking it over we decided that it wasn't worth bandaiding over, the test needed to be improved. The test was added in #31135 to test that the env is loaded in these tasks. But it was blowing up because we were trying to read a database name out of the configuration - however that's not the purpose of this change. We want to read environment files in the rake tasks, but not in the config file. In this PR we changed the test to test what the PR was actually fixing. We've also deleted the `load_database_yaml` because it caused more problems than it was worth. This should fix the issues described in https://github.com/rails/rails/pull/32274#issuecomment-384161057. We also had these problems at GitHub. Co-authored-by: Nalimi <aibrahim2k2@gmail.com>
-
- 02 8月, 2018 1 次提交
-
-
由 Alberto Almagro 提交于
This commit follows the path we started at commit #ea4f0e2b and continued at PR #33229.
-
- 01 8月, 2018 1 次提交
-
-
由 Britni Alexander 提交于
-
- 10 4月, 2018 2 次提交
-
-
由 eileencodes 提交于
This was causing single db applications to have rake tasks named `db:create:primary`. These tasks are only useful to multiple database applications so they shouldn't be generated.
-
由 eileencodes 提交于
Pass the spec name to load_schema in order to load from the correct structure file when there are multiple databases
-
- 22 3月, 2018 3 次提交
-
-
由 eileencodes 提交于
Moves the configs_for and DatabaseConfig struct into it's own file. I was considering doing this in a future refactoring but our set up forced me to move it now. You see there are `mattr_accessor`'s on the Core module that have default settings. For example the `schema_format` defaults to Ruby. So if I call `configs_for` or any methods in the Core module it will reset the `schema_format` to `:ruby`. By moving it to it's own class we can keep the logic contained and avoid this unfortunate issue. The second change here does a double loop over the yaml files. Bear with me... Our tests dictate that we need to load an environment before our rake tasks because we could have something in an environment that the database.yml depends on. There are side-effects to this and I think there's a deeper bug that needs to be fixed but that's for another issue. The gist of the problem is when I was creating the dynamic rake tasks if the yaml that that rake task is calling evaluates code (like erb) that calls the environment configs the code will blow up because the environment is not loaded yet. To avoid this issue we added a new method that simply loads the yaml and does not evaluate the erb or anything in it. We then use that yaml to create the task name. Inside the task name we can then call `load_config` and load the real config to actually call the code internal to the task. I admit, this is gross, but refactoring can't all be pretty all the time and I'm working hard with `@tenderlove` to refactor much more of this code to get to a better place re connection management and rake tasks.
-
由 eileencodes 提交于
Adds the ability to dump the schema or structure files for mulitple databases. Loops through the configs for a given env and sets a filename based on the format, then establishes a connection for that config and dumps into the file.
-
由 eileencodes 提交于
`each_current_configuration` is used by create, drop, and other methods to find the configs for a given environment and returning those to the method calling them. The change here allows for the database commands to operate on all the configs in the environment. Previously we couldn't slice the hashes and iterate over them becasue they could be two tier or could be three tier. By using the database config structs we don't need to care whether we're dealing with a three tier or two tier, we can just parse all the configs based on the environment. This makes it possible for us to run `bin/rails db:create` and it will create all the configs for the dev and test environment ust like it does for a two tier - it creates the db for dev and test. Now `db:create` will create `primary` for dev and test, and `animals` for dev and test if our database.yml looks like: ``` development: primary: etc animals: etc test: primary: etc animals: etc ``` This means that `bin/rails db:create`, `bin/rails db:drop`, and `bin/rails db:migrate` will operate on the dev and test env for both primary and animals ds.
-
- 02 3月, 2018 1 次提交
-
-
由 Ryuta Kamizono 提交于
Follow up of b988ecb9. This was added for internal usage, it doesn't need to be public.
-
- 23 2月, 2018 1 次提交
-
-
由 eileencodes 提交于
This reverts commit 16f279eb, reversing changes made to 6c6a30a7. The config can be named anything, not just default (although all generated apps will be named default). We can't just delete configs that don't have a database because that will break three-tier configs. Oh well.
-
- 22 2月, 2018 1 次提交
-
-
由 eileencodes 提交于
Because of this default configuration we're constantly checking if the database exists when looping through configurations. This is unnecessary and we should just delete it before we need to loop through configurations.
-
- 06 2月, 2018 2 次提交
-
-
由 eileencodes 提交于
Followup to b988ecb9, when I cherry-picked from my parallel testing branch I didn't realize `drop` wasn't part of the commit.
-
由 eileencodes 提交于
You could use the `VERBOSE` env var to turn off output for migrations tasks but you couldn't use it for other tasks. This change moves the `verbose?` check to a method so we can also use it in create and drop respectively. tenderlove and I noticed this as part of the ongoing work in parallel testing. When the parallel tests boot the app needs to create new databases for each worker. The output from these is unnecessary but there was previously no way to turn it off. Now if `VERBOSE=false` is passes to `bin/rails db:create` the text "Created blah blah db" will no longer be output.
-
- 19 1月, 2018 1 次提交
-
-
由 Ryuta Kamizono 提交于
This was added in #31727, but it is unused.
-
- 18 1月, 2018 1 次提交
-
-
由 eileencodes 提交于
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.
-
- 07 11月, 2017 1 次提交
-
-
由 bogdanvlviv 提交于
Ensure that `bin/rails db:migrate` with specified `VERSION` reverts all migrations only if `VERSION` is `0`. Raise error if target migration doesn't exist.
-
- 16 10月, 2017 2 次提交
-
-
由 bogdanvlviv 提交于
When load schema from `structure.sql`, database connection isn't established. `ActiveRecord::Tasks::DatabaseTasks.load_schema` has to establish database connection since it executes ``` ActiveRecord::InternalMetadata.create_table ActiveRecord::InternalMetadata[:environment] = environment ```
-
由 bogdanvlviv 提交于
Fix `bin/rails db:setup` and `bin/rails db:test:prepare` create wrong ar_internal_metadata's data for a test database. Before: ``` $ RAILS_ENV=test rails dbconsole > SELECT * FROM ar_internal_metadata; key|value|created_at|updated_at environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679 ``` After: ``` $ RAILS_ENV=test rails dbconsole > SELECT * FROM ar_internal_metadata; key|value|created_at|updated_at environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679 ``` Fixes #26731.
-
- 24 7月, 2017 1 次提交
-
-
由 Eugene Kenny 提交于
This was missed when the frozen string literal pragma was added to this file because the string is only modified when running in the context of a full Rails app, which wasn't covered by the test suite.
-
- 20 7月, 2017 1 次提交
-
-
由 Kir Shatrov 提交于
-
- 11 7月, 2017 1 次提交
-
-
由 Kasper Timm Hansen 提交于
By making the Rails minitest behave like a standard minitest plugin we're much more likely to not break when people use other minitest plugins. Like minitest-focus and pride. To do this, we need to behave like minitest: require files up front and then perform the plugin behavior via the at_exit hook. This also saves us a fair bit of wrangling with test file loading. Finally, since the environment and warnings options have to be applied as early as possible, and since minitest loads plugins at_exit, they have to be moved to the test command. * Don't expect the root method. It's likely this worked because we eagerly loaded the Rails minitest plugin and that somehow defined a root method on `Rails`. * Assign a backtrace to failed exceptions. Otherwise Minitest pukes when attempting to filter the backtrace (which Rails' backtrace cleaner then removes). Means the exception message test has to be revised too. This is likely caused by the rails minitest plugin now being loaded for these tests and assigning a default backtrace cleaner.
-
- 02 7月, 2017 1 次提交
-
-
由 Matthew Draper 提交于
This reverts commit 3420a145, reversing changes made to afb66a5a.
-
- 01 7月, 2017 1 次提交
-
-
由 Kir Shatrov 提交于
-
- 24 5月, 2017 1 次提交
-
-
由 Koichi ITO 提交于
-
- 11 5月, 2017 1 次提交
-
-
由 Akira Matsuda 提交于
Because we don't need to load tasks for DBs that we don't use for the current app. Also, these Tasks classes load AR::Base in their class level, and so immediately kick :active_record on_load hooks. This used to happen when we were loading tasks, not when we run a task.
-
- 27 4月, 2017 1 次提交
-
-
由 bogdanvlviv 提交于
Set consistent type cast ENV["VERBOSE"]: ENV["VERBOSE"] is true if it not equal "false"
-
- 27 3月, 2017 1 次提交
-
-
由 Philippe Guay 提交于
Add stronger assertions to rake migration tasks to make sure the user is providing a numeric VERSION An empty string was getting converted to version = 0. This would in turn pass the presence check. Address linting warning Add test for rake task and refactor code to meet expectations In particular passing VERSION=0 should not raise an error. Addressed Comments for PR #28485. Trimmed empty lines + change of wording for error message Adjust test for change of wording in error message Change condition to follow rails idioms
-
- 12 1月, 2017 1 次提交
-
-
由 Akira Matsuda 提交于
(I personally prefer writing one string in one line no matter how long it is, though)
-
- 04 1月, 2017 1 次提交
-
-
由 Rafael Mendonça França 提交于
-
- 02 1月, 2017 1 次提交
-
-
由 Kir Shatrov 提交于
Today `rake db:schema:cache:dump` only supports dumping cache for a single connection (`ActiveRecord::Base.connection`). This doesn't work for apps with multiple databases. This PR makes `DatabaseTasks` to provide an API for dumping schema cache for any connection.
-
- 30 12月, 2016 1 次提交
-
-
由 Rafael Mendonça França 提交于
-
- 23 12月, 2016 1 次提交
-
-
由 Kir Shatrov 提交于
Without this patch it's impossible to pass extra flags to mysqldump/pg_dump when running `rake db:structure:dump` or `load` The following config variables (`structure_load_flags` and `structure_dump_flags`) make it better configurable.
-
- 29 10月, 2016 1 次提交
-
-
由 Rafael Mendonça França 提交于
-
- 08 8月, 2016 1 次提交
-
-
由 Xavier Noria 提交于
Some case expressions remain, need to think about those ones.
-
- 07 8月, 2016 3 次提交
-
-
由 Xavier Noria 提交于
-
由 Xavier Noria 提交于
-
由 Xavier Noria 提交于
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
-
- 25 5月, 2016 2 次提交
-
-
由 Arthur Neves 提交于
-
由 Arthur Neves 提交于
Instead of passing a separete name variable, we can make the resolver merge a name on the config, and use that before creating the Specification.
-
- 07 5月, 2016 1 次提交
-
-
由 Arthur Neves 提交于
-