Extending the Database Schema

Edit on GitHub

Fields can be added to the existing database tables, but they cannot be removed (removing fields from the tables could break the functionalities implemented in Spryker Core).

In addition, you can create a new database table by running the following command: `console spryk:run AddZedPersistencePropelSchema`.

As an example, we will add a description field to the spy_price_type table. The structure of this table is defined in the PriceProduct module, in the spy_price_product.schema.xml file, as it can be seen below:

    <table name="spy_price_type">
        <column name="id_price_type" type="INTEGER" required="true" primaryKey="true" autoIncrement="true"/>
        <column name="name" type="VARCHAR" size="255" required="true"/>
        <column name="price_mode_configuration" type="ENUM" valueSet="NET_MODE, GROSS_MODE, BOTH"/>

        <unique name="spy_price_type-name">
            <unique-column name="name"/>

        <id-method-parameter value="spy_price_type_pk_seq"/>

To add an additional column to this table, do the following:

  1. On the project side, if it hasn’t been created yet, add the corresponding xml file ( follow the same folder structure and give it the same name)
mkdir -p src/Pyz/Zed/PriceProduct/Persistence/Propel/Schema
touch src/Pyz/Zed/PriceProduct/Persistence/Propel/Schema/spy_price_product.schema.xml
  1. Add the additional fields to the table definition:
<?xml version="1.0"?>
<database xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="zed"

    <table name="spy_price_type">
        <column name="description" type="VARCHAR" size="255" required="false"/>

  1. Update the database by running the following console command:
vendor/bin/console propel:install


If you stumble upon an exception Uncommitted migrations have been found, you should either execute or delete them before rerunning the diff task:

vendor/bin/console propel:migration:delete