Skip to content

Supports database migration#760

Open
hi1king wants to merge 1 commit into
cedar2025:masterfrom
hi1king:master
Open

Supports database migration#760
hi1king wants to merge 1 commit into
cedar2025:masterfrom
hi1king:master

Conversation

@hi1king

@hi1king hi1king commented Dec 3, 2025

Copy link
Copy Markdown

This document details the usage of the migrate:sqlite-to-db Artisan command, which provides a robust and interactive way to migrate data from a SQLite database to a specified relational database (MySQL or PostgreSQL). It handles schema migration, data transfer, and updates your .env configuration.

Here's the detailed breakdown of the tool:

1. 交互式选择(推荐)

如果你不确定或想每次都选择,直接运行命令,它会提示你:

php artisan migrate:sqlite-to-db

2. 直接指定目标数据库

如果你确定目标数据库类型,可以使用 --target 选项:

php artisan migrate:sqlite-to-db --target=mysql
#
php artisan migrate:sqlite-to-db --target=pgsql

3. 生产环境运行

在生产环境中运行此命令需要添加 --force 选项:

php artisan migrate:sqlite-to-db --force
#
php artisan migrate:sqlite-to-db --target=mysql --force

重要提示:

  • 运行此命令前,请确保目标数据库服务器正在运行,并且您已创建了一个空的数据库。
  • 此命令会运行 migrate:fresh,这意味着它会删除目标数据库中的所有表并重新创建它们。
  • 完成迁移后,请务必重启您的 Web 服务器和 PHP-FPM 进程,以使新的数据库配置生效。例如:
    sudo systemctl restart nginx
    sudo systemctl restart php8.1-fpm # 使用您的 PHP 版本

@JxQg

JxQg commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

LGTM +

@cedar2025

Copy link
Copy Markdown
Owner

感谢你的 PR!虽然这个 PR 暂时不会被合并,但它的内容可能会对其他人有所帮助,非常感谢你的贡献。

rebecca554owen added a commit to rebecca554owen/xboard that referenced this pull request Jul 10, 2026
PR cedar2025#760 from hi1king. Adds an interactive Artisan command to migrate
data from SQLite to MySQL/PostgreSQL with .env backup and progress bar.

Security review: no SQL injection, no command injection, passwords use
secret() input, migrate:fresh documented as destructive.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants