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.

48 lines
1.4KB

  1. <?php
  2. use yii\db\Migration;
  3. /**
  4. * Class m220817_074240_add_foreign_keys_documents
  5. */
  6. class m220817_074240_add_foreign_keys_documents extends Migration
  7. {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. public function safeUp()
  12. {
  13. $this->createIndex('user_fk', 'delivery_note', ['id_user']);
  14. $this->createIndex('producer_fk', 'delivery_note', ['id_producer']);
  15. $this->createIndex('user_fk', 'quotation', ['id_user']);
  16. $this->createIndex('producer_fk', 'quotation', ['id_producer']);
  17. $this->createIndex('user_fk', 'invoice', ['id_user']);
  18. $this->createIndex('producer_fk', 'invoice', ['id_producer']);
  19. $this->createIndex('delivery_note_fk', 'order', ['id_delivery_note']);
  20. $this->createIndex('quotation_fk', 'order', ['id_quotation']);
  21. $this->createIndex('invoice_fk', 'order', ['id_invoice']);
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function safeDown()
  27. {
  28. $this->dropIndex('user_fk', 'delivery_note');
  29. $this->dropIndex('producer_fk', 'delivery_note');
  30. $this->dropIndex('user_fk', 'quotation');
  31. $this->dropIndex('producer_fk', 'quotation');
  32. $this->dropIndex('user_fk', 'invoice');
  33. $this->dropIndex('producer_fk', 'invoice');
  34. $this->dropIndex('delivery_note_fk', 'order');
  35. $this->dropIndex('quotation_fk', 'order');
  36. $this->dropIndex('invoice_fk', 'order');
  37. }
  38. }