20250704030421_extension_filesystem_cagegory.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. use Phinx\Migration\AbstractMigration;
  3. use think\migration\db\Column;
  4. class ExtensionFilesystemCagegory 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(): void
  28. {
  29. $table = $this->table('extension_filesystem_category', [
  30. 'comment' => '文件分类表',
  31. 'engine' => 'InnoDB',
  32. 'collation' => 'utf8mb4_general_ci',
  33. 'id' => false,
  34. 'primary_key' => 'id'
  35. ]);
  36. $table->addColumn('id', 'integer', [
  37. 'identity' => true,
  38. 'signed' => false,
  39. 'comment' => '主键'
  40. ])->addColumn('name', 'string', [
  41. 'limit' => 100,
  42. 'null' => false,
  43. 'comment' => '名称'
  44. ])->addColumn('parent_id', 'integer', [
  45. 'signed' => false,
  46. 'null' => true,
  47. 'default' => 0,
  48. 'comment' => '父级ID'
  49. ])->addColumn('level', 'integer', [
  50. 'signed' => false,
  51. 'null' => false,
  52. 'default' => 0,
  53. 'comment' => '层级'
  54. ])->addColumn('sort', 'integer', [
  55. 'signed' => false,
  56. 'null' => false,
  57. 'default' => 0,
  58. 'comment' => '排序'
  59. ])->addColumn('file_count', 'integer',[
  60. 'signed' => false,
  61. 'null' => false,
  62. 'default' => 0,
  63. 'comment' => '文件数量'
  64. ])->addTimestamps()
  65. ->addSoftDelete()
  66. ->create();
  67. }
  68. }