Skip to main content

Project schema overview

Contember project schema defines schema of your model, ACL and validation rules.

Model schema

First let's look at the model schema, which is now the most important for us.


Make sure you have SchemaDefinition imported in each file

import { SchemaDefinition as def } from "@contember/schema-definition"


Basic unit in model schema is called entity. Each entity can have fields. There are two kind of fields - columns holding a value and relationships to other entities.

Each entity is represented as a PostgreSQL table.

You define an entity by exporting a class from the schema definition file

export class Post {}

You don't have to define a primary key, because every entity has "id" column by default.


See columns chapter.


Allow you to set relationship between different entities. See relationships chapter.

ACL schema

Defines user roles with permissions. For details see dedicated ACL chapter

Validation schema

Allows you to set additional validation constraints on GraphQL input. See input validations


If you make a change in your project schema, you must create and apply a migration