Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ This allows the Amplify team to maintain and enhance the SQL Layer without needi
| integer | a.integer() |
| bigint | a.integer() |
| tinyint | a.integer() |
| serial* | a.integer().default() |
| float | a.float() |
| double | a.float() |
| decimal | a.float() |
Expand All @@ -429,6 +430,8 @@ This allows the Amplify team to maintain and enhance the SQL Layer without needi
| json | a.json() |
| enum | a.enum() |

*Support for auto increment (serial) fields is limited to PostgreSQL datasources.

## Troubleshooting

### Debug Mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ const schema = a.schema({
}),
}).authorization((allow) => allow.publicApiKey());
```

If you're working with a Postgres datasource, `.default()` can be applied to integer fields to represent [serial fields](/[platform]/build-a-backend/data/connect-to-existing-data-sources/connect-postgres-mysql-database/#mapping-of-sql-data-types-to-field-types-for-auto-generated-schema).

<Callout>
**Note:** The `.default(...)` modifier can't be applied to required fields.
</Callout>
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ print("New Todo created: \(createdTodo)")
</InlineFilter>

If you want, you can use Amplify Data to define single-field and composite identifiers:
- Single-field identifier with a consumer-provided value (type: `id` or `string`, and must be marked `required`)
- Composite identifier with a set of consumer-provided values (type: `id` or `string`, and must be marked `required`)
- Single-field identifier with a consumer-provided value (type: `id` or `string` marked `required`, or for a [serial identifier](/[platform]/build-a-backend/data/data-modeling/add-fields/#assign-default-values-for-fields), type: `integer` marked `default`)
- Composite identifier with a set of consumer-provided values (type: `id` or `string` marked `required`, or for a [serial identifier](/[platform]/build-a-backend/data/data-modeling/add-fields/#assign-default-values-for-fields), type: `integer` marked `default`)

## Single-field identifier

Expand Down