You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

m240603_131331_create_table_shared_point_sale.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use yii\db\Migration;
  3. use yii\db\Schema;
  4. /**
  5. * Class m240603_131331_create_table_shared_point_sale
  6. */
  7. class m240603_131331_create_table_shared_point_sale extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $this->createTable('shared_point_sale', [
  15. 'id' => 'pk',
  16. 'id_point_sale' => Schema::TYPE_INTEGER,
  17. 'id_producer_with_sharing' => Schema::TYPE_INTEGER,
  18. 'id_point_sale_with_sharing' => Schema::TYPE_INTEGER,
  19. 'status' => Schema::TYPE_INTEGER,
  20. ]);
  21. $this->addForeignKey('fk_id_point_sale', 'shared_point_sale', 'id_point_sale', 'point_sale', 'id');
  22. $this->addForeignKey('fk_id_producer', 'shared_point_sale', 'id_producer_with_sharing', 'producer', 'id');
  23. $this->addForeignKey('fk_id_point_sale_with_sharing', 'shared_point_sale', 'id_point_sale_with_sharing', 'point_sale', 'id');
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function safeDown()
  29. {
  30. $this->dropTable('shared_point_sale');
  31. $this->dropForeignKey('fk_id_point_sale', 'shared_point_sale');
  32. $this->dropForeignKey('fk_id_producer', 'shared_point_sale');
  33. $this->dropForeignKey('fk_id_point_sale_with_sharing', 'shared_point_sale');
  34. }
  35. }