m240202_224554_cliente.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. use yii\db\Migration;
  3. /**
  4. * Class m240202_224554_cliente
  5. */
  6. class m240202_224554_cliente extends Migration
  7. {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. public function safeUp()
  12. {
  13. $this->createTable('Agencia', [
  14. "idAgencia" => $this->primaryKey(),
  15. "id" => $this->integer(),
  16. "nombre" => $this->string(50),
  17. "direccion" => $this->string(20),
  18. "contacto" => $this->string(255),
  19. "descripcion" => $this->string(255),
  20. "clave" => $this->integer(),
  21. "idUsuarioCreador" => $this->integer(),
  22. "creado" => $this->timestamp() . " with time zone",
  23. "modificado" => $this->timestamp() . " with time zone",
  24. "eliminado" => $this->timestamp() . " with time zone",
  25. ]);
  26. $this->addColumn('Usuario', 'idAgencia', $this->integer()->null());
  27. $this->addForeignKey('UsuarioIdAgenciaFK', 'Usuario', 'idAgencia', 'Agencia', 'idAgencia');
  28. $this->addForeignKey('AgenciaIdUsuarioFK', 'Agencia', 'id', 'Usuario', 'id');
  29. }
  30. public function safeDown()
  31. {
  32. $this->dropForeignKey('UsuarioIdAgenciaFK', 'Usuario');
  33. $this->dropForeignKey('AgenciaIdUsuarioFK', 'Agencia');
  34. $this->dropTable("Agencia");
  35. $this->dropColumn("Usuario", "idAgencia");
  36. }
  37. }