first commit
This commit is contained in:
30
docs/orm-schema.md
Normal file
30
docs/orm-schema.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# ORM Schema Generation
|
||||
|
||||
`OrmSchema` builds a `TableSpec` from annotated entities.
|
||||
|
||||
## Example
|
||||
|
||||
```java
|
||||
import com.andrewkydev.database.orm.OrmSchema;
|
||||
import com.andrewkydev.database.schema.SqlDialect;
|
||||
import com.andrewkydev.database.schema.TableSpec;
|
||||
|
||||
TableSpec spec = OrmSchema.fromEntity(PlayerModel.class, SqlDialect.MYSQL);
|
||||
api.schema().createTable(spec);
|
||||
```
|
||||
|
||||
## Type Mapping
|
||||
|
||||
Default mapping (when `@DbColumn(type = "...")` is not specified):
|
||||
|
||||
- `String` -> `VARCHAR(length)`
|
||||
- `int`/`Integer` -> `INT`
|
||||
- `long`/`Long` -> `BIGINT`
|
||||
- `short`/`Short` -> `SMALLINT`
|
||||
- `boolean`/`Boolean` -> `BOOLEAN` (PostgreSQL) or `TINYINT(1)` (MySQL)
|
||||
- `float`/`Float` -> `FLOAT`
|
||||
- `double`/`Double` -> `DOUBLE`
|
||||
- `UUID` -> `UUID` (PostgreSQL) or `CHAR(36)` (MySQL)
|
||||
- `@DbJson` -> `JSON` (MySQL) or `JSONB` (PostgreSQL)
|
||||
|
||||
`@DbColumn(length, unique, nullable)` is also applied.
|
||||
Reference in New Issue
Block a user