20221219192033_add_sale_table.php 1.1 KB

123456789101112131415161718192021222324
  1. <?php
  2. declare(strict_types=1);
  3. use Phinx\Db\Adapter\MysqlAdapter;
  4. use Phinx\Migration\AbstractMigration;
  5. final class AddSaleTable extends AbstractMigration {
  6. public function change(): void {
  7. $this->table("sale", ["signed" => false])
  8. ->addColumn("company_id", "integer", ["signed" => false])
  9. ->addColumn("location_id", "integer", ["signed" => false])
  10. ->addColumn("user_id", "integer", ["signed" => false])
  11. ->addColumn("status", "integer", ["signed" => false, "limit" => MysqlAdapter::INT_TINY])
  12. ->addColumn("currency", "string", ["limit" => 3])
  13. ->addColumn("tax_rate", "decimal", ["precision" => 5, "scale" => 2, "default" => "20.00"])
  14. ->addColumn("dts_created", "datetime")
  15. ->addColumn("dts_updated", "datetime", ["null" => true])
  16. ->addColumn("dts_deleted", "datetime", ["null" => true])
  17. ->addForeignKey("company_id", "company", "id", ["update" => "CASCADE", "delete" => "RESTRICT"])
  18. ->addForeignKey("location_id", "location", "id", ["update" => "CASCADE", "delete" => "RESTRICT"])
  19. ->addForeignKey("user_id", "user", "id", ["update" => "CASCADE", "delete" => "RESTRICT"])
  20. ->create();
  21. }
  22. }