diff --git a/backend/migrations/2026_03_09_110000_modify_users_add_role_fk_and_api_key_enabled.php b/backend/migrations/2026_03_09_110000_modify_users_add_role_fk_and_api_key_enabled.php new file mode 100644 index 0000000..304c01c --- /dev/null +++ b/backend/migrations/2026_03_09_110000_modify_users_add_role_fk_and_api_key_enabled.php @@ -0,0 +1,30 @@ +boolean('api_key_enabled')->default(false)->comment('是否允许使用 API Key'); + $table->foreign('role_id')->references('id')->on('roles')->onDelete('restrict'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropForeign(['role_id']); + $table->dropColumn('api_key_enabled'); + }); + } +};