| 123456789101112131415161718192021222324 |
- <?php
- declare(strict_types=1);
- use Phinx\Db\Adapter\MysqlAdapter;
- use Phinx\Migration\AbstractMigration;
- final class AddSaleTable extends AbstractMigration {
- public function change(): void {
- $this->table("sale", ["signed" => false])
- ->addColumn("company_id", "integer", ["signed" => false])
- ->addColumn("location_id", "integer", ["signed" => false])
- ->addColumn("user_id", "integer", ["signed" => false])
- ->addColumn("status", "integer", ["signed" => false, "limit" => MysqlAdapter::INT_TINY])
- ->addColumn("currency", "string", ["limit" => 3])
- ->addColumn("tax_rate", "decimal", ["precision" => 5, "scale" => 2, "default" => "20.00"])
- ->addColumn("dts_created", "datetime")
- ->addColumn("dts_updated", "datetime", ["null" => true])
- ->addColumn("dts_deleted", "datetime", ["null" => true])
- ->addForeignKey("company_id", "company", "id", ["update" => "CASCADE", "delete" => "RESTRICT"])
- ->addForeignKey("location_id", "location", "id", ["update" => "CASCADE", "delete" => "RESTRICT"])
- ->addForeignKey("user_id", "user", "id", ["update" => "CASCADE", "delete" => "RESTRICT"])
- ->create();
- }
- }
|