Foreign key for "Category" is missing on "Product"

Хочу сделать так, чтобы одному значению category соответствовало много значений product, но получаю вот такую ошибку, когда запускаю приложение

[Nest] 18012  - 07.09.2024, 00:37:22   ERROR [SequelizeModule] Unable to connect to the database. Retrying (8)...
Error: Foreign key for "Category" is missing on "Product".
    at getForeignKeyOptions (D:\HTML\flowers_shop\server\node_modules\sequelize-typescript\dist\associations\foreign-key\foreign-key-service.js:24:15)
    at HasAssociation.getSequelizeOptions (D:\HTML\flowers_shop\server\node_modules\sequelize-typescript\dist\associations\has\has-association.js:18:77)
    at D:\HTML\flowers_shop\server\node_modules\sequelize-typescript\dist\sequelize\sequelize\sequelize.js:51:45
    at Array.forEach (<anonymous>)
    at D:\HTML\flowers_shop\server\node_modules\sequelize-typescript\dist\sequelize\sequelize\sequelize.js:50:26
    at Array.forEach (<anonymous>)
    at Sequelize.associateModels (D:\HTML\flowers_shop\server\node_modules\sequelize-typescript\dist\sequelize\sequelize\sequelize.js:46:16)
    at Sequelize.addModels (D:\HTML\flowers_shop\server\node_modules\sequelize-typescript\dist\sequelize\sequelize\sequelize.js:38:14)
    at D:\HTML\flowers_shop\server\node_modules\@nestjs\sequelize\dist\sequelize-core.module.js:118:23
    at Observable._subscribe (D:\HTML\flowers_shop\server\node_modules\rxjs\src\internal\observable\defer.ts:55:15)

Код из products.model.ts:

import { ApiProperty } from "@nestjs/swagger";
import { BelongsTo, Column, DataType, ForeignKey, Model, Table } from "sequelize-typescript";
import { Category } from "src/Categories/categories.model";

interface ProductCreationAttribute {
    name: string
    price: number
    sku: number
    image: string
}

@Table({ tableName: 'products' })
export class Product extends Model<Product, ProductCreationAttribute> {

    @ApiProperty({ example: '1',  description: 'Уникальный идентификатор' })
    @Column({ type: DataType.INTEGER, unique: true, autoIncrement: true, primaryKey: true })
    id: number
    
    @ApiProperty({ example: 'Розы', description: 'Наименование товара' })
    @Column({ type: DataType.STRING, allowNull: false})
    name: string

    @ApiProperty({ example: '1000', description: 'Стоимость товара' })
    @Column({ type: DataType.INTEGER, allowNull: false})
    price: number

    @ApiProperty({ example: '1234', description: 'Уникальный артикул товара' })
    @Column({ type: DataType.INTEGER, unique: true, allowNull: false})
    sku: number

    @ApiProperty({ example: 'rose.jpg', description: 'Название изображения товара' })
    @Column({ type: DataType.STRING, unique: true, allowNull: false})
    image: string

    @ForeignKey(() => Category)
    @Column({ type: DataType.INTEGER })
    categoryId: number

    @BelongsTo(() => Category)
    category: Category
}

Код из categories.model.ts:

import { ApiProperty } from "@nestjs/swagger";
import { Column, DataType, HasMany, Model, Table } from "sequelize-typescript";
import { Product } from "src/products/products.model";

interface CategoriesCreationAttribute {
    name: string
}

@Table({ tableName: 'categories' })
export class Category extends Model<Category, CategoriesCreationAttribute> {

    @ApiProperty({ example: '1',  description: 'Уникальный идентификатор' })
    @Column({ type: DataType.INTEGER, unique: true, autoIncrement: true, primaryKey: true })
    id: number

    
    @ApiProperty({ example: 'Розы', description: 'Наименование товара' })
    @Column({ type: DataType.STRING, allowNull: false, unique: true })
    name: string

    @HasMany(() => Product)
    products: Product[]
}

Ответы (0 шт):