feat(docs): Add database migration instructions and Neon setup details

- Introduced comprehensive sections on database migrations in the README files for English and Vietnamese documentation, including prerequisites, migration creation, and application steps.
- Added instructions for setting up the Neon database, including connection string configuration in `appsettings.Development.json`.
- Updated the `appsettings.Development.json` file with a default connection string for the Neon database and added Redis configuration.
- Included additional EF Core commands for managing migrations in the Vietnamese documentation.
This commit is contained in:
Ho Ngoc Hai
2026-01-12 17:52:35 +07:00
parent 9168a5f734
commit 435e5c2dfa
6 changed files with 154 additions and 10 deletions

6
NOTE.MD Normal file
View File

@@ -0,0 +1,6 @@
⚠️ Còn Thiếu (Tùy chọn mở rộng)
- Authorization Code Flow - Cho OAuth2 web apps
- Role/Permission Management APIs - CRUD roles
- Email Verification - Confirm email
- 2FA/MFA - Two-factor authentication
- Social Login - Google, Facebook, etc.

View File

@@ -53,6 +53,45 @@ dotnet build
dotnet run --project src/IamService.API
```
## Database Migrations
### Prerequisites
```bash
# Install EF Core tools (one-time)
dotnet tool install --global dotnet-ef
```
### Create Migration
```bash
dotnet ef migrations add <MigrationName> \
--project src/IamService.Infrastructure \
--startup-project src/IamService.API
```
### Apply Migration
```bash
dotnet ef database update \
--project src/IamService.Infrastructure \
--startup-project src/IamService.API
```
### Neon Database Setup
1. Create database on [Neon Console](https://console.neon.tech)
2. Copy connection string
3. Update `appsettings.Development.json`:
```json
{
"ConnectionStrings": {
"DefaultConnection": "Host=<host>;Port=5432;Database=<db>;Username=<user>;Password=<pass>;SSL Mode=Require"
}
}
```
4. Run migrations: `dotnet ef database update ...`
## API Endpoints
### Authentication (`/api/v1/auth`)

View File

@@ -55,6 +55,37 @@ dotnet build
dotnet run --project src/IamService.API
```
## Database Migrations
### Prerequisites
```bash
# Install EF Core tools (one-time)
dotnet tool install --global dotnet-ef
```
### Create Migration
```bash
dotnet ef migrations add <MigrationName> \
--project src/IamService.Infrastructure \
--startup-project src/IamService.API
```
### Apply Migration
```bash
dotnet ef database update \
--project src/IamService.Infrastructure \
--startup-project src/IamService.API
```
### Neon Database Setup
1. Create database on [Neon Console](https://console.neon.tech)
2. Update `appsettings.Development.json` with connection string
3. Run: `dotnet ef database update ...`
## API Endpoints
### Authentication (`/api/v1/auth`)

View File

@@ -39,6 +39,67 @@ dotnet build
dotnet run --project src/IamService.API
```
## Database Migrations
### Yêu Cầu
```bash
# Cài đặt EF Core tools (một lần)
dotnet tool install --global dotnet-ef
```
### Tạo Migration
```bash
# Tạo migration mới
dotnet ef migrations add <TenMigration> \
--project src/IamService.Infrastructure \
--startup-project src/IamService.API
```
### Áp Dụng Migration
```bash
# Áp dụng migrations vào database
dotnet ef database update \
--project src/IamService.Infrastructure \
--startup-project src/IamService.API
```
### Các Lệnh Khác
```bash
# Xóa migration cuối (nếu chưa áp dụng)
dotnet ef migrations remove \
--project src/IamService.Infrastructure \
--startup-project src/IamService.API
# Tạo SQL script
dotnet ef migrations script \
--project src/IamService.Infrastructure \
--startup-project src/IamService.API \
--output migrations.sql
# Liệt kê migrations
dotnet ef migrations list \
--project src/IamService.Infrastructure \
--startup-project src/IamService.API
```
### Thiết Lập Neon Database
1. Tạo database trên [Neon Console](https://console.neon.tech)
2. Sao chép connection string
3. Cập nhật `appsettings.Development.json`:
```json
{
"ConnectionStrings": {
"DefaultConnection": "Host=<host>;Port=5432;Database=<db>;Username=<user>;Password=<pass>;SSL Mode=Require"
}
}
```
4. Chạy migrations: `dotnet ef database update ...`
## API Endpoints
### Authentication (`/api/v1/auth`)

View File

@@ -17,6 +17,10 @@
<!-- EN: FluentValidation for request validation / VI: FluentValidation cho validation request -->
<PackageReference Include="FluentValidation" Version="11.11.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.11.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<!-- EN: Swagger/OpenAPI / VI: Swagger/OpenAPI -->
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />

View File

@@ -3,17 +3,20 @@
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore": "Information",
"Microsoft.EntityFrameworkCore.Database.Command": "Information"
"Microsoft.EntityFrameworkCore": "Information"
}
},
"Serilog": {
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Information",
"Microsoft.EntityFrameworkCore.Database.Command": "Information",
"System": "Information"
}
}
"ConnectionStrings": {
"DefaultConnection": "Host=ep-holy-glitter-a4hongg7-pooler.us-east-1.aws.neon.tech;Port=5432;Database=iam_service;Username=neondb_owner;Password=npg_Ssfy6HKO0cXI;SSL Mode=Require"
},
"Redis": {
"ConnectionString": "localhost:6379"
},
"Jwt": {
"Secret": "goodgo-iam-service-secret-key-32chars!",
"Issuer": "goodgo-platform",
"Audience": "goodgo-services",
"AccessTokenExpiryMinutes": 15,
"RefreshTokenExpiryDays": 7
}
}