Skip to content

Commit

Permalink
changed user_pet_activity to activity
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry-cheng5 committed Oct 10, 2024
1 parent 9156318 commit 93e8c99
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Migration } from "../umzug";
const OLD_TABLE_NAME = "activities";
const NEW_TABLE_NAME = "activity_types";
const USER_PET_ACTIVITIES_TABLE = "user_pet_activities";
const ACTIVITIES_TABLE = "activities";

export const up: Migration = async ({ context: sequelize }) => {
// Rename the activities table to activity_types
Expand All @@ -27,9 +28,19 @@ export const up: Migration = async ({ context: sequelize }) => {
key: "id",
},
});

// Change the name of user_pet_activities to activities
await sequelize
.getQueryInterface()
.renameTable(USER_PET_ACTIVITIES_TABLE, ACTIVITIES_TABLE);
};

export const down: Migration = async ({ context: sequelize }) => {
// Rename the activities table back to user_pet_activities
await sequelize
.getQueryInterface()
.renameTable(ACTIVITIES_TABLE, USER_PET_ACTIVITIES_TABLE);

// Rename the activity_types table back to activities
await sequelize
.getQueryInterface()
Expand Down
4 changes: 2 additions & 2 deletions backend/typescript/models/activity.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import User from "./user.model";
import Pet from "./pet.model";
import ActivityType from "./activityType.model";

@Table({ timestamps: false, tableName: "user_pet_activities" })
@Table({ timestamps: false, tableName: "activities" })
export default class Activity extends Model {
@Column({})
user_pet_activity_id!: number;
activity_id!: number;

@ForeignKey(() => User) // in case of null, task has not been assigned
@Column({})
Expand Down

0 comments on commit 93e8c99

Please sign in to comment.