Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Allow EAV and other extended table types #51

Merged
merged 15 commits into from
Jan 26, 2021

Conversation

johnorourke
Copy link
Contributor

@johnorourke johnorourke commented Dec 29, 2020

Working with Magento2 EAV.

This adds 'table providers' - so new types of complex table can be added either by the end user or within the package.

See src/config/sample/magento_eav.yaml for example config.

It also adds new 'where' and 'delete' options at table level, so you can truncate tables you don't need or only affect certain data - for example, to leave data alone which is used by unit tests.

This opens the door for adding table types for Wordpress and Drupal, which have their own linked-table systems - eg. in a Wordpress table provider, we'd be able to specify 'postmeta' fields to be anonymised, simply by adding a new class.

See the updates in README.md for more info and see examples in src/config/sample.

@johnorourke johnorourke changed the title Allow EAV and other extended table types - work in progress Allow EAV and other extended table types Jan 4, 2021
@johnorourke
Copy link
Contributor Author

(hang fire on this - just ironing out a couple of issues found when moving into prod)

…ow allows subclass to override orderBy; support multiple EAV attributes of the same type; warn if using WHERE on a nulled column
@peterjaap
Copy link
Contributor

@johnorourke thanks for working on this! I'll wait with testing until you give me the green light :)

@johnorourke
Copy link
Contributor Author

OK @peterjaap it's working for me nicely now, including accurate row counts and EAV attributes with per-store values.

There's an issue with Illuminate where ->count() doesn't behave as expected when using groupBy or having - fixed in 7.x but I've put a workaround in so that we don't need to upgrade it, meaning this will still work with php 7.1. See laravel/framework#32624

@johnorourke
Copy link
Contributor Author

@peterjaap In production we discovered one more issue - the 'delete' option does not enforce integrity, so any foreign keys with 'on delete cascade' triggers are not deleted, leaving invalid data. I'll add a fix.

@johnorourke
Copy link
Contributor Author

@peterjaap still not getting 'on delete cascade' enforced, so don't test/merge this yet!

…Illuminate Arr class instead of array_get; finished documenting new features
@johnorourke
Copy link
Contributor Author

@peterjaap I'm happy with this now - I updated the README with much more detail about how to use EAV, 'delete' and 'where' options, and added a new 'platform' setting of 'magento2-without-orders' to give a better example of removing data.

@peterjaap peterjaap merged commit 7f2a1a1 into elgentos:master Jan 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants