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.

2020-02-22-222222_example_migration.php 1.1KB

2 vuotta sitten
12345678910111213141516171819202122232425262728293031323334353637
  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. }