Need to change the database schema

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
VickoNovianto
Posts: 7
Joined: 16 Apr 2017, 00:35

Need to change the database schema

Post by VickoNovianto » 16 May 2017, 10:36

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.

User avatar
aimeos
Administrator
Posts: 7785
Joined: 01 Jan 1970, 00:00

Re: Need to change the database schema

Post by aimeos » 16 May 2017, 15:11

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
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

VickoNovianto
Posts: 7
Joined: 16 Apr 2017, 00:35

Re: Need to change the database schema

Post by VickoNovianto » 31 May 2017, 03:24

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.

User avatar
aimeos
Administrator
Posts: 7785
Joined: 01 Jan 1970, 00:00

Re: Need to change the database schema

Post by aimeos » 31 May 2017, 08:39

Can you please post an example of what you want to change?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

VickoNovianto
Posts: 7
Joined: 16 Apr 2017, 00:35

Re: Need to change the database schema

Post by VickoNovianto » 21 Jun 2017, 14:22

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.

User avatar
aimeos
Administrator
Posts: 7785
Joined: 01 Jan 1970, 00:00

Re: Need to change the database schema

Post by aimeos » 21 Jun 2017, 20:59

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
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kdim95
Advanced
Posts: 180
Joined: 26 Aug 2022, 12:17

Re: Need to change the database schema

Post by kdim95 » 20 Mar 2023, 13:19

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

User avatar
aimeos
Administrator
Posts: 7785
Joined: 01 Jan 1970, 00:00

Re: Need to change the database schema

Post by aimeos » 21 Mar 2023, 08:06

The correct directory is:

Code: Select all

/packages/<my-extension>/setup/default/schema/review.php
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kdim95
Advanced
Posts: 180
Joined: 26 Aug 2022, 12:17

Re: Need to change the database schema

Post by kdim95 » 04 Apr 2023, 13:24

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.

User avatar
aimeos
Administrator
Posts: 7785
Joined: 01 Jan 1970, 00:00

Re: Need to change the database schema

Post by aimeos » 07 Apr 2023, 08:36

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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply