What a Database records#
| Field | Content |
|---|---|
name·engine | Name and engine. Required |
handle | Web address name. Required; unique among the Databases of the same Organization, and structures is not allowed (see address names) |
summary·description | One-line summary and description |
relational_options | database_name for the five RDBs |
redis_options | Redis mode (standalone, cluster, sentinel), db_index, master_name, and connection_alias |
cassandra_options | Cassandra keyspace_name |
external_references | Code and external document sources |
engine is one of postgresql, mysql, mariadb, oracle, sqlserver, mongodb, redis, and cassandra.
Connection addresses and credentials are not recorded.
Web UI#
In Datastores → 새 Database (New Database), enter the engine and name, then select Database 등록 (Register Database). On the Database detail, add the structures for its engine (새 Table, 새 Collection, 새 Key Pattern, or 새 Cassandra Table).
On the detail of any of the five RDB Databases, ERD 보기 (View ERD) shows the reference structure of its Tables and recorded Foreign Keys on a wide screen. Targets not found in the same Database appear as dashed unregistered Tables, references recorded without an actual DB Constraint appear as dotted lines marked DB Constraint 없음 (no DB Constraint), and cardinality is not shown. Selecting a Table highlights it and the Tables that directly reference it or that it references; this state stays in the address, so you can share it as a link.
Structures#
| engine | Structure | stly resource | Create option |
|---|---|---|---|
| PostgreSQL, MySQL, MariaDB, Oracle, Microsoft SQL Server | Table | tables | --database <id> |
| MongoDB | Collection | collections | --database <id> |
| Redis | Key Pattern | key-patterns | --database <id> |
| Cassandra | Table | cassandra-tables | --database <id> |
You can list a summary of the structures of all Databases at once.
stly databases structuresPostgreSQL example#
{"name": "orders-db", "handle": "orders-db", "engine": "postgresql", "summary": "Production DB for the orders Service", "relational_options": {"database_name": "orders"}}stly databases create --input database.jsonA Table holds its Columns, Primary Key, Unique Keys, Foreign Keys, and Indexes in definition. Send empty items as empty arrays.
{
"name": "orders",
"namespace": "public",
"summary": "Basic order information",
"definition": {
"columns": [
{"name": "id", "data_type": "uuid", "nullable": false, "default_expression": null, "description": "Order ID"},
{"name": "status", "data_type": "text", "nullable": false, "default_expression": "'pending'", "description": "Order status"}
],
"primary_key": {"name": "orders_pkey", "columns": ["id"]},
"unique_keys": [],
"foreign_keys": [],
"indexes": []
}
}stly tables validate --operation create --database 1Zvw5jZYaAM --input table.json
stly tables create --database 1Zvw5jZYaAM --input table.json
stly tables list --database 1Zvw5jZYaAM --fields id,namespace,namenamespace is the Schema name for PostgreSQL, Oracle, and SQL Server, and an empty string for MySQL and MariaDB.
References without an actual DB Constraint#
A Foreign Key's constraint_in_database records whether that Constraint exists in the actual DB. true means it exists, false means it does not, and null means not recorded; omitting it means null.
Record a reference that only application code or an ORM uses, with no FOREIGN KEY Constraint in the actual DB, as false instead of in a Column description, and it appears in the ERD.
With false, send name, on_delete, and on_update as null, and put evidence such as the code location you checked in description. Structly does not connect to the actual DB or run DDL.
{"name": null, "columns": ["user_id"], "target": {"namespace": "public", "table_name": "users", "columns": ["id"]}, "on_delete": null, "on_update": null, "constraint_in_database": false, "description": "Source: order-api/internal/entity/order.go"}Redis example#
{"name": "session-cache", "handle": "session-cache", "engine": "redis", "summary": "Session cache", "redis_options": {"mode": "standalone", "db_index": 0}}A Key Pattern records a ${variable} template, variable descriptions, the value structure, and TTL. Each variable in the template needs exactly one description in variables.
{
"template": "session:${session_id}",
"summary": "Login session",
"definition": {
"variables": [{"name": "session_id", "description": "Session ID"}],
"value": {"type": "string", "structure": {"encoding": "json", "description": "Session information as JSON"}},
"ttl": {"mode": "fixed", "seconds": 1209600, "description": "14 days"}
}
}stly key-patterns create --database 8vuXCuVcMBb --input key-pattern.jsonThe value type is one of string, hash, list, set, sorted_set, and stream, and each type has a different structure. Check them with stly schema key-patterns create.
You can move a Key Pattern to another Redis Database in the same Organization. stly looks up the latest detail and changes only the Database it belongs to. Actual Redis keys are not moved.
stly key-patterns move <key-pattern-id> --database <destination Database ID> --dry-run
stly key-patterns move <key-pattern-id> --database <destination Database ID>For MongoDB Collection and Cassandra Table input, see stly schema collections create and stly schema cassandra-tables create.
Service connections#
Connect the Services that use a Database or each of its structures (Key Pattern, Table, Collection, or Cassandra Table). For a shared Database, you can record which Services use each structure. In the Web UI, edit them in 연결 Service (Connected Services) on the detail. Database connections are not applied to its structures automatically.
stly databases service-links get <database-id>
stly databases service-links update <database-id> --input links.json --if-match '"ETag from the connection lookup"'
stly key-patterns service-links update <key-pattern-id> --input links.json --if-match '"ETag from the connection lookup"'
stly tables service-links update <table-id> --input links.json --if-match '"ETag from the connection lookup"'collections and cassandra-tables use the same service-links get|update commands.
links.json uses the format {"service_ids": ["Service ID"]}, and [] removes all connections. Connections are kept when a structure is moved to another Database.
Delete#
A Database cannot be deleted while it has structures or Service connections (HTTP 409 DATABASE_IN_USE). A structure with Service connections cannot be deleted either (HTTP 409 KEY_PATTERN_IN_USE, TABLE_IN_USE, COLLECTION_IN_USE, or CASSANDRA_TABLE_IN_USE). Delete the structures and remove the connections first.