upsert_attribute
Create a new attribute or update an existing one in an ERD, setting primary key, auto-increment, data type, nullability, uniqueness, or default value. Domain can dictate data type.
Instructions
Creates an attribute (no attributeId, logicalName required) or updates one (attributeId given, only provided fields change). primaryKey=true forces nullable=false and propagates child FKs. With a domain, the domain decides the data type. autoIncrement marks the column as identity — exported as AUTO_INCREMENT (mysql/cubrid/h2), IDENTITY(1,1) (sqlserver), or GENERATED BY DEFAULT AS IDENTITY (postgres/oracle); it applies to primary keys only.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | No | ||
| source | Yes | Target ERD — exactly one of a local file ({file}) or a server ERD ({erdId}) | |
| unique | No | ||
| dataType | No | ||
| entityId | Yes | ||
| nullable | No | ||
| primaryKey | No | ||
| attributeId | No | ||
| logicalName | No | ||
| defaultValue | No | Raw SQL default, emitted verbatim after DEFAULT — quote it yourself for string/date literals: "'N'" not "N". Unquoted values are treated as SQL expressions (`0`, `CURRENT_TIMESTAMP`), so a bare word becomes an identifier reference and produces invalid DDL. | |
| autoIncrement | No |