Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unable to extend ProductAttribute with new properties after 1.8 #11843

@leflings

Description

@leflings

Sylius version affected: 1.8

Description
We are no longer able to extend ProductAttribute with new properties due to the new way doctrine migrations are now ordered.

Due to the way this specific migration works (specifically how it uses the repository in line 40), it will fail if you have added any properties to ProductAttribute since these properties will not yet have been migrated to the table schema.

We used to solve this by backdating the migrations that altered the product attribute table back to some timestamp before the 20171003103916 migration. This no longer works.

 bin/console doc:data:drop --force && bin/console doc:data:create && bin/console doc:mig:migrate
Dropped database `sylius_18_dev` for connection named default
Created database `sylius_18_dev` for connection named default

 WARNING! You are about to execute a database migration that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
 > y

[notice] Migrating up to DoctrineMigrations\Version20171003100000
[warning] Migration Sylius\Bundle\CoreBundle\Migrations\Version20161209095131 was executed but did not result in any SQL statements.
[error] Migration Sylius\Bundle\CoreBundle\Migrations\Version20171003103916 failed during Execution. Error: "An exception occurred while executing 'SELECT t0.code AS code_1, t0.type AS type_2, t0.storage_type AS storage_type_3, t0.configuration AS configuration_4, t0.created_at AS created_at_5, t0.updated_at AS updated_at_6, t0.position AS position_7, t0.id AS id_8, t0.facetType AS facetType_9 FROM sylius_product_attribute t0 WHERE t0.type = ?' with params ["select"]:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.facetType' in 'field list'"

In AbstractMySQLDriver.php line 64:

  An exception occurred while executing 'SELECT t0.code AS code_1, t0.type AS type_2, t0.storage_type AS storage_type_3, t0.configuration AS configuration_4, t0.created_at AS created_at_5, t0.updated_at AS updated_at_6, t0.position AS position_7, t0.id AS id_8, t0.facetType AS facetTyp
  e_9 FROM sylius_product_attribute t0 WHERE t0.type = ?' with params ["select"]:

  SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.facetType' in 'field list'


In PDOStatement.php line 131:

  SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.facetType' in 'field list'


In PDOStatement.php line 129:

  SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.facetType' in 'field list'


doctrine:migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--all-or-nothing [ALL-OR-NOTHING]] [--configuration CONFIGURATION] [--db-configuration DB-CONFIGURATION] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<version>]

Steps to reproduce
I have provided a repository that reproduce the bug in question.

https://github.com/leflings/sylius-1.8-migration-issue/commits/master

How will we solve this problem from now on, now that backdating no longer works? Can the 20171003103916 migration be rewritten to not use the the repository (which is what creates the failing select query)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions