Supports database migration #760
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This document details the usage of the
migrate:sqlite-to-dbArtisan 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.envconfiguration.Here's the detailed breakdown of the tool:
1. 交互式选择(推荐)
如果你不确定或想每次都选择,直接运行命令,它会提示你:
2. 直接指定目标数据库
如果你确定目标数据库类型,可以使用
--target选项:php artisan migrate:sqlite-to-db --target=mysql # 或 php artisan migrate:sqlite-to-db --target=pgsql3. 生产环境运行
在生产环境中运行此命令需要添加
--force选项:php artisan migrate:sqlite-to-db --force # 或 php artisan migrate:sqlite-to-db --target=mysql --force重要提示:
migrate:fresh,这意味着它会删除目标数据库中的所有表并重新创建它们。sudo systemctl restart nginx sudo systemctl restart php8.1-fpm # 使用您的 PHP 版本