From c41d2d25236c576aa6815c1e3cfa04e840355dbc Mon Sep 17 00:00:00 2001 From: forge-bot Date: Tue, 14 Jul 2026 04:34:14 +0000 Subject: [PATCH] =?UTF-8?q?=EC=86=8C=EC=8A=A4=20=EC=9D=B8=EB=B2=A4?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EA=B5=AC=EC=A1=B0=20=EB=B6=84=EC=84=9D=20?= =?UTF-8?q?(iss-bfacccaabbd5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source-inventory/DB_SCHEMA.md | 78 +++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 source-inventory/DB_SCHEMA.md diff --git a/source-inventory/DB_SCHEMA.md b/source-inventory/DB_SCHEMA.md new file mode 100644 index 0000000..a48219d --- /dev/null +++ b/source-inventory/DB_SCHEMA.md @@ -0,0 +1,78 @@ +# Database Schema + +## Entity: User + +### Table Definition + +```sql +CREATE TABLE users ( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + username VARCHAR(50) NOT NULL UNIQUE, + email VARCHAR(100) NOT NULL UNIQUE, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); +``` + +### Column Details + +| Column | Type | Constraints | Description | +|--------|------|-------------|-------------| +| id | BIGINT | PRIMARY KEY, AUTO_INCREMENT | Unique identifier | +| username | VARCHAR(50) | NOT NULL, UNIQUE | User's unique username | +| email | VARCHAR(100) | NOT NULL, UNIQUE | User's email address | +| created_at | TIMESTAMP | DEFAULT CURRENT_TIMESTAMP | Record creation time | +| updated_at | TIMESTAMP | DEFAULT CURRENT_TIMESTAMP ON UPDATE | Last update time | + +### Indexes + +| Index Name | Column | Type | Description | +|------------|--------|------|-------------| +| idx_username | username | UNIQUE | Fast username lookup | +| idx_email | email | UNIQUE | Fast email lookup | + +### Entity Relationships + +``` +User (standalone entity, no foreign keys) +``` + +### JPA Entity Mapping + +```java +@Entity +@Table(name = "users") +public class User { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(nullable = false, unique = true, length = 50) + private String username; + + @Column(nullable = false, unique = true, length = 100) + private String email; + + @Column(name = "created_at", updatable = false) + private LocalDateTime createdAt; + + @Column(name = "updated_at") + private LocalDateTime updatedAt; +} +``` + +### Database Support + +| Environment | Database | Driver | +|-------------|----------|--------| +| Development | H2 (In-Memory) | org.h2.Driver | +| Test | H2 (In-Memory) | org.h2.Driver | +| Production | MySQL 8.x | com.mysql.cj.jdbc.Driver | +| Production | PostgreSQL 15+ | org.postgresql.Driver | + +### Migration Strategy + +- **Development**: Auto DDL (Hibernate) +- **Production**: Flyway Migration Scripts + - Location: `src/main/resources/db/migration/` + - Naming: `V{version}__{description}.sql`