Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

53 lines
1.6KB

  1. <?php
  2. use yii\db\Migration;
  3. use yii\db\Schema;
  4. /**
  5. * Class m230717_120138_module_ticket
  6. */
  7. class m230717_120138_module_ticket extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $this->createTable('ticket', [
  15. 'id' => 'pk',
  16. 'id_producer' => Schema::TYPE_INTEGER.' NOT NULL',
  17. 'id_user' => Schema::TYPE_INTEGER.' NOT NULL',
  18. 'subject' => Schema::TYPE_STRING.' NOT NULL',
  19. 'status' => Schema::TYPE_STRING.' NOT NULL',
  20. 'created_at' => Schema::TYPE_DATETIME.' NOT NULL DEFAULT CURRENT_TIMESTAMP',
  21. 'updated_at' => Schema::TYPE_DATETIME.' NOT NULL DEFAULT CURRENT_TIMESTAMP'
  22. ]);
  23. $this->createTable('ticket_message', [
  24. 'id' => 'pk',
  25. 'id_ticket' => Schema::TYPE_INTEGER.' NOT NULL',
  26. 'id_user' => Schema::TYPE_INTEGER.' NOT NULL',
  27. 'message' => Schema::TYPE_TEXT.' NOT NULL',
  28. 'created_at' => Schema::TYPE_DATETIME.' NOT NULL DEFAULT CURRENT_TIMESTAMP',
  29. 'updated_at' => Schema::TYPE_DATETIME.' NOT NULL DEFAULT CURRENT_TIMESTAMP',
  30. ]);
  31. $this->createTable('ticket_user', [
  32. 'id' => 'pk',
  33. 'id_user' => Schema::TYPE_INTEGER.' NOT NULL',
  34. 'id_ticket' => Schema::TYPE_INTEGER.' NOT NULL',
  35. 'read_at' => Schema::TYPE_DATETIME.' NOT NULL DEFAULT CURRENT_TIMESTAMP',
  36. ]);
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function safeDown()
  42. {
  43. $this->dropTable('ticket');
  44. $this->dropTable('ticket_message');
  45. $this->dropTable('ticket_user');
  46. }
  47. }