20221211230900_gift_card_table.php 1.1 KB

123456789101112131415161718192021222324252627282930
  1. <?php
  2. declare(strict_types=1);
  3. use Phinx\Migration\AbstractMigration;
  4. final class GiftCardTable extends AbstractMigration
  5. {
  6. public function up(): void
  7. {
  8. if (! $this->hasTable('gift_card')) {
  9. $this->table('gift_card', [ 'id' => false, 'primary_key' => [ 'id' ]])
  10. ->addColumn('id', 'biginteger', [ 'identity' => true,'signed' => false ])
  11. ->addColumn('card', 'text', ['comment' => '卡号'])
  12. ->addColumn('balance', 'integer', ['comment' => '余额'])
  13. ->addColumn('create_time', 'integer', ['comment' => '创建时间'])
  14. ->addColumn('status', 'integer', ['comment' => '使用状态'])
  15. ->addColumn('use_time', 'integer', ['comment' => '使用时间'])
  16. ->addColumn('use_user', 'integer', ['comment' => '使用用户'])
  17. ->addIndex([ 'id' ])
  18. ->addIndex([ 'status' ])
  19. ->create();
  20. }
  21. }
  22. public function down(): void
  23. {
  24. $this->table('gift_card')->drop()->update();
  25. }
  26. }