| 7 | | BEGIN; |
| 8 | | |
| 9 | | DROP TABLE IF EXISTS temp_course_id; |
| 10 | | DROP TABLE IF EXISTS temp_course_version_id; |
| 11 | | DROP TABLE IF EXISTS temp_course_translate_id; |
| 12 | | DROP TABLE IF EXISTS temp_course_content_id; |
| 13 | | DROP TABLE IF EXISTS temp_course_lecture_id; |
| 14 | | DROP TABLE IF EXISTS temp_tag_id; |
| 15 | | |
| 16 | | CREATE TEMP TABLE temp_course_id (id BIGINT); |
| 17 | | CREATE TEMP TABLE temp_course_version_id (id BIGINT); |
| 18 | | CREATE TEMP TABLE temp_course_translate_id (id BIGINT, language VARCHAR(2)); |
| 19 | | CREATE TEMP TABLE temp_course_content_id (id BIGINT); |
| 20 | | CREATE TEMP TABLE temp_course_lecture_id (id BIGINT); |
| 21 | | CREATE TEMP TABLE temp_tag_id (id BIGINT, type VARCHAR(50)); |
| 22 | | |
| 23 | | WITH new_course AS ( |
| 24 | | INSERT INTO course (image_url, difficulty, duration_minutes, price, color) |
| 25 | | VALUES ('https://example.com/image.png', 'INTERMEDIATE', 120, 50, '#008CC2') |
| 26 | | RETURNING id |
| 27 | | ) |
| 28 | | INSERT INTO temp_course_id (id) |
| 29 | | SELECT id FROM new_course; |
| 30 | | |
| 31 | | WITH new_course_version AS ( |
| 32 | | INSERT INTO course_version (course_id) |
| 33 | | SELECT id FROM temp_course_id |
| 34 | | RETURNING id |
| 35 | | ) |
| 36 | | INSERT INTO temp_course_version_id (id) |
| 37 | | SELECT id FROM new_course_version; |
| 38 | | |
| 39 | | WITH new_course_translate_en AS ( |
| 40 | | INSERT INTO course_translate (language, title_short, title, description_short, description, description_long, course_id) |
| 41 | | SELECT 'en', 'Advanced Sales', 'Advanced Sales For Senior Salesman', 'Short desc', 'Normal desc', 'Long desc', id FROM temp_course_id |
| 42 | | RETURNING id, language |
| 43 | | ) |
| 44 | | INSERT INTO temp_course_translate_id (id, language) |
| 45 | | SELECT id, language FROM new_course_translate_en; |
| 46 | | |
| 47 | | WITH new_course_translate_mk AS ( |
| 48 | | INSERT INTO course_translate (language, title_short, title, description_short, description, description_long, course_id) |
| 49 | | SELECT 'mk', 'Напредна Продажба', 'Напредна Продажба за Сениор Продавачи', 'Кратка дескрипција', 'Нормална дескрипција', 'Долга дескрипција', id FROM temp_course_id |
| 50 | | RETURNING id, language |
| 51 | | ) |
| 52 | | INSERT INTO temp_course_translate_id (id, language) |
| 53 | | SELECT id, language FROM new_course_translate_mk; |
| 54 | | |
| 55 | | WITH new_course_content AS ( |
| 56 | | INSERT INTO course_content (position, course_version_id) |
| 57 | | SELECT 1, id FROM temp_course_version_id |
| 58 | | RETURNING id |
| 59 | | ) |
| 60 | | INSERT INTO temp_course_content_id (id) |
| 61 | | SELECT id FROM new_course_content; |
| 62 | | |
| 63 | | INSERT INTO course_content_translate (title, language, course_content_id) |
| 64 | | SELECT 'Module 1: Sales Strategies', 'en', id FROM temp_course_content_id; |
| 65 | | |
| 66 | | INSERT INTO course_content_translate (title, language, course_content_id) |
| 67 | | SELECT 'Модул 1: Продажни Стратегии', 'mk', id FROM temp_course_content_id; |
| 68 | | |
| 69 | | WITH new_course_lecture AS ( |
| 70 | | INSERT INTO course_lecture (duration_minutes, position, content_type, course_content_id) |
| 71 | | SELECT 30, 1, 'video', id FROM temp_course_content_id |
| 72 | | RETURNING id |
| 73 | | ) |
| 74 | | INSERT INTO temp_course_lecture_id (id) |
| 75 | | SELECT id FROM new_course_lecture; |
| 76 | | |
| 77 | | INSERT INTO course_lecture_translate (title, language, content_file_name, description, content_text, course_lecture_id) |
| 78 | | SELECT 'Lecture 1: Intro', 'en', 'lecture1.mp4', 'Introduction to advanced sales', 'Video text content', id |
| 79 | | FROM temp_course_lecture_id; |
| 80 | | |
| 81 | | INSERT INTO course_lecture_translate (title, language, content_file_name, description, content_text, course_lecture_id) |
| 82 | | SELECT 'Предавање 1: Вовед', 'mk', 'lecture1.mp4', 'Вовед во напредна продажба', 'Тмп', id |
| 83 | | FROM temp_course_lecture_id; |
| 84 | | |
| 85 | | WITH new_tags AS ( |
| 86 | | INSERT INTO tag (type) |
| 87 | | VALUES ('skill'), ('interest') |
| 88 | | RETURNING id, type |
| 89 | | ) |
| 90 | | INSERT INTO temp_tag_id (id, type) |
| 91 | | SELECT id, type FROM new_tags; |
| 92 | | |
| 93 | | INSERT INTO tag_translate (language, value, tag_id) |
| 94 | | SELECT 'en', CASE type WHEN 'skill' THEN 'Skill' WHEN 'interest' THEN 'Interest' END, id FROM temp_tag_id; |
| 95 | | |
| 96 | | INSERT INTO tag_translate (language, value, tag_id) |
| 97 | | SELECT 'mk', CASE type WHEN 'skill' THEN 'Вештина' WHEN 'interest' THEN 'Интерес' END, id FROM temp_tag_id; |
| 98 | | |
| 99 | | INSERT INTO course_tag (tag_id, course_id) |
| 100 | | SELECT t.id, c.id |
| 101 | | FROM temp_tag_id t |
| 102 | | CROSS JOIN temp_course_id c; |
| 103 | | |
| 104 | | INSERT INTO expert_course (course_id, expert_id) |
| 105 | | SELECT id, 1 |
| 106 | | FROM temp_course_id; |
| 107 | | |
| 108 | | INSERT INTO course_translate_what_will_be_learned (course_translate_id, what_will_be_learned) |
| 109 | | SELECT id, 'Advanced sales techniques' |
| 110 | | FROM temp_course_translate_id |
| 111 | | WHERE language = 'en'; |
| 112 | | |
| 113 | | INSERT INTO course_translate_what_will_be_learned (course_translate_id, what_will_be_learned) |
| 114 | | SELECT id, 'How to successfully close deals' |
| 115 | | FROM temp_course_translate_id |
| 116 | | WHERE language = 'en'; |
| 117 | | |
| 118 | | INSERT INTO course_translate_what_will_be_learned (course_translate_id, what_will_be_learned) |
| 119 | | SELECT id, 'Напредни техники на продажба' |
| 120 | | FROM temp_course_translate_id |
| 121 | | WHERE language = 'mk'; |
| 122 | | |
| 123 | | INSERT INTO course_translate_what_will_be_learned (course_translate_id, what_will_be_learned) |
| 124 | | SELECT id, 'Како до успешно затворање на продажби' |
| 125 | | FROM temp_course_translate_id |
| 126 | | WHERE language = 'mk'; |
| 127 | | |
| 128 | | COMMIT; |
| | 14 | <dependency> |
| | 15 | <groupId>org.springframework.boot</groupId> |
| | 16 | <artifactId>spring-boot-starter-web</artifactId> |
| | 17 | </dependency> |