20250704031150_extension_filesystem_file.php 2.8 KB

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