20260108033628_filesystem_user_file.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. declare(strict_types=1);
  3. use Phinx\Migration\AbstractMigration;
  4. final class FilesystemUserFile extends AbstractMigration
  5. {
  6. /**
  7. * Change Method.
  8. *
  9. * Write your reversible migrations using this method.
  10. *
  11. * More information on writing migrations is available here:
  12. * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
  13. *
  14. * Remember to call "create()" or "update()" and NOT "save()" when working
  15. * with the Table class.
  16. */
  17. public function change(): void
  18. {
  19. $table = $this->table('filesystem_user_file', [
  20. 'comment' => '文件表',
  21. 'engine' => 'InnoDB',
  22. 'collation' => 'utf8mb4_general_ci',
  23. 'id' => false,
  24. 'primary_key' => 'id'
  25. ]);
  26. $table
  27. ->addColumn('id', 'integer', [
  28. 'identity' => true,
  29. 'signed' => false,
  30. 'comment' => '主键'
  31. ])
  32. ->addColumn('user_id', 'integer', [
  33. 'default' => 0,
  34. 'signed' => false,
  35. 'comment' => '用户id'
  36. ])
  37. ->addColumn('file_hash', 'string', [
  38. 'default' => '',
  39. 'comment' => '文件hash'
  40. ])->addColumn('name', 'string', [
  41. 'default' => '',
  42. 'comment' => '文件备注名称'
  43. ])->addColumn('file_name', 'string', [
  44. 'default' => '',
  45. 'comment' => '文件名'
  46. ])->addColumn('file_path', 'string', [
  47. 'default' => '',
  48. 'comment' => '文件路径'
  49. ])->addColumn('file_size', 'integer', [
  50. 'default' => 0,
  51. 'comment' => '文件大小'
  52. ])->addColumn('file_ext', 'string', [
  53. 'default' => '',
  54. 'comment' => '文件类型'
  55. ])->addColumn('file_mine', 'string', [
  56. 'default' => '',
  57. 'comment' => '文件MIME'
  58. ])->addColumn('file_url', 'string', [
  59. 'default' => '',
  60. 'comment' => '文件URL'
  61. ])->addTimestamps('create_time', 'update_time')
  62. ->addColumn('delete_time', 'timestamp', [
  63. 'null' => true,
  64. 'comment' => '删除时间'
  65. ])->addIndex('file_hash', [
  66. 'name' => 'file_hash'
  67. ])->create();
  68. }
  69. }