CakeCarts/config/Migrations/20251008093507_CreateCarts.php

115 lines
3.2 KiB
PHP

<?php
declare(strict_types=1);
use Migrations\BaseMigration;
class CreateCarts 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('carts', ['id' => false, 'primary_key' => ['id']]);
$table->addColumn('id', 'uuid', [
'default' => null,
'null' => false,
]);
$table->addColumn('cart_type_id', 'integer', [
'default' => null,
'limit' => 11,
'null' => false,
]);
$table->addColumn('session_id', 'string', [
'default' => null,
'null' => true,
]);
$table->addColumn('user_id', 'integer', [
'default' => null,
'limit' => 11,
'null' => true,
]);
$table->addColumn('user_id_uuid', 'uuid', [
'default' => null,
'null' => true,
]);
$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->addColumn('removed', 'datetime', [
'default' => null,
'null' => true,
]);
$table->addColumn('removed_reason_id', 'integer', [
'default' => null,
'limit' => 11,
'null' => true,
]);
$table->addColumn('num_items', 'integer', [
'default' => 0,
'null' => false,
]);
$table->create();
$table = $this->table('cart_items', ['id' => false, 'primary_key' => ['id']]);
$table->addColumn('id', 'uuid', [
'default' => null,
'null' => false,
]);
$table->addColumn('foreign_key', 'integer', [
'default' => null,
'null' => true,
]);
$table->addColumn('foreign_key_uuid', 'uuid', [
'default' => null,
'null' => true,
]);
$table->addColumn('model', 'string', [
'default' => null,
'limit' => 255,
'null' => false,
]);
$table->addColumn('cart_id', 'uuid', [
'default' => null,
'null' => false,
]);
$table->addColumn('position', 'integer', [
'default' => null,
'limit' => 11,
'null' => true,
]);
$table->addColumn('qty', 'integer', [
'default' => null,
'limit' => 11,
'null' => false,
]);
$table->addColumn('price', 'decimal', [
'default' => null,
'null' => true,
'precision' => 13,
'scale' => 5,
]);
$table->addColumn('subtotal', 'decimal', [
'default' => null,
'null' => true,
'precision' => 13,
'scale' => 5,
]);
$table->create();
}
}