Skip to content

Commit

Permalink
MAGETWO-85326: Tool for generating schema
Browse files Browse the repository at this point in the history
--make magento works with new schema
  • Loading branch information
Sergii Kovalenko committed Jan 3, 2018
1 parent 732bb68 commit 86fb388
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 29 deletions.
32 changes: 16 additions & 16 deletions app/code/Magento/Sales/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1374,37 +1374,37 @@
<column xsi:type="smallint" name="store_id" padding="6" unsigned="true" nullable="true" identity="false"/>
<column xsi:type="varchar" name="order_status" nullable="false" length="50"/>
<column xsi:type="int" name="orders_count" padding="11" unsigned="false" nullable="false" identity="false"
default="'0'"/>
default="0"/>
<column xsi:type="decimal" name="total_qty_ordered" scale="12" precission="4" unsigned="false" nullable="false"
default="'0.0000'"/>
default="0.0000"/>
<column xsi:type="decimal" name="total_qty_invoiced" scale="12" precission="4" unsigned="false" nullable="false"
default="'0.0000'"/>
default="0.0000"/>
<column xsi:type="decimal" name="total_income_amount" scale="12" precission="4" unsigned="false"
nullable="false" default="'0.0000'"/>
nullable="false" default="0.0000"/>
<column xsi:type="decimal" name="total_revenue_amount" scale="12" precission="4" unsigned="false"
nullable="false" default="'0.0000'"/>
nullable="false" default="0.0000"/>
<column xsi:type="decimal" name="total_profit_amount" scale="12" precission="4" unsigned="false"
nullable="false" default="'0.0000'"/>
nullable="false" default="0.0000"/>
<column xsi:type="decimal" name="total_invoiced_amount" scale="12" precission="4" unsigned="false"
nullable="false" default="'0.0000'"/>
nullable="false" default="0.0000"/>
<column xsi:type="decimal" name="total_canceled_amount" scale="12" precission="4" unsigned="false"
nullable="false" default="'0.0000'"/>
nullable="false" default="0.0000"/>
<column xsi:type="decimal" name="total_paid_amount" scale="12" precission="4" unsigned="false" nullable="false"
default="'0.0000'"/>
default="0.0000"/>
<column xsi:type="decimal" name="total_refunded_amount" scale="12" precission="4" unsigned="false"
nullable="false" default="'0.0000'"/>
nullable="false" default="0.0000"/>
<column xsi:type="decimal" name="total_tax_amount" scale="12" precission="4" unsigned="false" nullable="false"
default="'0.0000'"/>
default="0.0000"/>
<column xsi:type="decimal" name="total_tax_amount_actual" scale="12" precission="4" unsigned="false"
nullable="false" default="'0.0000'"/>
nullable="false" default="0.0000"/>
<column xsi:type="decimal" name="total_shipping_amount" scale="12" precission="4" unsigned="false"
nullable="false" default="'0.0000'"/>
nullable="false" default="0.0000"/>
<column xsi:type="decimal" name="total_shipping_amount_actual" scale="12" precission="4" unsigned="false"
nullable="false" default="'0.0000'"/>
nullable="false" default="0.0000"/>
<column xsi:type="decimal" name="total_discount_amount" scale="12" precission="4" unsigned="false"
nullable="false" default="'0.0000'"/>
nullable="false" default="0.0000"/>
<column xsi:type="decimal" name="total_discount_amount_actual" scale="12" precission="4" unsigned="false"
nullable="false" default="'0.0000'"/>
nullable="false" default="0.0000"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
Expand Down
14 changes: 7 additions & 7 deletions app/code/Magento/SalesRule/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,19 @@
<column xsi:type="varchar" name="order_status" nullable="true" length="50"/>
<column xsi:type="varchar" name="coupon_code" nullable="true" length="50"/>
<column xsi:type="int" name="coupon_uses" padding="11" unsigned="false" nullable="false" identity="false"
default="'0'"/>
default="0"/>
<column xsi:type="decimal" name="subtotal_amount" scale="12" precission="4" unsigned="false" nullable="false"
default="'0.0000'"/>
default="0.0000"/>
<column xsi:type="decimal" name="discount_amount" scale="12" precission="4" unsigned="false" nullable="false"
default="'0.0000'"/>
default="0.0000"/>
<column xsi:type="decimal" name="total_amount" scale="12" precission="4" unsigned="false" nullable="false"
default="'0.0000'"/>
default="0.0000"/>
<column xsi:type="decimal" name="subtotal_amount_actual" scale="12" precission="4" unsigned="false"
nullable="false" default="'0.0000'"/>
nullable="false" default="0.0000"/>
<column xsi:type="decimal" name="discount_amount_actual" scale="12" precission="4" unsigned="false"
nullable="false" default="'0.0000'"/>
nullable="false" default="0.0000"/>
<column xsi:type="decimal" name="total_amount_actual" scale="12" precission="4" unsigned="false"
nullable="false" default="'0.0000'"/>
nullable="false" default="0.0000"/>
<column xsi:type="varchar" name="rule_name" nullable="true" length="255"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Tax/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
<column xsi:type="varchar" name="order_status" nullable="false" length="50"/>
<column xsi:type="float" name="percent" scale="10" precission="0" unsigned="false" nullable="true"/>
<column xsi:type="int" name="orders_count" padding="11" unsigned="true" nullable="false" identity="false"
default="'0'"/>
default="0"/>
<column xsi:type="float" name="tax_base_amount_sum" scale="10" precission="0" unsigned="false" nullable="true"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<xs:complexType name="boolean">
<xs:attributeGroup ref="baseColumn" />
<xs:attribute name="default" type="xs:boolean" />
<xs:attribute name="nullable" type="xs:boolean" />
</xs:complexType>
</xs:schema>
6 changes: 3 additions & 3 deletions setup/src/Magento/Setup/Model/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ private function handleDBSchemaData($setup, $type)
$upgradeType = $type . '-upgrade';
$moduleNames = $this->moduleList->getNames();
$moduleContextList = $this->generateListOfModuleContext($resource, $verType);
if ($type !== 'schema') {
#if ($type !== 'schema') {
foreach ($moduleNames as $moduleName) {
$this->schemaListener->setModuleName($moduleName);
$this->log->log("Module '{$moduleName}':");
Expand Down Expand Up @@ -914,10 +914,10 @@ private function handleDBSchemaData($setup, $type)
}
$this->logProgress();
}
}
#}

//Before recurring generate schema
//$this->schemaPersistor->persist($this->schemaListener);
$this->schemaPersistor->persist($this->schemaListener);
if ($type === 'schema') {
$this->log->log('Schema post-updates:');
$handlerType = 'schema-recurring';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function convertToDefinition(array $definition)
'precission' => $definition['scale'] ?? self::DEFAULT_SCALE,
'unsigned' => $definition['unsigned'] ?? false,
'nullable' => $definition['nullable'] ?? true,
'default' => $definition['default'] ?? null,
'default' => isset($definition['default']) ? (int) $definition['default'] : null,
'primary' => $definition['primary'] ?? false
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ class IntegerDefinition implements DefinitionConverterInterface
'bigint' => 20
];

/**
* @var BooleanDefinition
*/
private $booleanDefinition;

/**
* IntegerDefinition constructor.
* @param BooleanDefinition $booleanDefinition
*/
public function __construct(BooleanDefinition $booleanDefinition)
{
$this->booleanDefinition = $booleanDefinition;
}

/**
* @inheritdoc
*/
Expand All @@ -32,14 +46,19 @@ public function convertToDefinition(array $definition)
$definition['type'] = 'int';
}

if (isset($definition['padding']) && $definition['padding'] == 1) {
$definition['type'] = 'boolean';
return $this->booleanDefinition->convertToDefinition($definition);
}

return [
'xsi:type' => $definition['type'],
'name' => $definition['name'],
'padding' => $definition['length'] ?? self::$lengthDefaults[$definition['type']],
'unsigned' => $definition['unsigned'] ?? false,
'nullable' => $definition['nullable'] ?? true,
'identity' => $definition['identity'] ?? false,
'default' => $definition['default'] ?? null,
'default' => isset($definition['default']) ? (int) $definition['default'] : null,
'primary' => $definition['primary'] ?? false
];
}
Expand Down

0 comments on commit 86fb388

Please sign in to comment.