88 lines
2.2 KiB
PHP
88 lines
2.2 KiB
PHP
|
<?php
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
use Migrations\BaseMigration;
|
||
|
|
||
|
class CreateProductPhotos 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_photos', ['id' => false, 'primary_key' => ['id']]);
|
||
|
$table->addColumn('id', 'uuid', [
|
||
|
'default' => null,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
$table->addColumn('product_id', 'uuid', [
|
||
|
'default' => null,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
$table->addColumn('product_sku_id', 'uuid', [
|
||
|
'default' => null,
|
||
|
'null' => true,
|
||
|
]);
|
||
|
|
||
|
$table->addColumn('photo_dir', 'text', [
|
||
|
'default' => null,
|
||
|
'length' => 255,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
$table->addColumn('photo_filename', 'string', [
|
||
|
'default' => null,
|
||
|
'length' => 255,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
|
||
|
$table->addColumn('primary_photo', 'boolean', [
|
||
|
'default' => false,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
|
||
|
$table->addColumn('photo_position', 'integer', [
|
||
|
'default' => 100,
|
||
|
'limit' => 11,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
|
||
|
$table->addColumn('enabled', 'boolean', [
|
||
|
'default' => false,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
|
||
|
$table->addColumn('created', 'datetime', [
|
||
|
'default' => null,
|
||
|
'null' => false,
|
||
|
]);
|
||
|
$table->addColumn('modified', 'datetime', [
|
||
|
'default' => null,
|
||
|
'null' => true,
|
||
|
]);
|
||
|
$table->addColumn('deleted', 'datetime', [
|
||
|
'default' => null,
|
||
|
'null' => true,
|
||
|
]);
|
||
|
|
||
|
$table->addIndex([
|
||
|
'product_id',
|
||
|
], [
|
||
|
'name' => 'PRODUCT_PHOTOS_BY_PRODUCT_ID',
|
||
|
'unique' => false,
|
||
|
]);
|
||
|
$table->addIndex([
|
||
|
'product_sku_id',
|
||
|
], [
|
||
|
'name' => 'PRODUCT_PHOTOS_BY_PRODUCT_SKU_ID',
|
||
|
'unique' => true,
|
||
|
]);
|
||
|
|
||
|
$table->create();
|
||
|
}
|
||
|
}
|