| 1234567891011121314151617 |
- <?php
- declare(strict_types=1);
- use Phinx\Migration\AbstractMigration;
- final class AddSaleItemTable extends AbstractMigration {
- public function change(): void {
- $this->table("sale_item", ["signed" => false])
- ->addColumn("sale_id", "integer", ["signed" => false])
- ->addColumn("product_id", "integer", ["signed" => false])
- ->addColumn("quantity", "integer", ["signed" => false])
- ->addColumn("unit_price", "decimal", ["precision" => 11, "scale" => 2])
- ->addForeignKey("sale_id", "sale", "id", ["update" => "CASCADE", "delete" => "CASCADE"])
- ->addForeignKey("product_id", "product", "id", ["update" => "CASCADE", "delete" => "RESTRICT"])
- ->create();
- }
- }
|