Browse Source

feat(filesystem): 添加文件系统用户文件表结构

runphp 2 months ago
parent
commit
b7c60e3de7
1 changed files with 72 additions and 0 deletions
  1. 72 0
      database/migrations/20260108033628_filesystem_user_file.php

+ 72 - 0
database/migrations/20260108033628_filesystem_user_file.php

@@ -0,0 +1,72 @@
+<?php
+
+declare(strict_types=1);
+
+use Phinx\Migration\AbstractMigration;
+
+final class FilesystemUserFile extends AbstractMigration
+{
+    /**
+     * Change Method.
+     *
+     * Write your reversible migrations using this method.
+     *
+     * More information on writing migrations is available here:
+     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
+     *
+     * Remember to call "create()" or "update()" and NOT "save()" when working
+     * with the Table class.
+     */
+    public function change(): void
+    {
+        $table = $this->table('extension_filesystem_file', [
+            'comment' => '文件表',
+            'engine' => 'InnoDB',
+            'collation' => 'utf8mb4_general_ci',
+            'id' => false,
+            'primary_key' => 'id'
+        ]);
+        $table
+            ->addColumn('id', 'integer', [
+                'identity' => true,
+                'signed' => false,
+                'comment' => '主键'
+            ])
+            ->addColumn('user_id', 'integer', [
+                'default' => 0,
+                'signed' => false,
+                'comment' => '用户id'
+            ])
+            ->addColumn('file_hash', 'string', [
+                'default' => '',
+                'comment' => '文件hash'
+            ])->addColumn('name', 'string', [
+                'default' => '',
+                'comment' => '文件备注名称'
+            ])->addColumn('file_name', 'string', [
+                'default' => '',
+                'comment' => '文件名'
+            ])->addColumn('file_path', 'string', [
+                'default' => '',
+                'comment' => '文件路径'
+            ])->addColumn('file_size', 'integer', [
+                'default' => 0,
+                'comment' => '文件大小'
+            ])->addColumn('file_ext', 'string', [
+                'default' => '',
+                'comment' => '文件类型'
+            ])->addColumn('file_mine', 'string', [
+                'default' => '',
+                'comment' => '文件MIME'
+            ])->addColumn('file_url', 'string', [
+                'default' => '',
+                'comment' => '文件URL'
+            ])->addTimestamps('create_time', 'update_time')
+            ->addColumn('delete_time', 'timestamp', [
+                'null' => true,
+                'comment' => '删除时间'
+            ])->addIndex('file_hash', [
+                'name' => 'file_hash'
+            ])->create();
+    }
+}