bring into standalone plugin for distribution
This commit is contained in:
47
config/Migrations/20241114090547_CreateProducts.php
Normal file
47
config/Migrations/20241114090547_CreateProducts.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Migrations\AbstractMigration;
|
||||
|
||||
class CreateProducts extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* More information on this method is available here:
|
||||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
$table = $this->table('products', ['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_id', 'uuid', [
|
||||
'default' => null,
|
||||
'null' => false,
|
||||
]);
|
||||
$table->addColumn('product_type_id', 'integer', [
|
||||
'default' => null,
|
||||
'limit' => 11,
|
||||
'null' => false,
|
||||
]);
|
||||
$table->addIndex('product_category_id');
|
||||
$table->addIndex('product_type_id');
|
||||
$table->addIndex([
|
||||
'product_category_id',
|
||||
'name',
|
||||
], [
|
||||
'name' => 'BY_NAME_AND_CATEGORY_ID',
|
||||
'unique' => true,
|
||||
]);
|
||||
$table->create();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user