annotaterb icon indicating copy to clipboard operation
annotaterb copied to clipboard

Feature request: support for multi database

Open drwl opened this issue 10 months ago • 2 comments

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 avatar Feb 17 '25 03:02 drwl

@drwl Thank you for creating the issue. I will try to take on this task.🖐️

OdenTakashi avatar Feb 20 '25 00:02 OdenTakashi

This issue, "Feature request: support for multi database," contained the following two problems:

  1. 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.

  1. When the --show-migration option 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.

OdenTakashi avatar Mar 03 '25 09:03 OdenTakashi

@drwl The necessary work for this issue is now finished. Could you please close this issue when it's convenient for you? Thanks!

OdenTakashi avatar Jul 27 '25 23:07 OdenTakashi

Closed by #241 and #206

drwl avatar Jul 30 '25 04:07 drwl

Thank you @OdenTakashi for fixing this!

drwl avatar Jul 30 '25 04:07 drwl