Skip to content

Commit

Permalink
MAGETWO-85326: Tool for generating schema
Browse files Browse the repository at this point in the history
--stabilize CE
  • Loading branch information
Sergii Kovalenko committed Jan 4, 2018
1 parent 4a8e192 commit dc4bb0e
Show file tree
Hide file tree
Showing 34 changed files with 1,272 additions and 909 deletions.
529 changes: 257 additions & 272 deletions app/code/Magento/Bundle/etc/db_schema.xml

Large diffs are not rendered by default.

188 changes: 114 additions & 74 deletions app/code/Magento/Catalog/etc/db_schema.xml

Large diffs are not rendered by default.

20 changes: 9 additions & 11 deletions app/code/Magento/CatalogInventory/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
default="0"/>
<column xsi:type="decimal" name="qty" scale="12" precission="4" unsigned="false" nullable="true"/>
<column xsi:type="decimal" name="min_qty" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
default="0"/>
<column xsi:type="smallint" name="use_config_min_qty" padding="6" unsigned="true" nullable="false"
identity="false" default="1"/>
<column xsi:type="smallint" name="is_qty_decimal" padding="6" unsigned="true" nullable="false" identity="false"
Expand All @@ -30,17 +30,18 @@
<column xsi:type="smallint" name="use_config_backorders" padding="6" unsigned="true" nullable="false"
identity="false" default="1"/>
<column xsi:type="decimal" name="min_sale_qty" scale="12" precission="4" unsigned="false" nullable="false"
default="1.0000"/>
default="1"/>
<column xsi:type="smallint" name="use_config_min_sale_qty" padding="6" unsigned="true" nullable="false"
identity="false" default="1"/>
<column xsi:type="decimal" name="max_sale_qty" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
default="0"/>
<column xsi:type="smallint" name="use_config_max_sale_qty" padding="6" unsigned="true" nullable="false"
identity="false" default="1"/>
<column xsi:type="smallint" name="is_in_stock" padding="6" unsigned="true" nullable="false" identity="false"
default="0"/>
<column xsi:type="timestamp" name="low_stock_date" on_update="false" nullable="true"/>
<column xsi:type="decimal" name="notify_stock_qty" scale="12" precission="4" unsigned="false" nullable="true"/>
<column xsi:type="decimal" name="notify_stock_qty" scale="12" precission="4" unsigned="false" nullable="true"
default="0"/>
<column xsi:type="smallint" name="use_config_notify_stock_qty" padding="6" unsigned="true" nullable="false"
identity="false" default="1"/>
<column xsi:type="smallint" name="manage_stock" padding="6" unsigned="true" nullable="false" identity="false"
Expand All @@ -52,7 +53,7 @@
<column xsi:type="smallint" name="use_config_qty_increments" padding="6" unsigned="true" nullable="false"
identity="false" default="1"/>
<column xsi:type="decimal" name="qty_increments" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
default="0"/>
<column xsi:type="smallint" name="use_config_enable_qty_inc" padding="6" unsigned="true" nullable="false"
identity="false" default="1"/>
<column xsi:type="smallint" name="enable_qty_increments" padding="6" unsigned="true" nullable="false"
Expand Down Expand Up @@ -85,8 +86,7 @@
<column xsi:type="int" name="product_id" padding="11" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="smallint" name="website_id" padding="6" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="smallint" name="stock_id" padding="6" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="decimal" name="qty" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
<column xsi:type="decimal" name="qty" scale="12" precission="4" unsigned="false" nullable="false" default="0"/>
<column xsi:type="smallint" name="stock_status" padding="6" unsigned="true" nullable="false" identity="false"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="product_id"/>
Expand All @@ -107,8 +107,7 @@
<column xsi:type="int" name="product_id" padding="11" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="smallint" name="website_id" padding="6" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="smallint" name="stock_id" padding="6" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="decimal" name="qty" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
<column xsi:type="decimal" name="qty" scale="12" precission="4" unsigned="false" nullable="false" default="0"/>
<column xsi:type="smallint" name="stock_status" padding="6" unsigned="true" nullable="false" identity="false"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="product_id"/>
Expand All @@ -126,8 +125,7 @@
<column xsi:type="int" name="product_id" padding="11" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="smallint" name="website_id" padding="6" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="smallint" name="stock_id" padding="6" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="decimal" name="qty" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
<column xsi:type="decimal" name="qty" scale="12" precission="4" unsigned="false" nullable="false" default="0"/>
<column xsi:type="smallint" name="stock_status" padding="6" unsigned="true" nullable="false" identity="false"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="product_id"/>
Expand Down
17 changes: 6 additions & 11 deletions app/code/Magento/CatalogRule/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
default="0"/>
<column xsi:type="varchar" name="action_operator" nullable="true" length="10" default="to_fixed"/>
<column xsi:type="decimal" name="action_amount" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
default="0"/>
<column xsi:type="smallint" name="action_stop" padding="6" unsigned="false" nullable="false" identity="false"
default="0"/>
<column xsi:type="int" name="sort_order" padding="11" unsigned="true" nullable="false" identity="false"
default="0"/>
<column xsi:type="smallint" name="website_id" padding="6" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="varchar" name="sub_simple_action" nullable="true" length="32"/>
<column xsi:type="decimal" name="sub_discount_amount" scale="12" precission="4" unsigned="false"
nullable="false" default="0.0000"/>
nullable="false" default="0"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="rule_product_id"/>
</constraint>
Expand Down Expand Up @@ -91,7 +91,7 @@
<column xsi:type="int" name="product_id" padding="11" unsigned="true" nullable="false" identity="false"
default="0"/>
<column xsi:type="decimal" name="rule_price" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
default="0"/>
<column xsi:type="smallint" name="website_id" padding="6" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="date" name="latest_start_date"/>
<column xsi:type="date" name="earliest_end_date"/>
Expand Down Expand Up @@ -126,15 +126,10 @@
<column name="customer_group_id"/>
<column name="website_id"/>
</constraint>
<constraint xsi:type="foreign" name="CATRULE_GROUP_WS_CSTR_GROUP_ID_CSTR_GROUP_CSTR_GROUP_ID"
table="catalogrule_group_website" column="customer_group_id" referenceTable="customer_group"
referenceColumn="customer_group_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" name="CATALOGRULE_GROUP_WEBSITE_RULE_ID_CATALOGRULE_RULE_ID"
table="catalogrule_group_website" column="rule_id" referenceTable="catalogrule"
referenceColumn="rule_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" name="CATRULE_GROUP_WS_CSTR_GROUP_ID_CSTR_GROUP_CSTR_GROUP_ID" disabled="1"/>
<constraint xsi:type="foreign" name="CATALOGRULE_GROUP_WEBSITE_RULE_ID_CATALOGRULE_RULE_ID" disabled="1"/>
<constraint xsi:type="foreign" name="CATALOGRULE_GROUP_WEBSITE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID"
table="catalogrule_group_website" column="website_id" referenceTable="store_website"
referenceColumn="website_id" onDelete="CASCADE"/>
disabled="1"/>
<index name="CATALOGRULE_GROUP_WEBSITE_CUSTOMER_GROUP_ID" indexType="btree">
<column name="customer_group_id"/>
</index>
Expand Down
34 changes: 28 additions & 6 deletions app/code/Magento/CatalogSearch/etc/db_schema.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/schema.xsd">
<table name="catalog_eav_attribute" resource="default">
<column xsi:type="float" name="search_weight" scale="10" precission="0" unsigned="true" nullable="false"
default="1"/>
</table>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/schema.xsd">
<table name="catalog_eav_attribute" resource="default">
<column xsi:type="float" name="search_weight" scale="10" precission="0" unsigned="true" nullable="false" default="1"/>
</table>
<table name="catalogsearch_fulltext_scope1_tmp" resource="default">
<column xsi:type="int" name="entity_id" padding="11" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="int" name="attribute_id" padding="11" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="longtext" name="data_index" nullable="true"/>
<constraint xsi:type="primary" name="IDX_PRIMARY">
<column name="entity_id"/>
<column name="attribute_id"/>
</constraint>
<index name="FTI_FULLTEXT_DATA_INDEX" indexType="fulltext">
<column name="data_index"/>
</index>
</table>
<table name="catalogsearch_fulltext_scope1_tmp" resource="default">
<column xsi:type="int" name="entity_id" padding="11" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="int" name="attribute_id" padding="11" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="longtext" name="data_index" nullable="true"/>
<constraint xsi:type="primary" name="IDX_PRIMARY">
<column name="entity_id"/>
<column name="attribute_id"/>
</constraint>
<index name="FTI_FULLTEXT_DATA_INDEX" indexType="fulltext">
<column name="data_index"/>
</index>
</table>
</schema>
33 changes: 18 additions & 15 deletions app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/schema.xsd">
<table name="catalog_url_rewrite_product_category" resource="default">
<column xsi:type="int" name="url_rewrite_id" padding="11" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="int" name="category_id" padding="11" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="int" name="product_id" padding="11" unsigned="true" nullable="false" identity="false"/>
<constraint xsi:type="foreign" name="CAT_URL_REWRITE_PRD_CTGR_PRD_ID_CAT_PRD_ENTT_ENTT_ID"
table="catalog_url_rewrite_product_category" column="product_id"
referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" name="FK_BB79E64705D7F17FE181F23144528FC8"
table="catalog_url_rewrite_product_category" column="url_rewrite_id" referenceTable="url_rewrite"
referenceColumn="url_rewrite_id" onDelete="CASCADE"/>
<index name="CATALOG_URL_REWRITE_PRODUCT_CATEGORY_CATEGORY_ID_PRODUCT_ID" indexType="btree">
<column name="category_id"/>
<column name="product_id"/>
</index>
</table>
<table name="catalog_url_rewrite_product_category" resource="default">
<column xsi:type="int" name="url_rewrite_id" padding="11" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="int" name="category_id" padding="11" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="int" name="product_id" padding="11" unsigned="true" nullable="false" identity="false"/>
<constraint xsi:type="foreign" name="CAT_URL_REWRITE_PRD_CTGR_PRD_ID_CAT_PRD_ENTT_ENTT_ID"
table="catalog_url_rewrite_product_category" column="product_id" referenceTable="catalog_product_entity"
referenceColumn="entity_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" name="FK_BB79E64705D7F17FE181F23144528FC8"
table="catalog_url_rewrite_product_category" column="url_rewrite_id" referenceTable="url_rewrite"
referenceColumn="url_rewrite_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" name="CAT_URL_REWRITE_PRD_CTGR_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID"
table="catalog_url_rewrite_product_category" column="category_id"
referenceTable="catalog_category_entity" referenceColumn="entity_id" onDelete="CASCADE"/>
<index name="CATALOG_URL_REWRITE_PRODUCT_CATEGORY_CATEGORY_ID_PRODUCT_ID" indexType="btree">
<column name="category_id"/>
<column name="product_id"/>
</index>
</table>
</schema>
44 changes: 44 additions & 0 deletions app/code/Magento/Customer/Setup/RecurringData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Customer\Setup;

use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Customer\Model\Customer;

/**
* Upgrade registered themes
*/
class RecurringData implements InstallDataInterface
{
/**
* @var IndexerRegistry
*/
private $indexerRegistry;

/**
* Init
*
* @param IndexerRegistry $indexerRegistry
*/
public function __construct(IndexerRegistry $indexerRegistry)
{
$this->indexerRegistry = $indexerRegistry;
}

/**
* {@inheritdoc}
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);

This comment has been minimized.

Copy link
@giacmir

giacmir Feb 14, 2019

Member

@sereban Why is this needed? In this way a complete customer grid reindex is triggered at every setup run and it can takes lots of time if you have many customers.

$indexer->reindexAll();

}
}
2 changes: 0 additions & 2 deletions app/code/Magento/Customer/Setup/UpgradeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
$this->upgradeVersionTwoZeroTwelve($customerSetup);
}

$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
$indexer->reindexAll();
$this->eavConfig->clear();
$setup->endSetup();
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Customer/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<column xsi:type="int" name="entity_id" padding="11" unsigned="true" nullable="false" identity="false"
default="0"/>
<column xsi:type="decimal" name="value" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
default="0"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="value_id"/>
</constraint>
Expand Down Expand Up @@ -276,7 +276,7 @@
<column xsi:type="int" name="entity_id" padding="11" unsigned="true" nullable="false" identity="false"
default="0"/>
<column xsi:type="decimal" name="value" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
default="0"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="value_id"/>
</constraint>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Directory/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<column xsi:type="varchar" name="currency_from" nullable="false" length="3"/>
<column xsi:type="varchar" name="currency_to" nullable="false" length="3"/>
<column xsi:type="decimal" name="rate" scale="24" precission="12" unsigned="false" nullable="false"
default="0.000000000000"/>
default="0"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="currency_from"/>
<column name="currency_to"/>
Expand Down
10 changes: 5 additions & 5 deletions app/code/Magento/Downloadable/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<column xsi:type="smallint" name="website_id" padding="6" unsigned="true" nullable="false" identity="false"
default="0"/>
<column xsi:type="decimal" name="price" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
default="0"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="price_id"/>
</constraint>
Expand Down Expand Up @@ -201,9 +201,9 @@
identity="false"/>
<column xsi:type="smallint" name="website_id" padding="6" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="decimal" name="min_price" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
default="0"/>
<column xsi:type="decimal" name="max_price" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
default="0"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="entity_id"/>
<column name="customer_group_id"/>
Expand All @@ -216,9 +216,9 @@
identity="false"/>
<column xsi:type="smallint" name="website_id" padding="6" unsigned="true" nullable="false" identity="false"/>
<column xsi:type="decimal" name="min_price" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
default="0"/>
<column xsi:type="decimal" name="max_price" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
default="0"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="entity_id"/>
<column name="customer_group_id"/>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Eav/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<column xsi:type="int" name="entity_id" padding="11" unsigned="true" nullable="false" identity="false"
default="0"/>
<column xsi:type="decimal" name="value" scale="12" precission="4" unsigned="false" nullable="false"
default="0.0000"/>
default="0"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="value_id"/>
</constraint>
Expand Down
20 changes: 20 additions & 0 deletions app/code/Magento/GiftMessage/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,24 @@
<column name="gift_message_id"/>
</constraint>
</table>
<table name="quote" resource="default">
<column xsi:type="int" name="gift_message_id" padding="11" unsigned="false" nullable="true" identity="false"/>
</table>
<table name="quote_address" resource="default">
<column xsi:type="int" name="gift_message_id" padding="11" unsigned="false" nullable="true" identity="false"/>
</table>
<table name="quote_item" resource="default">
<column xsi:type="int" name="gift_message_id" padding="11" unsigned="false" nullable="true" identity="false"/>
</table>
<table name="quote_address_item" resource="default">
<column xsi:type="int" name="gift_message_id" padding="11" unsigned="false" nullable="true" identity="false"/>
</table>
<table name="sales_order" resource="default">
<column xsi:type="int" name="gift_message_id" padding="11" unsigned="false" nullable="true" identity="false"/>
</table>
<table name="sales_order_item" resource="default">
<column xsi:type="int" name="gift_message_id" padding="11" unsigned="false" nullable="true" identity="false"/>
<column xsi:type="int" name="gift_message_available" padding="11" unsigned="false" nullable="true"
identity="false"/>
</table>
</schema>
Loading

0 comments on commit dc4bb0e

Please sign in to comment.