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.

35 lines
790B

  1. <?php
  2. use yii\db\Migration;
  3. use yii\db\Schema;
  4. /**
  5. * Class m240619_195454_create_table_accessory
  6. */
  7. class m240619_195454_create_table_accessory extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $this->createTable('accessory', [
  15. 'id' => 'pk',
  16. 'id_producer' => Schema::TYPE_INTEGER.' NOT NULl',
  17. 'name' => Schema::TYPE_STRING.' NOT NULl',
  18. 'quantity' => Schema::TYPE_INTEGER
  19. ]);
  20. $this->addForeignKey('fk_accessory_id_producer', 'accessory', 'id_producer', 'producer', 'id');
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function safeDown()
  26. {
  27. $this->dropTable('accessory');
  28. $this->dropForeignKey('fk_accessory_id_producer', 'accessory');
  29. }
  30. }