From 3294f7e3f4f2b3838fc62354f00ec3160ce03a0d Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 1 Jan 2020 21:05:12 +0100 Subject: [PATCH] add todos and improve db schema --- Admin/Install/db.json | 203 +++++++++++---------------------------- Models/AddressMapper.php | 60 ------------ Models/ProfileMapper.php | 5 +- 3 files changed, 59 insertions(+), 209 deletions(-) delete mode 100644 Models/AddressMapper.php diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 962d50d..ee9f7bd 100644 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -38,39 +38,6 @@ } } }, - "profile_account_permission": { - "name": "profile_account_permission", - "fields": { - "profile_account_permission_id": { - "name": "profile_account_permission_id", - "type": "INT", - "null": false, - "primary": true, - "autoincrement": true - }, - "profile_account_permission_profile": { - "name": "profile_account_permission_profile", - "type": "INT", - "null": false, - "foreignTable": "profile_account", - "foreignKey": "profile_account_id" - }, - "profile_account_permission_group": { - "name": "profile_account_permission_group", - "type": "INT", - "null": false, - "foreignTable": "group", - "foreignKey": "group_id" - }, - "profile_account_permission_account": { - "name": "profile_account_permission_account", - "type": "INT", - "null": false, - "foreignTable": "account", - "foreignKey": "account_id" - } - } - }, "profile_contact": { "name": "profile_contact", "fields": { @@ -148,8 +115,19 @@ "type": "TEXT", "null": false }, - "profile_contact_account": { - "name": "profile_contact_account", + "profile_contact_image": { + "name": "profile_contact_image", + "type": "INT", + "default": null, + "null": true, + "foreignTable": "media", + "foreignKey": "media_id", + "annotations": { + "gdpr": true + } + }, + "profile_contact_profile": { + "name": "profile_contact_profile", "type": "INT", "null": false, "foreignTable": "profile_account", @@ -192,9 +170,40 @@ } } }, + "profile_contact_address": { + "name": "profile_contact_address", + "fields": { + "profile_contact_address_id": { + "name": "profile_contact_address_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "profile_contact_address_type": { + "name": "profile_contact_address_type", + "type": "TINYINT", + "null": false + }, + "profile_contact_address_contact": { + "name": "profile_contact_address_contact", + "type": "INT", + "null": false, + "foreignTable": "profile_contact", + "foreignKey": "profile_contact_id" + }, + "profile_contact_address_address": { + "name": "profile_contact_address_address", + "type": "INT", + "null": false, + "foreignTable": "address", + "foreignKey": "address_id" + } + } + }, "profile_contactelement": { "name": "profile_contactelement", - "comment": "not a full contact only the element like email, phone etc. for the accounts themselves (not profile_account)", + "comment": "email, phone etc for profiles", "fields": { "profile_contactelement_id": { "name": "profile_contactelement_id", @@ -218,12 +227,12 @@ "type": "VARCHAR(255)", "null": false }, - "profile_contactelement_account": { - "name": "profile_contactelement_account", + "profile_contactelement_contact": { + "name": "profile_contactelement_contact", "type": "INT", "null": false, - "foreignTable": "account", - "foreignKey": "account_id" + "foreignTable": "profile_account", + "foreignKey": "profile_account_id" } } }, @@ -242,119 +251,19 @@ "type": "TINYINT", "null": false }, - "profile_address_address": { - "name": "profile_address_address", - "type": "VARCHAR(255)", - "null": false, - "annotations": { - "gdpr": true - } - }, - "profile_address_street": { - "name": "profile_address_street", - "type": "VARCHAR(255)", - "null": false, - "annotations": { - "gdpr": true - } - }, - "profile_address_city": { - "name": "profile_address_city", - "type": "VARCHAR(255)", - "null": false, - "annotations": { - "gdpr": true - } - }, - "profile_address_zip": { - "name": "profile_address_zip", - "type": "VARCHAR(255)", - "null": false, - "annotations": { - "gdpr": true - } - }, - "profile_address_country": { - "name": "profile_address_country", - "type": "VARCHAR(255)", - "null": false, - "annotations": { - "gdpr": true - } - }, - "profile_address_account": { - "name": "profile_address_account", + "profile_address_profile": { + "name": "profile_address_profile", "type": "INT", "null": false, "foreignTable": "profile_account", "foreignKey": "profile_account_id" - } - } - }, - "profile_account_relation": { - "name": "profile_account_relation", - "fields": { - "profile_account_relation_id": { - "name": "profile_account_relation_id", + }, + "profile_address_address": { + "name": "profile_address_address", "type": "INT", "null": false, - "primary": true, - "autoincrement": true - }, - "profile_account_relation_type": { - "name": "profile_account_relation_type", - "type": "TINYINT", - "null": false - }, - "profile_account_relation_relation": { - "name": "profile_account_relation_relation", - "type": "INT", - "default": null, - "null": true - }, - "profile_account_relation_account": { - "name": "profile_account_relation_account", - "type": "INT", - "default": null, - "null": true, - "foreignTable": "account", - "foreignKey": "account_id" - } - } - }, - "profile_account_setting": { - "name": "profile_account_setting", - "fields": { - "profile_account_setting_id": { - "name": "profile_account_setting_id", - "type": "INT", - "null": false, - "primary": true, - "autoincrement": true - }, - "profile_account_setting_module": { - "name": "profile_account_setting_module", - "type": "INT", - "null": false - }, - "profile_account_setting_type": { - "name": "profile_account_setting_type", - "type": "VARCHAR(20)", - "null": false - }, - "profile_account_setting_value": { - "name": "profile_account_setting_value", - "type": "VARCHAR(32)", - "default": null, - "null": true - }, - "profile_account_setting_account": { - "name": "profile_account_setting_account", - "type": "INT", - "default": null, - "null": true, - "foreignTable": "account", - "foreignKey": "account_id" + "foreignTable": "address", + "foreignKey": "address_id" } } } diff --git a/Models/AddressMapper.php b/Models/AddressMapper.php deleted file mode 100644 index d5bbad0..0000000 --- a/Models/AddressMapper.php +++ /dev/null @@ -1,60 +0,0 @@ -> - * @since 1.0.0 - */ - protected static array $columns = [ - 'profile_address_id' => ['name' => 'profile_address_id', 'type' => 'int', 'internal' => 'id'], - 'profile_address_type' => ['name' => 'profile_address_type', 'type' => 'int', 'internal' => 'type'], - 'profile_address_address' => ['name' => 'profile_address_address', 'type' => 'string', 'internal' => 'address'], - 'profile_address_street' => ['name' => 'profile_address_street', 'type' => 'string', 'internal' => 'street'], - 'profile_address_city' => ['name' => 'profile_address_city', 'type' => 'string', 'internal' => 'city'], - 'profile_address_zip' => ['name' => 'profile_address_zip', 'type' => 'string', 'internal' => 'postal'], - 'profile_address_country' => ['name' => 'profile_address_country', 'type' => 'string', 'internal' => 'country'], - ]; - - /** - * Primary table. - * - * @var string - * @since 1.0.0 - */ - protected static string $table = 'profile_address'; - - /** - * Primary field name. - * - * @var string - * @since 1.0.0 - */ - protected static string $primaryField = 'profile_address_id'; -} diff --git a/Models/ProfileMapper.php b/Models/ProfileMapper.php index f49fd7c..7c533d2 100644 --- a/Models/ProfileMapper.php +++ b/Models/ProfileMapper.php @@ -17,6 +17,7 @@ namespace Modules\Profile\Models; use Modules\Admin\Models\AccountMapper; use Modules\Media\Models\MediaMapper; use phpOMS\DataStorage\Database\DataMapperAbstract; +use Modules\Address\Models\AddressMapper; /** * Profile mapper. @@ -68,8 +69,8 @@ final class ProfileMapper extends DataMapperAbstract 'location' => [ 'mapper' => AddressMapper::class, 'table' => 'profile_address', - 'dst' => 'profile_address_account', - 'src' => null, + 'dst' => 'profile_address_address', + 'src' => 'profile_address_profile', ], ];