Introduction

ROQ One Backend uses TypeORM to access the database. The entire schema is described in the entity-classes that you find in each module. Here, all fields are listed. The database-types and other meta-information are added using the @Column decorator:

@Column({ nullable: true, type: 'varchar' })
name?: string;
TYPESCRIPT

Relations are declared using a decorator like @OneToMany:

@OneToMany(() => BookEntity, (book) => book.author)
books: BookEntity[];
TYPESCRIPT

All of this information is parsed by the TypeORM migration script and compiled into SQL migration scripts which you can find in the /backend/src/migration directory of ROQ One.

To lean more about TypeORM entities and migrations we recommend to read the official documentation of 📖 TypeORM

Migration script

The migration script can be executed with:

npm run migration:local:run
CODE

This script is also automatically executed when you install ROQ One locally, see Local installation guide

If you got the error

Error during migration run:
TypeORMError: No connection options were found in any orm configuration files.
CODE

it means that the filer ormconfig.json is missing. Please create the configuration files with the following command and then run the migration command again.

npm run migration:local:config
CODE

TypeORM offers to synchronize all changes directly to the database. During development you can activate this in the root module file backend/src/app.module.ts:

synchronize: true,
TYPESCRIPT