Page 1 of 2

Need to change the database schema

Posted: 16 May 2017, 10:36
by VickoNovianto
I use Aimeos 2017.04 with PostgreSQL 9.6.2 and Laravel 5.4 with PHP 7.1.1. I use Windows 8 Pro. I want to ask, if I change the PostgreSQL database schema(including the tables) in the demo app, can the source code still work? Or i have to change the source code to adapt to new schema? Thank you.

Re: Need to change the database schema

Posted: 16 May 2017, 15:11
by aimeos
Depends which schema changes you want to make. Can you explain a bit in more detail?
The correct way is explained in the Aimeos Wiki: https://aimeos.org/docs/Developers/Library/Setup_tasks

Re: Need to change the database schema

Posted: 31 May 2017, 03:24
by VickoNovianto
I want to replace entire demo schema with my own designed schema. My own designed schema is different with the demo schema. My schema has foreign keys and has a lot more tables and columns. What do i need to do to replace the demo schema with my own designed schema? Do i need to change the code in the application too? Thank you.

Re: Need to change the database schema

Posted: 31 May 2017, 08:39
by aimeos
Can you please post an example of what you want to change?

Re: Need to change the database schema

Posted: 21 Jun 2017, 14:22
by VickoNovianto
I want to change mshop_order table into order table which consists of :
  • ID
    Buyer_ID
    Payment_Method_Type_ID
    Buyer_Address
    Timestamp
Buyer_ID is a foreign key which references id from buyer table. Payment_Method_Type_ID references id from payment_method_type table.

Re: Need to change the database schema

Posted: 21 Jun 2017, 20:59
by aimeos
You can extend the mshop_order table but you should keep the existing data as well. Otherwise, there's no place to store important information and you will get trouble with e.g. the confirmation e-mails.

For changing the table schema, have a look at this article:
https://aimeos.org/docs/Developers/Libr ... ema_update

This one explains how to extend the order item and manager to store the additional data:
https://aimeos.org/docs/Developers/Libr ... gers_items

Re: Need to change the database schema

Posted: 20 Mar 2023, 13:19
by kdim95
Hello,

What is the proper way to override this file?
vendor/aimeos/aimeos-core/setup/default/schema/review.php

I have attempted to override it in my extension, it didn't work:
/packages/<my-extension>/database/setup/default/schema/review.php

Re: Need to change the database schema

Posted: 21 Mar 2023, 08:06
by aimeos
The correct directory is:

Code: Select all

/packages/<my-extension>/setup/default/schema/review.php

Re: Need to change the database schema

Posted: 04 Apr 2023, 13:24
by kdim95
Hello,

That did not work.

When executing php artisan aimeos:setup, it stops on Migrating: vendor/aimeos/aimeos-core/setup/Review.php

Error:

Code: Select all

Doctrine\DBAL\Exception\UniqueConstraintViolationException

An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2-product-<product id>-1.' for key 'unq_msrev_cid_dom_rid_sid'
I understand that is because there are existing reviews from the same user in the database, but that is the purpose of modifying the database, to allow adding multiple reviews by the same person and not breaking the setup command.

Re: Need to change the database schema

Posted: 07 Apr 2023, 08:36
by aimeos
The problem might be that the demo data isn't removed before importing it again and therefore, the exact same row causes the problem now.

Each customer can add only one review for each product and this is ensured by the constraint.