20200430170235_MigrationToolsTokens.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. use Migrations\AbstractMigration;
  3. class MigrationToolsTokens extends AbstractMigration {
  4. /**
  5. * Change Method.
  6. *
  7. * More information on this method is available here:
  8. * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
  9. *
  10. * @return void
  11. */
  12. public function change() {
  13. $this->table('tokens')
  14. ->addColumn('user_id', 'integer', [
  15. 'limit' => null,
  16. 'null' => true,
  17. ])
  18. ->addColumn('type', 'string', [
  19. 'comment' => 'e.g.:activate,reactivate',
  20. 'default' => null,
  21. 'limit' => 20,
  22. 'null' => false,
  23. ])
  24. ->addColumn('token_key', 'string', [
  25. 'default' => null,
  26. 'limit' => 60,
  27. 'null' => false,
  28. ])
  29. ->addColumn('content', 'string', [
  30. 'comment' => 'can transport some information',
  31. 'default' => null,
  32. 'limit' => 255,
  33. 'null' => true,
  34. ])
  35. ->addColumn('used', 'integer', [
  36. 'default' => 0,
  37. 'limit' => null,
  38. 'null' => false,
  39. ])
  40. ->addColumn('created', 'datetime', [
  41. 'default' => null,
  42. 'limit' => null,
  43. 'null' => true,
  44. ])
  45. ->addColumn('modified', 'datetime', [
  46. 'default' => null,
  47. 'limit' => null,
  48. 'null' => true,
  49. ])
  50. ->addIndex(['user_id'])
  51. ->addIndex(['token_key'], ['unique' => true])
  52. ->create();
  53. }
  54. }