4 changed files with 236 additions and 0 deletions
@ -0,0 +1,59 @@ |
|||
# MySQL Database Migration Guide |
|||
|
|||
This guide will help you manage MySQL database migrations using the migration scripts. |
|||
|
|||
## Prerequisites |
|||
|
|||
1. Ensure .NET Core SDK is installed |
|||
2. Ensure Entity Framework Core tools are installed |
|||
```powershell |
|||
dotnet tool install --global dotnet-ef |
|||
``` |
|||
3. Ensure MySQL connection string is properly configured |
|||
|
|||
## Usage Instructions |
|||
|
|||
### 1. Create New Migration |
|||
|
|||
1. Run the migration script in the `aspnet-core/migrations` directory: |
|||
```powershell |
|||
# Use English version |
|||
.\MigrateEn.ps1 |
|||
|
|||
# Or use Chinese version |
|||
.\Migrate.ps1 |
|||
``` |
|||
|
|||
2. Select MySQL database context from the menu: |
|||
``` |
|||
[1] LY.MicroService.Applications.Single.EntityFrameworkCore.MySql |
|||
``` |
|||
|
|||
3. Enter migration name (optional): |
|||
- Press Enter to use default name: `AddNewMigration_yyyyMMdd_HHmmss` |
|||
- Or enter custom name, e.g.: `AddNewFeature` |
|||
|
|||
### 2. Generate SQL Script |
|||
|
|||
After creating the migration, the script will ask if you want to generate SQL script: |
|||
|
|||
1. Choose whether to generate SQL script (Y/N) |
|||
2. If Y is selected, following options will be available: |
|||
- `[A]` - Generate SQL script for all migrations |
|||
- `[L]` - Generate SQL script for latest migration only |
|||
- `[0-9]` - Generate from specified migration version |
|||
|
|||
Generated SQL scripts will be saved in: |
|||
``` |
|||
aspnet-core/InitSql/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/ |
|||
``` |
|||
|
|||
### 3. Apply Migration |
|||
|
|||
Generated SQL scripts can be applied to database through: |
|||
|
|||
1. Using MySQL client tools to execute SQL script directly |
|||
2. Or using command line: |
|||
```powershell |
|||
mysql -u your_username -p your_database < your_script.sql |
|||
``` |
|||
@ -0,0 +1,59 @@ |
|||
# MySQL 数据库迁移指南 |
|||
|
|||
本指南将帮助您使用迁移脚本来管理 MySQL 数据库的迁移操作。 |
|||
|
|||
## 前置条件 |
|||
|
|||
1. 确保已安装 .NET Core SDK |
|||
2. 确保已安装 Entity Framework Core 工具 |
|||
```powershell |
|||
dotnet tool install --global dotnet-ef |
|||
``` |
|||
3. 确保已正确配置 MySQL 连接字符串 |
|||
|
|||
## 使用说明 |
|||
|
|||
### 1. 创建新的迁移 |
|||
|
|||
1. 在 `aspnet-core/migrations` 目录下运行迁移脚本: |
|||
```powershell |
|||
# 使用中文版本 |
|||
.\Migrate.ps1 |
|||
|
|||
# 或使用英文版本 |
|||
.\MigrateEn.ps1 |
|||
``` |
|||
|
|||
2. 在菜单中选择 MySQL 数据库上下文: |
|||
``` |
|||
[1] LY.MicroService.Applications.Single.EntityFrameworkCore.MySql |
|||
``` |
|||
|
|||
3. 输入迁移名称(可选): |
|||
- 直接回车将使用默认名称:`AddNewMigration_yyyyMMdd_HHmmss` |
|||
- 或输入自定义名称,如:`AddNewFeature` |
|||
|
|||
### 2. 生成 SQL 脚本 |
|||
|
|||
在创建迁移后,脚本会询问是否需要生成 SQL 脚本: |
|||
|
|||
1. 选择是否生成 SQL 脚本 (Y/N) |
|||
2. 如果选择 Y,将提供以下选项: |
|||
- `[A]` - 生成所有迁移的 SQL 脚本 |
|||
- `[L]` - 仅生成最新迁移的 SQL 脚本 |
|||
- `[0-9]` - 从指定的迁移版本开始生成 |
|||
|
|||
生成的 SQL 脚本将保存在: |
|||
``` |
|||
aspnet-core/InitSql/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/ |
|||
``` |
|||
|
|||
### 3. 应用迁移 |
|||
|
|||
生成的 SQL 脚本可以通过以下方式应用到数据库: |
|||
|
|||
1. 使用 MySQL 客户端工具直接执行 SQL 脚本 |
|||
2. 或使用命令行: |
|||
```powershell |
|||
mysql -u your_username -p your_database < your_script.sql |
|||
``` |
|||
@ -0,0 +1,59 @@ |
|||
# PostgreSQL Database Migration Guide |
|||
|
|||
This guide will help you manage PostgreSQL database migrations using the migration scripts. |
|||
|
|||
## Prerequisites |
|||
|
|||
1. Ensure .NET Core SDK is installed |
|||
2. Ensure Entity Framework Core tools are installed |
|||
```powershell |
|||
dotnet tool install --global dotnet-ef |
|||
``` |
|||
3. Ensure PostgreSQL connection string is properly configured |
|||
|
|||
## Usage Instructions |
|||
|
|||
### 1. Create New Migration |
|||
|
|||
1. Run the migration script in the `aspnet-core/migrations` directory: |
|||
```powershell |
|||
# Use English version |
|||
.\MigrateEn.ps1 |
|||
|
|||
# Or use Chinese version |
|||
.\Migrate.ps1 |
|||
``` |
|||
|
|||
2. Select PostgreSQL database context from the menu: |
|||
``` |
|||
[2] LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql |
|||
``` |
|||
|
|||
3. Enter migration name (optional): |
|||
- Press Enter to use default name: `AddNewMigration_yyyyMMdd_HHmmss` |
|||
- Or enter custom name, e.g.: `AddNewFeature` |
|||
|
|||
### 2. Generate SQL Script |
|||
|
|||
After creating the migration, the script will ask if you want to generate SQL script: |
|||
|
|||
1. Choose whether to generate SQL script (Y/N) |
|||
2. If Y is selected, following options will be available: |
|||
- `[A]` - Generate SQL script for all migrations |
|||
- `[L]` - Generate SQL script for latest migration only |
|||
- `[0-9]` - Generate from specified migration version |
|||
|
|||
Generated SQL scripts will be saved in: |
|||
``` |
|||
aspnet-core/InitSql/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/ |
|||
``` |
|||
|
|||
### 3. Apply Migration |
|||
|
|||
Generated SQL scripts can be applied to database through: |
|||
|
|||
1. Using pgAdmin or other PostgreSQL client tools to execute SQL script |
|||
2. Or using command line: |
|||
```bash |
|||
psql -U your_username -d your_database -f your_script.sql |
|||
``` |
|||
@ -0,0 +1,59 @@ |
|||
# PostgreSQL 数据库迁移指南 |
|||
|
|||
本指南将帮助您使用迁移脚本来管理 PostgreSQL 数据库的迁移操作。 |
|||
|
|||
## 前置条件 |
|||
|
|||
1. 确保已安装 .NET Core SDK |
|||
2. 确保已安装 Entity Framework Core 工具 |
|||
```powershell |
|||
dotnet tool install --global dotnet-ef |
|||
``` |
|||
3. 确保已正确配置 PostgreSQL 连接字符串 |
|||
|
|||
## 使用说明 |
|||
|
|||
### 1. 创建新的迁移 |
|||
|
|||
1. 在 `aspnet-core/migrations` 目录下运行迁移脚本: |
|||
```powershell |
|||
# 使用中文版本 |
|||
.\Migrate.ps1 |
|||
|
|||
# 或使用英文版本 |
|||
.\MigrateEn.ps1 |
|||
``` |
|||
|
|||
2. 在菜单中选择 PostgreSQL 数据库上下文: |
|||
``` |
|||
[2] LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql |
|||
``` |
|||
|
|||
3. 输入迁移名称(可选): |
|||
- 直接回车将使用默认名称:`AddNewMigration_yyyyMMdd_HHmmss` |
|||
- 或输入自定义名称,如:`AddNewFeature` |
|||
|
|||
### 2. 生成 SQL 脚本 |
|||
|
|||
在创建迁移后,脚本会询问是否需要生成 SQL 脚本: |
|||
|
|||
1. 选择是否生成 SQL 脚本 (Y/N) |
|||
2. 如果选择 Y,将提供以下选项: |
|||
- `[A]` - 生成所有迁移的 SQL 脚本 |
|||
- `[L]` - 仅生成最新迁移的 SQL 脚本 |
|||
- `[0-9]` - 从指定的迁移版本开始生成 |
|||
|
|||
生成的 SQL 脚本将保存在: |
|||
``` |
|||
aspnet-core/InitSql/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/ |
|||
``` |
|||
|
|||
### 3. 应用迁移 |
|||
|
|||
生成的 SQL 脚本可以通过以下方式应用到数据库: |
|||
|
|||
1. 使用 pgAdmin 或其他 PostgreSQL 客户端工具执行 SQL 脚本 |
|||
2. 或使用命令行: |
|||
```bash |
|||
psql -U your_username -d your_database -f your_script.sql |
|||
``` |
|||
Loading…
Reference in new issue