Skip to content

Deals with tables with composite primary key - #7

Closed
k4200 wants to merge 2 commits into
y-ken:masterfrom
k4200:composite_index
Closed

Deals with tables with composite primary key#7
k4200 wants to merge 2 commits into
y-ken:masterfrom
k4200:composite_index

Conversation

@k4200

@k4200 k4200 commented Mar 27, 2015

Copy link
Copy Markdown

In our project, the tables that we wanted to export to Elasticsearch don't have a single column primary key, so the plugin couldn't be used because it doesn't allow composite ones, so I did a quick fix to allow them and it seems working in our environment.

I'm not sure this feature is of use to anyone, but who knows? So I'm sending this PR.

I'm not a Ruby programmer, so any suggestions as to the coding style etc. would be appreciated.

Thanks.

@k4200

k4200 commented Mar 27, 2015

Copy link
Copy Markdown
Author

Sorry, tests failed...

@y-ken

y-ken commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Thank you for this PR and for raising composite primary key support — it's a genuinely useful capability.

We've implemented it in #55, which reimplements your approach on the current codebase (the plugin has diverged quite a bit since 2015). primary_key now accepts a comma-separated list, e.g.:

primary_key  tenant_id,id

and the combination is used both for change detection and for the Elasticsearch document _id (joined by ,, e.g. 10,7). Single-column keys are unchanged.

While porting your idea, we also kept a fix for a small bug in the original change here: the update branch read table_hash[row[id]] (always nil, since id is the composite array) instead of table_hash[id].

Once #55 is merged this PR will be superseded. Thanks again — your PR is what drove the feature. 🙏

@y-ken y-ken closed this Jun 16, 2026
@y-ken y-ken mentioned this pull request Jun 16, 2026
y-ken added a commit that referenced this pull request Jun 16, 2026
Bump the gem version to 1.3.0 and add the CHANGELOG entry.

1.3.0 is a minor release adding two backward-compatible features since 1.2.0:
- Date-based Elasticsearch index names via strftime tokens in the tag (#27).
- Composite primary key support in mysql_replicator (#7).

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants