Skip to content

Commit d2a4459

Browse files
committed
feat: add isArchived and isActive columns
Add archived/active flags to positions and users with defaults via migration
1 parent e684b4a commit d2a4459

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { DataType } from "sequelize-typescript";
2+
import { Migration } from "../umzug";
3+
4+
const POSITIONS_TABLE_NAME = "positions";
5+
const USERS_TABLE_NAME = "users";
6+
7+
export const up: Migration = async ({ context: sequelize }) => {
8+
await sequelize.getQueryInterface().addColumn(POSITIONS_TABLE_NAME, "isArchived", {
9+
type: DataType.BOOLEAN,
10+
allowNull: false,
11+
defaultValue: false,
12+
});
13+
14+
await sequelize.getQueryInterface().addColumn(USERS_TABLE_NAME, "isActive", {
15+
type: DataType.BOOLEAN,
16+
allowNull: false,
17+
defaultValue: true,
18+
});
19+
};
20+
21+
export const down: Migration = async ({ context: sequelize }) => {
22+
await sequelize.getQueryInterface().removeColumn(USERS_TABLE_NAME, "isActive");
23+
await sequelize
24+
.getQueryInterface()
25+
.removeColumn(POSITIONS_TABLE_NAME, "isArchived");
26+
};
27+

backend/typescript/models/position.model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ export default class Position extends Model {
77

88
@Column({ type: DataType.STRING })
99
department!: string;
10+
11+
@Column({ type: DataType.BOOLEAN, defaultValue: false })
12+
isArchived!: boolean;
1013
}

backend/typescript/models/user.model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ export default class User extends Model {
3737
@Column({ type: DataType.STRING })
3838
position?: string;
3939

40+
@Column({ type: DataType.BOOLEAN, defaultValue: true })
41+
isActive!: boolean;
42+
4043
@HasMany(() => ReviewedApplicantRecord, {
4144
foreignKey: "reviewerId",
4245
sourceKey: "id",

0 commit comments

Comments
 (0)