20250704031150_extension_filesystem_file.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. declare(strict_types=1);
  3. use Phinx\Migration\AbstractMigration;
  4. class ExtensionFilesystemFile 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. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  13. *
  14. * The following commands can be used in this method and Phinx will
  15. * automatically reverse them when rolling back:
  16. *
  17. * createTable
  18. * renameTable
  19. * addColumn
  20. * renameColumn
  21. * addIndex
  22. * addForeignKey
  23. *
  24. * Remember to call "create()" or "update()" and NOT "save()" when working
  25. * with the Table class.
  26. */
  27. public function change()
  28. {
  29. $table = $this->table('extension_filesystem_file', [
  30. 'comment' => '文件表',
  31. 'engine' => 'InnoDB',
  32. 'collation' => 'utf8mb4_general_ci',
  33. 'id' => false,
  34. 'primary_key' => 'id'
  35. ]);
  36. $table
  37. ->addColumn('id', 'integer', [
  38. 'identity' => true,
  39. 'signed' => false,
  40. 'comment' => '主键'
  41. ])
  42. ->addColumn('category_id', 'integer', [
  43. 'default' => 0,
  44. 'signed' => false,
  45. 'comment' => '分类id'
  46. ])
  47. ->addColumn('file_hash', 'string', [
  48. 'default' => '',
  49. 'comment' => '文件hash'
  50. ])->addColumn('name', 'string', [
  51. 'default' => '',
  52. 'comment' => '文件备注名称'
  53. ])->addColumn('file_name', 'string', [
  54. 'default' => '',
  55. 'comment' => '文件名'
  56. ])->addColumn('file_path', 'string', [
  57. 'default' => '',
  58. 'comment' => '文件路径'
  59. ])->addColumn('file_size', 'integer', [
  60. 'default' => 0,
  61. 'comment' => '文件大小'
  62. ])->addColumn('file_ext', 'string', [
  63. 'default' => '',
  64. 'comment' => '文件类型'
  65. ])->addColumn('file_mine', 'string', [
  66. 'default' => '',
  67. 'comment' => '文件MIME'
  68. ])->addColumn('file_url', 'string', [
  69. 'default' => '',
  70. 'comment' => '文件URL'
  71. ])->addColumn('create_time', 'datetime', [
  72. 'null' => true,
  73. 'comment' => '创建时间'
  74. ])->addColumn('update_time', 'datetime', [
  75. 'null' => true,
  76. 'comment' => '更新时间'
  77. ])->addColumn('delete_time', 'datetime', [
  78. 'null' => true,
  79. 'comment' => '删除时间'
  80. ])->addIndex('file_hash', [
  81. 'name' => 'file_hash'
  82. ])->create();
  83. }
  84. }