From d5844f0421cdfaebfd4f5332b246bc22508f9a42 Mon Sep 17 00:00:00 2001 From: Anton Liauchuk Date: Tue, 29 Jun 2021 11:10:20 +0300 Subject: [PATCH] #14 foreign keys --- .../main/resources/db/course-enrollments.yml | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/course-enrollments/application/src/main/resources/db/course-enrollments.yml b/course-enrollments/application/src/main/resources/db/course-enrollments.yml index 96167a8..9e23676 100644 --- a/course-enrollments/application/src/main/resources/db/course-enrollments.yml +++ b/course-enrollments/application/src/main/resources/db/course-enrollments.yml @@ -27,11 +27,13 @@ databaseChangeLog: type: uuid - column: constraints: + foreignKeyName: course_fkey nullable: false name: course type: int - column: constraints: + foreignKeyName: student_fkey nullable: false name: student type: int @@ -40,3 +42,77 @@ databaseChangeLog: nullable: false name: completion_status type: VARCHAR(14) + - changeSet: + id: 2021_06_25-2 + author: antonliauchuk + preConditions: + onFail: MARK_RAN + not: + tableExists: + tableName: enroll_course + changes: + - createTable: + tableName: enroll_course + columns: + - column: + name: id + type: int + autoIncrement: true + startWith: 1 + incrementBy: 1 + constraints: + primaryKey: true + primaryKeyName: enroll_course_pk + - column: + constraints: + nullable: false + name: uuid + type: uuid + - changeSet: + id: 2021_06_25-3 + author: antonliauchuk + preConditions: + onFail: MARK_RAN + not: + tableExists: + tableName: student + changes: + - createTable: + tableName: student + columns: + - column: + name: id + type: int + autoIncrement: true + startWith: 1 + incrementBy: 1 + constraints: + primaryKey: true + primaryKeyName: student_pk + - column: + constraints: + nullable: false + name: username + type: VARCHAR(100) + - changeSet: + id: 2021_06_25-4 + author: antonliauchuk + changes: + - addForeignKeyConstraint: + baseColumnNames: course + baseTableName: course_enrollment + constraintName: course_fkey + referencedColumnNames: id + referencedTableName: enroll_course + validate: true + - changeSet: + id: 2021_06_25-5 + author: antonliauchuk + changes: + - addForeignKeyConstraint: + baseColumnNames: student + baseTableName: course_enrollment + constraintName: student_fkey + referencedColumnNames: id + referencedTableName: student + validate: true