Skip to content

Commit

Permalink
uncommented foreign key restraints
Browse files Browse the repository at this point in the history
  • Loading branch information
laks0407 committed Jun 15, 2024
1 parent 78da9f0 commit 5710029
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export const up: Migration = async ({ context: sequelize }) => {
animal_type_id: {
type: DataType.INTEGER,
allowNull: false,
// references: {
// model: "animal_type",
// key: "animal_type_id",
// },
references: {
model: "animal_type",
key: "animal_type_id",
},
},
name: {
type: DataType.INTEGER,
Expand All @@ -39,11 +39,11 @@ export const up: Migration = async ({ context: sequelize }) => {
pet_care_info_id: {
type: DataType.INTEGER,
allowNull: true,
// references: {
// model: "pet_care_info",
// key: "pet_care_info_id"
// },
// onDelete: "SET NULL"
references: {
model: "pet_care_info",
key: "pet_care_info_id"
},
onDelete: "SET NULL"
},
weight: {
type: DataType.DECIMAL,
Expand Down
16 changes: 8 additions & 8 deletions backend/typescript/models/pet.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Column, Model, Table, DataType, ForeignKey, BelongsTo } from "sequelize-typescript";
// import { AnimalType } from "./AnimalType"
// import { PetCareInfo } from "./PetCareInfo"
import { AnimalType } from "./AnimalType"
import { PetCareInfo } from "./PetCareInfo"

import { Letters } from "../types";

Expand All @@ -9,12 +9,12 @@ export default class Pet extends Model {
@Column ({ type: DataType.INTEGER })
pet_id!: number;

// @ForeignKey(() => AnimalType)
@ForeignKey(() => AnimalType)
@Column ({ type: DataType.INTEGER })
animal_type_id!: number;

// @BelongsTo(() => AnimalType)
// animalType: AnimalType;
@BelongsTo(() => AnimalType)
animalType: AnimalType;

@Column ({ type: DataType.STRING })
name!: string;
Expand All @@ -28,12 +28,12 @@ export default class Pet extends Model {
@Column ({ type: DataType.BOOLEAN })
adoption_status!: boolean;

// @ForeignKey(() => PetCareInfo)
@ForeignKey(() => PetCareInfo)
@Column ({ type: DataType.INTEGER })
pet_care_info_id?: number;

// @BelongsTo(() => PetCareInfo)
// petCareInfo?: PetCareInfo;
@BelongsTo(() => PetCareInfo)
petCareInfo?: PetCareInfo;

@Column ({ type: DataType.DECIMAL })
weight!: number;
Expand Down

0 comments on commit 5710029

Please sign in to comment.