20221219201955_add_sale_item_table.php 676 B

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