-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into lakshya/F24/forgot-password-flow
- Loading branch information
Showing
18 changed files
with
310 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
backend/typescript/migrations/2024.10.04T00.23.02.create-user-animal-types-table.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { DataType } from "sequelize-typescript"; | ||
|
||
import { Migration } from "../umzug"; | ||
|
||
const TABLE_NAME = "user_animal_types"; | ||
|
||
export const up: Migration = async ({ context: sequelize }) => { | ||
await sequelize.getQueryInterface().createTable(TABLE_NAME, { | ||
user_id: { | ||
type: DataType.INTEGER, | ||
allowNull: false, | ||
primaryKey: true, | ||
references: { | ||
model: "users", | ||
key: "id", | ||
}, | ||
onUpdate: "CASCADE", | ||
onDelete: "CASCADE", | ||
}, | ||
animal_type_id: { | ||
type: DataType.INTEGER, | ||
allowNull: false, | ||
primaryKey: true, | ||
references: { | ||
model: "animal_types", | ||
key: "id", | ||
}, | ||
onUpdate: "CASCADE", | ||
onDelete: "CASCADE", | ||
}, | ||
}); | ||
}; | ||
|
||
export const down: Migration = async ({ context: sequelize }) => { | ||
await sequelize.getQueryInterface().dropTable(TABLE_NAME); | ||
}; |
55 changes: 55 additions & 0 deletions
55
backend/typescript/migrations/2024.10.22T19.38.07.create-behaviour-level-details-table.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { DataType } from "sequelize-typescript"; | ||
|
||
import { Migration } from "../umzug"; | ||
|
||
const TABLE_NAME = "behaviour_level_details"; | ||
const CONSTRAINT_NAME = "unique_behaviour_level"; | ||
|
||
export const up: Migration = async ({ context: sequelize }) => { | ||
await sequelize.getQueryInterface().createTable(TABLE_NAME, { | ||
id: { | ||
type: DataType.INTEGER, | ||
allowNull: false, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
behaviour_id: { | ||
type: DataType.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: "behaviours", | ||
key: "id", | ||
}, | ||
}, | ||
level: { | ||
type: DataType.INTEGER, | ||
validate: { | ||
min: 1, | ||
max: 4, | ||
}, | ||
allowNull: false, | ||
}, | ||
description: { | ||
type: DataType.STRING, | ||
allowNull: true, | ||
}, | ||
training_instructions: { | ||
type: DataType.STRING, | ||
allowNull: true, | ||
}, | ||
}); | ||
|
||
await sequelize.getQueryInterface().addConstraint(TABLE_NAME, { | ||
fields: ["behaviour_id", "level"], | ||
type: "unique", | ||
name: CONSTRAINT_NAME, | ||
}); | ||
}; | ||
|
||
export const down: Migration = async ({ context: sequelize }) => { | ||
await sequelize | ||
.getQueryInterface() | ||
.removeConstraint(TABLE_NAME, CONSTRAINT_NAME); | ||
|
||
await sequelize.getQueryInterface().dropTable(TABLE_NAME); | ||
}; |
23 changes: 23 additions & 0 deletions
23
backend/typescript/migrations/2024.10.22T19.42.10.add-behaviour-columns.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { DataType } from "sequelize-typescript"; | ||
import { Migration } from "../umzug"; | ||
|
||
const TABLE_NAME = "behaviours"; | ||
|
||
export const up: Migration = async ({ context: sequelize }) => { | ||
await sequelize | ||
.getQueryInterface() | ||
.addColumn(TABLE_NAME, "parent_behaviour_id", { | ||
type: DataType.INTEGER, | ||
allowNull: true, | ||
references: { | ||
model: "behaviours", | ||
key: "id", | ||
}, | ||
}); | ||
}; | ||
|
||
export const down: Migration = async ({ context: sequelize }) => { | ||
await sequelize | ||
.getQueryInterface() | ||
.removeColumn(TABLE_NAME, "parent_behaviour_id"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
import { Column, Model, Table } from "sequelize-typescript"; | ||
import { | ||
Column, | ||
DataType, | ||
ForeignKey, | ||
Model, | ||
Table, | ||
} from "sequelize-typescript"; | ||
|
||
@Table({ timestamps: false, tableName: "behaviours" }) | ||
export default class Behaviour extends Model { | ||
@Column | ||
@Column({ type: DataType.STRING, allowNull: false }) | ||
behaviour_name!: string; | ||
|
||
@ForeignKey(() => Behaviour) | ||
@Column({ type: DataType.INTEGER }) | ||
parent_behaviour_id?: number | null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { | ||
Column, | ||
Model, | ||
Table, | ||
ForeignKey, | ||
DataType, | ||
} from "sequelize-typescript"; | ||
import Behaviour from "./behaviour.model"; | ||
|
||
@Table({ timestamps: false, tableName: "behaviour_level_details" }) | ||
export default class BehaviourLevelDetails extends Model { | ||
@ForeignKey(() => Behaviour) | ||
@Column({ type: DataType.INTEGER, allowNull: false }) | ||
behaviour_id!: number; | ||
|
||
@Column({ type: DataType.INTEGER, allowNull: false }) | ||
level!: number; | ||
|
||
@Column({ type: DataType.STRING, allowNull: true }) | ||
description?: string; | ||
|
||
@Column({ type: DataType.STRING, allowNull: true }) | ||
training_instructions?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import User from "./user.model"; | ||
import AnimalType from "./animalType.model"; | ||
import UserAnimalType from "./userAnimalType.model"; | ||
|
||
export default function defineRelationships(): void { | ||
User.belongsToMany(AnimalType, { through: UserAnimalType }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { | ||
Column, | ||
DataType, | ||
Model, | ||
Table, | ||
ForeignKey, | ||
PrimaryKey, | ||
} from "sequelize-typescript"; | ||
import User from "./user.model"; | ||
import AnimalType from "./animalType.model"; | ||
|
||
@Table({ | ||
tableName: "User_AnimalTypes", | ||
timestamps: true, | ||
}) | ||
export default class UserAnimalType extends Model { | ||
@ForeignKey(() => User) | ||
@PrimaryKey | ||
@Column({ type: DataType.INTEGER, allowNull: false }) | ||
user_id!: number; | ||
|
||
@ForeignKey(() => AnimalType) | ||
@PrimaryKey | ||
@Column({ type: DataType.INTEGER, allowNull: false }) | ||
animal_type_id!: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.