| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- declare(strict_types=1);
- use Phinx\Db\Adapter\MysqlAdapter;
- use Phinx\Migration\AbstractMigration;
- final class AddDocumentTable extends AbstractMigration {
- public function change(): void {
- $this->table("document", ["signed" => false])
- ->addColumn("user_id", "integer", ["signed" => false])
- ->addColumn("sale_id", "integer", ["signed" => false, "null" => true])
- ->addColumn("supplier_id", "integer", ["signed" => false, "null" => true])
- ->addColumn("location_id", "integer", ["signed" => false, "null" => true])
- ->addColumn("related_document_id", "integer", ["signed" => false, "null" => true])
- ->addColumn("type", "integer", ["signed" => false, "limit" => MysqlAdapter::INT_TINY])
- ->addColumn("invoice_status", "integer", ["signed" => false, "limit" => MysqlAdapter::INT_TINY, "null" => true])
- ->addColumn("currency", "string", ["limit" => 3, "null" => true])
- ->addColumn("tax_rate", "decimal", ["precision" => 5, "scale" => 2, "null" => true])
- ->addColumn("billing_address", "string", ["null" => true])
- ->addColumn("delivery_address", "string", ["null" => true])
- ->addColumn("number", "integer", ["signed" => false, "null" => true])
- ->addColumn("date", "date", ["null" => true])
- ->addColumn("po_number", "string", ["null" => true])
- ->addColumn("terms", "string", ["null" => true])
- ->addColumn("delivery_company", "string", ["null" => true])
- ->addColumn("tracking_number", "string", ["null" => true])
- ->addColumn("delivery_cost", "string", ["null" => true])
- ->addColumn("notes", "text", ["null" => true])
- ->addColumn("dts_finalised", "datetime", ["null" => true])
- ->addColumn("dts_paid", "datetime", ["null" => true])
- ->addColumn("dts_created", "datetime")
- ->addColumn("dts_updated", "datetime", ["null" => true])
- ->addColumn("dts_deleted", "datetime", ["null" => true])
- ->addForeignKey("user_id", "user", "id", ["update" => "CASCADE", "delete" => "RESTRICT"])
- ->addForeignKey("sale_id", "sale", "id", ["update" => "CASCADE", "delete" => "CASCADE"])
- ->addForeignKey("supplier_id", "supplier", "id", ["update" => "CASCADE", "delete" => "RESTRICT"])
- ->addForeignKey("location_id", "location", "id", ["update" => "CASCADE", "delete" => "RESTRICT"])
- ->addForeignKey("related_document_id", "document", "id", ["update" => "CASCADE", "delete" => "CASCADE"])
- ->create();
- }
- }
|