product variants table split off from category variants table, variant values table updated to reflect
This commit is contained in:
62
config/Migrations/20250922045018_CreateProductVariants.php
Normal file
62
config/Migrations/20250922045018_CreateProductVariants.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
class CreateProductVariants extends BaseMigration
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* More information on this method is available here:
|
||||
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
$table = $this->table('product_variants', ['id' => false, 'primary_key' => ['id']]);
|
||||
$table->addColumn('id', 'uuid', [
|
||||
'default' => null,
|
||||
'null' => false,
|
||||
]);
|
||||
$table->addColumn('name', 'string', [
|
||||
'default' => null,
|
||||
'limit' => 255,
|
||||
'null' => false,
|
||||
]);
|
||||
$table->addColumn('product_category_variant_id', 'uuid', [
|
||||
'default' => null,
|
||||
'null' => true,
|
||||
]);
|
||||
$table->addColumn('product_id', 'uuid', [
|
||||
'default' => null,
|
||||
'null' => false,
|
||||
]);
|
||||
$table->addColumn('enabled', 'boolean', [
|
||||
'default' => null,
|
||||
'null' => false,
|
||||
]);
|
||||
$table->addIndex([
|
||||
'product_category_variant_id',
|
||||
], [
|
||||
'name' => 'VARIANTS_BY_PARENT_PRODUCT_CATEGORY_VARIANT_ID',
|
||||
'unique' => false,
|
||||
]);
|
||||
$table->addIndex([
|
||||
'product_id',
|
||||
], [
|
||||
'name' => 'VARIANTS_BY_PRODUCT_ID',
|
||||
'unique' => false,
|
||||
]);
|
||||
|
||||
// $table->addIndex([
|
||||
// 'name',
|
||||
// 'product_category_id',
|
||||
// ], [
|
||||
// 'name' => 'VARIANTS_BY_NAME_AND_PRODUCT_CATEGORY_ID_UNIQUE',
|
||||
// 'unique' => true,
|
||||
// ]);
|
||||
$table->create();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user