Feature request: support for multi database
Adding this as a feature request and an invitation for anyone that wants to try tackling this. At the moment, I do not have time to work on this.
From https://github.com/ctran/annotate_models/pull/892
Given a Rails application with multiple databases, tables in two databases with the same table name, and corresponding models with different names, some files get annotated with the wrong table's schema.
The issue is that some of the patterns include %TABLE_NAME%, which will be identical between the two tables, even though they have different model names.
This fixes the issue by eliminating the use of the table name when the model is not connected to the primary database.
My work in progress before I decided to close the PR, https://github.com/drwl/annotaterb/pull/135
@drwl Thank you for creating the issue. I will try to take on this task.🖐️
This issue, "Feature request: support for multi database," contained the following two problems:
- When executing annotation, fixture files were inferred based on the table name. In a multi-database environment, if tables with the same name exist across databases, the wrong file could be retrieved.
This is the same issue described below: https://github.com/ctran/annotate_models/pull/892
Given a Rails application with multiple databases, tables in two databases with the same table name, and corresponding models with different names, some files get annotated with the wrong table's schema.
The issue is that some of the patterns include %TABLE_NAME%, which will be identical between the two tables, even though they have different model names.
This fixes the issue by eliminating the use of the table name when the model is not connected to the primary database.
- When the
--show-migrationoption is specified, the schema version of the primary database is also annotated for models referring to the secondary database.
Therefore, we will address each issue in separate pull requests.
@drwl The necessary work for this issue is now finished. Could you please close this issue when it's convenient for you? Thanks!
Closed by #241 and #206
Thank you @OdenTakashi for fixing this!