Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down Expand Up @@ -58,7 +56,4 @@ public class HostUniversity extends BaseEntity {

@ManyToOne
private Region region;

@ManyToOne(fetch = FetchType.LAZY)
private HomeUniversity homeUniversity;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class UnivApplyInfo extends BaseEntity {
@Column(nullable = false, name = "term_id")
private long termId;

@Column(name = "home_university_id")
private Long homeUniversityId;

@Column(nullable = false, length = 100)
private String koreanName;

Expand Down
38 changes: 19 additions & 19 deletions src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,100 +50,100 @@ VALUES ('test@test.email', 'yonso', 'https://github.com/nayonsoso.png',

INSERT INTO home_university (id, name) VALUES (1, '인하대학교');

INSERT INTO host_university(id, home_university_id, country_code, region_code, english_name, format_name, korean_name,
INSERT INTO host_university(id, country_code, region_code, english_name, format_name, korean_name,
accommodation_url, english_course_url, homepage_url,
details_for_local, logo_image_url, background_image_url)
VALUES (1, 1, 'US', 'AMERICAS', 'University of Guam', 'university_of_guam', '괌대학',
VALUES (1, 'US', 'AMERICAS', 'University of Guam', 'university_of_guam', '괌대학',
'https://www.uog.edu/life-at-uog/residence-halls/', 'https://www.uog.edu/admissions/course-schedule',
'https://www.uog.edu/admissions/international-students', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_guam/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_guam/1.png'),
(2, 1, 'US', 'AMERICAS', 'University of Nevada, Las Vegas', 'university_of_nevada_las_vegas', '네바다주립대학 라스베이거스',
(2, 'US', 'AMERICAS', 'University of Nevada, Las Vegas', 'university_of_nevada_las_vegas', '네바다주립대학 라스베이거스',
'https://www.unlv.edu/housing', 'https://www.unlv.edu/engineering/academic-programs',
'https://www.unlv.edu/engineering/eip', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_nevada_las_vegas/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_nevada_las_vegas/1.png'),
(3, 1, 'CA', 'AMERICAS', 'Memorial University of Newfoundland St. John''s',
(3, 'CA', 'AMERICAS', 'Memorial University of Newfoundland St. John''s',
'memorial_university_of_newfoundland_st_johns', '메모리얼 대학 세인트존스', 'https://www.mun.ca/residences/',
'https://www.mun.ca/regoff/registration-and-final-exams/course-offerings/',
'https://mun.ca/goabroad/visiting-students-inbound/', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/memorial_university_of_newfoundland_st_johns/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/memorial_university_of_newfoundland_st_johns/1.png'),
(4, 1, 'AU', 'AMERICAS', 'University of Southern Queensland', 'university_of_southern_queensland', '서던퀸스랜드대학',
(4, 'AU', 'AMERICAS', 'University of Southern Queensland', 'university_of_southern_queensland', '서던퀸스랜드대학',
'https://www.unisq.edu.au/current-students/support/accommodation',
'https://www.unisq.edu.au/course/specification/current/',
'https://www.unisq.edu.au/international/partnerships/study-abroad-exchange', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_southern_queensland/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_southern_queensland/1.png'),
(5, 1, 'AU', 'AMERICAS', 'University of Sydney', 'university_of_sydney', '시드니대학',
(5, 'AU', 'AMERICAS', 'University of Sydney', 'university_of_sydney', '시드니대학',
'https://www.sydney.edu.au/study/accommodation.html', 'www.sydney.edu.au/sydney-abroad-units',
'https://www.sydney.edu.au/', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_sydney/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_sydney/1.png'),
(6, 1, 'AU', 'AMERICAS', 'Curtin University', 'curtin_university', '커틴대학',
(6, 'AU', 'AMERICAS', 'Curtin University', 'curtin_university', '커틴대학',
'https://www.curtin.edu.au/study/campus-life/accommodation/#perth', 'https://handbook.curtin.edu.au/',
'https://www.curtin.edu.au/', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/curtin_university/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/curtin_university/1.png'),
(7, 1, 'DK', 'EUROPE', 'University of Southern Denmark', 'university_of_southern_denmark', '서던덴마크대학교',
(7, 'DK', 'EUROPE', 'University of Southern Denmark', 'university_of_southern_denmark', '서던덴마크대학교',
'https://www.sdu.dk/en/uddannelse/information_for_international_students/studenthousing',
'https://www.sdu.dk/en/uddannelse/exchange_programmes', 'https://www.sdu.dk/en', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_southern_denmark/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_southern_denmark/1.png'),
(8, 1, 'DK', 'EUROPE', 'IT University of Copenhagen', 'it_university_of_copenhagen', '코펜하겐 IT대학',
(8, 'DK', 'EUROPE', 'IT University of Copenhagen', 'it_university_of_copenhagen', '코펜하겐 IT대학',
'https://en.itu.dk/Programmes/Student-Life/Practical-information-for-international-students',
'https://en.itu.dk/Programmes/Exchange-students/Become-an-exchange-student-at-ITU',
'https://en.itu.dk/programmes/exchange-students/become-an-exchange-student-at-itu', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/it_university_of_copenhagen/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/it_university_of_copenhagen/1.png'),
(9, 1, 'DE', 'EUROPE', 'Neu-Ulm University of Applied Sciences', 'neu-ulm_university_of_applied_sciences',
(9, 'DE', 'EUROPE', 'Neu-Ulm University of Applied Sciences', 'neu-ulm_university_of_applied_sciences',
'노이울름 대학',
'https://www.hnu.de/fileadmin/user_upload/5_Internationales/International_Incomings/Bewerbung/Housing_Broschure.pdf',
'https://www.hnu.de/en/international/international-exchange-students/courses-taught-in-english',
'https://www.hnu.de/en/international', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/neu-ulm_university_of_applied_sciences/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/neu-ulm_university_of_applied_sciences/1.png'),
(10, 1, 'GB', 'EUROPE', 'University of Hull', 'university_of_hull', '헐대학',
(10, 'GB', 'EUROPE', 'University of Hull', 'university_of_hull', '헐대학',
'https://www.hull.ac.uk/Choose-Hull/Student-life/Accommodation/accommodation.aspx',
'https://universityofhull.app.box.com/s/mpvulz3yz0uijdt68rybce19nek0d8eh',
'https://www.hull.ac.uk/choose-hull/study-at-hull/need-to-know/key-dates', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_hull/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_hull/1.png'),
(11, 1, 'AT', 'EUROPE', 'University of Graz', 'university_of_graz', '그라츠 대학',
(11, 'AT', 'EUROPE', 'University of Graz', 'university_of_graz', '그라츠 대학',
'https://orientation.uni-graz.at/de/planning-the-arrival/accommodation/',
'https://static.uni-graz.at/fileadmin/veranstaltungen/orientation/documents/incstud_application-courses.pdf',
'https://www.uni-graz.at/en/', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_graz/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_graz/1.png'),
(12, 1, 'AT', 'EUROPE', 'Graz University of Technology', 'graz_university_of_technology', '그라츠공과대학',
(12, 'AT', 'EUROPE', 'Graz University of Technology', 'graz_university_of_technology', '그라츠공과대학',
'https://www.tugraz.at/en/studying-and-teaching/studying-internationally/incoming-students-exchange-at-tu-graz/your-stay-at-tu-graz/preparation#c75033',
'https://tugraz.at/go/search-courses', 'https://www.tugraz.at/en/home', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/graz_university_of_technology/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/graz_university_of_technology/1.png'),
(13, 1, 'AT', 'EUROPE', 'Catholic Private University Linz', 'catholic_private_university_linz', '린츠 카톨릭 대학교', NULL,
(13, 'AT', 'EUROPE', 'Catholic Private University Linz', 'catholic_private_university_linz', '린츠 카톨릭 대학교', NULL,
'https://ku-linz.at/en/ku_international/incomings/kulis', 'https://ku-linz.at/en', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/catholic_private_university_linz/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/catholic_private_university_linz/1.png'),
(14, 1, 'AT', 'EUROPE', 'University of Applied Sciences Technikum Wien',
(14, 'AT', 'EUROPE', 'University of Applied Sciences Technikum Wien',
'university_of_applied_sciences_technikum_wien', '빈 공과대학교', NULL,
'https://www.technikum-wien.at/en/international/student-mobility/',
'https://www.technikum-wien.at/international/studierendenmobilitaet-2/', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_applied_sciences_technikum_wien/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/university_of_applied_sciences_technikum_wien/1.png'),
(15, 1, 'FR', 'EUROPE', 'IPSA', 'ipsa', 'IPSA', 'https://www.ipsa.fr/en/student-life/pratical-information/', NULL,
(15, 'FR', 'EUROPE', 'IPSA', 'ipsa', 'IPSA', 'https://www.ipsa.fr/en/student-life/pratical-information/', NULL,
'https://www.ipsa.fr/en/engineering-school/aeronautical-space', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/ipsa/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/ipsa/1.png'),
(16, 1, 'JP', 'ASIA', 'Meiji University', 'meiji_university', '메이지대학',
(16, 'JP', 'ASIA', 'Meiji University', 'meiji_university', '메이지대학',
'https://www.meiji.ac.jp/cip/english/admissions/co7mm90000000461-att/co7mm900000004fa.pdf', NULL,
'https://www.meiji.ac.jp/cip/english/admissions/co7mm90000000461-att/co7mm900000004fa.pdf', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/meiji_university/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/meiji_university/1.png'),
(17, 1, 'JP', 'ASIA', 'BAIKA Women''s University', 'baika_womens_university', '바이카여자대학',
(17, 'JP', 'ASIA', 'BAIKA Women''s University', 'baika_womens_university', '바이카여자대학',
'https://dormy-ac.com/page/baika/', NULL, 'https://www.baika.ac.jp/english/', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/baika_womens_university/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/baika_womens_university/1.png'),
(18, 1, 'JP', 'ASIA', 'Bunkyo Gakuin University', 'bunkyo_gakuin_university', '분쿄가쿠인대학', NULL, NULL,
(18, 'JP', 'ASIA', 'Bunkyo Gakuin University', 'bunkyo_gakuin_university', '분쿄가쿠인대학', NULL, NULL,
'https://www.bgu.ac.jp/', NULL,
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/bunkyo_gakuin_university/logo.png',
'https://solid-connection.s3.ap-northeast-2.amazonaws.com/original/bunkyo_gakuin_university/1.png');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ALTER TABLE host_university
DROP FOREIGN KEY fk_host_university_home_university;

ALTER TABLE host_university
DROP COLUMN home_university_id;

ALTER TABLE university_info_for_apply
ADD COLUMN home_university_id BIGINT NULL;

ALTER TABLE university_info_for_apply
ADD CONSTRAINT fk_university_info_for_apply_home_university
FOREIGN KEY (home_university_id) REFERENCES home_university (id) ON DELETE NO ACTION;
Comment on lines +1 to +12
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

1) 데이터 이관 없이 컬럼을 드롭하면 기존 관계가 소실됩니다.

  • 현재 스크립트는 기존 home_university_id 값을 백필하지 않고 컬럼을 제거합니다.
  • 운영 데이터가 있다면 FK 이동 과정에서 값이 유실됩니다.
🛠️ 안전한 순서 예시
-ALTER TABLE host_university
-    DROP FOREIGN KEY fk_host_university_home_university;
-
-ALTER TABLE host_university
-    DROP COLUMN home_university_id;
-
-ALTER TABLE university_info_for_apply
-    ADD COLUMN home_university_id BIGINT NULL;
-
-ALTER TABLE university_info_for_apply
-    ADD CONSTRAINT fk_university_info_for_apply_home_university
-        FOREIGN KEY (home_university_id) REFERENCES home_university (id) ON DELETE NO ACTION;
+ALTER TABLE university_info_for_apply
+    ADD COLUMN home_university_id BIGINT NULL;
+
+UPDATE university_info_for_apply u
+JOIN host_university h ON u.university_id = h.id
+SET u.home_university_id = h.home_university_id;
+
+ALTER TABLE university_info_for_apply
+    ADD CONSTRAINT fk_university_info_for_apply_home_university
+        FOREIGN KEY (home_university_id) REFERENCES home_university (id) ON DELETE NO ACTION;
+
+ALTER TABLE host_university
+    DROP FOREIGN KEY fk_host_university_home_university;
+
+ALTER TABLE host_university
+    DROP COLUMN home_university_id;
🤖 Prompt for AI Agents
In
`@src/main/resources/db/migration/V43__move_home_university_fk_to_univ_apply_info.sql`
around lines 1 - 12, The migration drops fk_host_university_home_university and
host_university.home_university_id without backfilling, which will lose data;
instead: add the new nullable column
university_info_for_apply.home_university_id, copy values from
host_university.home_university_id into university_info_for_apply (using the
appropriate join on the linking key between host_university and
university_info_for_apply), then add the new FK
fk_university_info_for_apply_home_university, verify data, and only after
successful backfill drop the old foreign key fk_host_university_home_university
and drop host_university.home_university_id; ensure the copy handles NULLs and
preserves referential integrity before removing the original constraint.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public UnivApplyInfoFixtureBuilder university(HostUniversity university) {

public UnivApplyInfo create() {
UnivApplyInfo univApplyInfo = new UnivApplyInfo(
null, termId, koreanName, 1, HOME_UNIVERSITY_PAYMENT, ONE_SEMESTER,
null, termId, null, koreanName, 1, HOME_UNIVERSITY_PAYMENT, ONE_SEMESTER,
"1", "detailsForLanguage", "gpaRequirement",
"gpaRequirementCriteria", "detailsForApply", "detailsForMajor",
"detailsForAccommodation", "detailsForEnglishCourse", "details",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public HostUniversity create() {
"https://accommodation-url",
"https://logo-image-url",
"https://background-image-url",
null, country, region,
null
null, country, region
);
return hostUniversityRepository.save(university);
}
Expand Down
Loading