Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

38 lines
1.1KB

  1. <?php
  2. namespace Tests\Support\Database\Migrations;
  3. use CodeIgniter\Database\Migration;
  4. class ExampleMigration extends Migration
  5. {
  6. protected $DBGroup = 'tests';
  7. public function up()
  8. {
  9. $this->forge->addField('id');
  10. $this->forge->addField([
  11. 'name' => ['type' => 'varchar', 'constraint' => 31],
  12. 'uid' => ['type' => 'varchar', 'constraint' => 31],
  13. 'class' => ['type' => 'varchar', 'constraint' => 63],
  14. 'icon' => ['type' => 'varchar', 'constraint' => 31],
  15. 'summary' => ['type' => 'varchar', 'constraint' => 255],
  16. 'created_at' => ['type' => 'datetime', 'null' => true],
  17. 'updated_at' => ['type' => 'datetime', 'null' => true],
  18. 'deleted_at' => ['type' => 'datetime', 'null' => true],
  19. ]);
  20. $this->forge->addKey('name');
  21. $this->forge->addKey('uid');
  22. $this->forge->addKey(['deleted_at', 'id']);
  23. $this->forge->addKey('created_at');
  24. $this->forge->createTable('factories');
  25. }
  26. public function down()
  27. {
  28. $this->forge->dropTable('factories');
  29. }
  30. }