Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brosenberger/module-entityservices
Magento2 module to enable easier ways to modify db-entities
https://github.com/brosenberger/module-entityservices
Last synced: 22 days ago
JSON representation
Magento2 module to enable easier ways to modify db-entities
- Host: GitHub
- URL: https://github.com/brosenberger/module-entityservices
- Owner: brosenberger
- License: mit
- Created: 2020-08-23T12:37:02.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-11-14T07:13:01.000Z (about 1 month ago)
- Last Synced: 2024-11-14T08:20:06.463Z (about 1 month ago)
- Language: PHP
- Size: 76.2 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Goal of this module should be
* easy way to update your database without knowledge of underlaying array configs
* creating new EAV entity schemas with just a view lines of code
* add EAV attributes for products, customers, categories without knowledge of the differing subtle differences###DONE:
* create tables with various columns, indizes, foreign keys
* create a set of tables for a EAV entity
* update tables (add/modify columns, drop foreign keys or indizes)###Example:
Usage within a Schema upgrade:
```
class UpgradeSchema implements UpgradeSchemaInterface
{
/**
* @var SchemaBuilder
*/
private $schemaBuilderFactory;
/**
* UpgradeSchema constructor.
* @param SchemaBuilder $schemaBuilderFactory
*/
public function __construct(SchemaBuilderFactory $schemaBuilderFactory) {
$this->schemaBuilderFactory = $schemaBuilderFactory;
}
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
if (version_compare($context->getVersion(), '1.1.0', '<')) {
$this->schemaBuilderFactory->create($setup)->withTable('entity')
->withIntColumn('entity_id')->asIdentiy()->asUnsigned()->asNullable(false)->asPrimaryKey()->build()
->withVarcharColumn('field_id)->asNullable(false)->build()
->withIndex(['field_id'])->build()
->withForeignKey('field_id, 'other_table', 'other_column')->actionNoAction()->build()
->build();
}
$setup->endSetup();
}
}
```