first commit

This commit is contained in:
2026-01-15 22:38:46 +03:00
commit a70e9b7a79
58 changed files with 3980 additions and 0 deletions

35
docs/api-schema.md Normal file
View File

@@ -0,0 +1,35 @@
# Schema API
Schema helpers let you create and update tables programmatically.
## Example: create table
```java
import com.andrewkydev.database.schema.ColumnSpec;
import com.andrewkydev.database.schema.IndexSpec;
import com.andrewkydev.database.schema.TableSpec;
TableSpec table = TableSpec.builder("players")
.column(ColumnSpec.builder("id", "BIGINT").primaryKey(true).autoIncrement(true).nullable(false).build())
.column(ColumnSpec.builder("name", "VARCHAR(32)").nullable(false).build())
.index(new IndexSpec("players_name_idx", java.util.Arrays.asList("name"), false))
.build();
api.schema().createTable(table);
```
## API Methods
```java
api.schema().createDatabase("primalix");
api.schema().dropDatabase("primalix");
api.schema().createTable(spec);
api.schema().dropTable("players");
api.schema().addColumn("players", ColumnSpec.builder("level", "INT").build());
api.schema().updateColumn("players", ColumnSpec.builder("level", "INT").nullable(false).build());
api.schema().dropColumn("players", "level");
api.schema().addIndex("players", new IndexSpec("players_name_idx", java.util.Arrays.asList("name"), false));
api.schema().dropIndex("players", "players_name_idx");
```
All methods also have async variants returning `CompletableFuture`.