Skip to content

Commit 676606e

Browse files
committed
feat: course id in schedule courses
1 parent 7beb4df commit 676606e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { BaseSchema } from "@adonisjs/lucid/schema";
2+
3+
export default class UpdateCourseIdForeignKey extends BaseSchema {
4+
protected tableName = "schedule_courses";
5+
6+
public async up() {
7+
this.schema.alterTable(this.tableName, (table) => {
8+
table.dropForeign(["course_id"]); // Remove the existing foreign key
9+
table
10+
.foreign("course_id")
11+
.references("courses.id")
12+
.onUpdate("CASCADE")
13+
.onDelete("CASCADE");
14+
});
15+
}
16+
17+
public async down() {
18+
this.schema.alterTable(this.tableName, (table) => {
19+
table.dropForeign(["course_id"]); // Remove the modified foreign key
20+
table.foreign("course_id").references("courses.id").onDelete("CASCADE"); // Revert to original
21+
});
22+
}
23+
}

0 commit comments

Comments
 (0)