-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigration_add_languages.sql
More file actions
executable file
·142 lines (121 loc) · 6.76 KB
/
migration_add_languages.sql
File metadata and controls
executable file
·142 lines (121 loc) · 6.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
-- Add language support to team_members
ALTER TABLE team_members ADD COLUMN language_code VARCHAR(10) NOT NULL DEFAULT 'pl';
CREATE INDEX idx_team_members_lang ON team_members(language_code);
-- Create team translations table
CREATE TABLE IF NOT EXISTS team_translations (
id INTEGER PRIMARY KEY AUTOINCREMENT,
translation_key VARCHAR(100) NOT NULL,
type VARCHAR(50) NOT NULL, -- 'position', 'bio', 'specialty'
translation TEXT NOT NULL,
language_code VARCHAR(10) NOT NULL DEFAULT 'pl',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE(translation_key, type, language_code)
);
CREATE INDEX idx_team_translations_key ON team_translations(translation_key, type, language_code);
-- Add language support to consultation_types
ALTER TABLE consultation_types ADD COLUMN language_code VARCHAR(10) NOT NULL DEFAULT 'pl';
CREATE INDEX idx_consultation_types_lang ON consultation_types(language_code);
-- Add language support to expertise table
ALTER TABLE expertise ADD COLUMN language_code VARCHAR(10) NOT NULL DEFAULT 'pl';
CREATE INDEX idx_expertise_lang ON expertise(language_code);
-- Add language support to expertise_points
ALTER TABLE expertise_points ADD COLUMN language_code VARCHAR(10) NOT NULL DEFAULT 'pl';
CREATE INDEX idx_expertise_points_lang ON expertise_points(language_code);
-- Add language support to education_items
ALTER TABLE education_items ADD COLUMN language_code VARCHAR(10) NOT NULL DEFAULT 'pl';
CREATE INDEX idx_education_items_lang ON education_items(language_code);
-- Add language support to certification_items
ALTER TABLE certification_items ADD COLUMN language_code VARCHAR(10) NOT NULL DEFAULT 'pl';
CREATE INDEX idx_certification_items_lang ON certification_items(language_code);
-- Add language support to config table for translatable content
ALTER TABLE config ADD COLUMN language_code VARCHAR(10) DEFAULT NULL;
CREATE INDEX idx_config_lang ON config(language_code);
-- Create section_translations table for section-level content
CREATE TABLE IF NOT EXISTS section_translations (
id INTEGER PRIMARY KEY AUTOINCREMENT,
section_name VARCHAR(50) NOT NULL,
title VARCHAR(255) NOT NULL,
subtitle TEXT,
description TEXT,
language_code VARCHAR(10) NOT NULL DEFAULT 'pl',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE(section_name, language_code)
);
-- Insert default section translations
INSERT INTO section_translations (section_name, title, subtitle, description, language_code) VALUES
-- Team section
('team', 'Zespół', NULL, 'Nasz zespół certyfikowanych specjalistów DBT', 'pl'),
('team', 'Team', NULL, 'Our team of certified DBT specialists', 'en'),
-- Team full section
('team_full', 'Nasz Zespół', NULL, 'Poznaj naszych certyfikowanych specjalistów DBT', 'pl'),
('team_full', 'Our Team', NULL, 'Meet our certified DBT specialists', 'en'),
-- Consultations section
('consultations', 'Konsultacje', NULL, 'Oferujemy różne formy konsultacji i terapii', 'pl'),
('consultations', 'Consultations', NULL, 'We offer various forms of consultation and therapy', 'en'),
-- Expertise section
('expertise', 'Obszary Ekspertyzy', NULL, 'Nasze główne obszary specjalizacji', 'pl'),
('expertise', 'Areas of Expertise', NULL, 'Our main areas of specialization', 'en'),
-- Education section
('education', 'Edukacja', NULL, 'Programy szkoleniowe i edukacyjne', 'pl'),
('education', 'Education', NULL, 'Training and educational programs', 'en'),
-- Certification section
('certification', 'Certyfikacja', NULL, 'Nasze certyfikaty i akredytacje', 'pl'),
('certification', 'Certification', NULL, 'Our certificates and accreditations', 'en');
-- Insert team translations
INSERT INTO team_translations (translation_key, type, translation, language_code) VALUES
-- Positions
('clinical_director', 'position', 'Dyrektor Kliniczny', 'pl'),
('clinical_director', 'position', 'Clinical Director', 'en'),
('lead_therapist', 'position', 'Główny Terapeuta', 'pl'),
('lead_therapist', 'position', 'Lead Therapist', 'en'),
('dbt_therapist', 'position', 'Terapeuta DBT', 'pl'),
('dbt_therapist', 'position', 'DBT Therapist', 'en'),
('skills_trainer', 'position', 'Trener Umiejętności', 'pl'),
('skills_trainer', 'position', 'Skills Trainer', 'en'),
('research_director', 'position', 'Dyrektor ds. Badań', 'pl'),
('research_director', 'position', 'Research Director', 'en'),
-- Specialties
('dbt', 'specialty', 'Terapia Dialektyczno-Behawioralna', 'pl'),
('dbt', 'specialty', 'Dialectical Behavior Therapy', 'en'),
('cbt', 'specialty', 'Terapia Poznawczo-Behawioralna', 'pl'),
('cbt', 'specialty', 'Cognitive Behavioral Therapy', 'en'),
('trauma', 'specialty', 'Leczenie Traumy', 'pl'),
('trauma', 'specialty', 'Trauma Treatment', 'en'),
('mindfulness', 'specialty', 'Uważność', 'pl'),
('mindfulness', 'specialty', 'Mindfulness', 'en'),
('group', 'specialty', 'Terapia Grupowa', 'pl'),
('group', 'specialty', 'Group Therapy', 'en'),
('individual', 'specialty', 'Terapia Indywidualna', 'pl'),
('individual', 'specialty', 'Individual Therapy', 'en'),
('crisis', 'specialty', 'Interwencja Kryzysowa', 'pl'),
('crisis', 'specialty', 'Crisis Intervention', 'en'),
('emotion', 'specialty', 'Regulacja Emocji', 'pl'),
('emotion', 'specialty', 'Emotion Regulation', 'en'),
('skills', 'specialty', 'Trening Umiejętności', 'pl'),
('skills', 'specialty', 'Skills Training', 'en'),
('assessment', 'specialty', 'Diagnostyka', 'pl'),
('assessment', 'specialty', 'Assessment', 'en');
-- Function to duplicate existing content for English language
CREATE TEMPORARY TABLE tmp_consultation_types AS SELECT * FROM consultation_types;
INSERT INTO consultation_types (title, description, icon, duration, price, features, booking_url, is_active, sort_order, language_code)
SELECT title, description, icon, duration, price, features, booking_url, is_active, sort_order, 'en'
FROM tmp_consultation_types;
DROP TABLE tmp_consultation_types;
CREATE TEMPORARY TABLE tmp_expertise AS SELECT * FROM expertise;
INSERT INTO expertise (title, description, icon_url, active, display_order, language_code)
SELECT title, description, icon_url, active, display_order, 'en'
FROM tmp_expertise;
DROP TABLE tmp_expertise;
CREATE TEMPORARY TABLE tmp_expertise_points AS SELECT * FROM expertise_points;
INSERT INTO expertise_points (expertise_id, point_text, language_code)
SELECT expertise_id, point_text, 'en'
FROM tmp_expertise_points;
DROP TABLE tmp_expertise_points;
-- Update config entries that need translation
UPDATE config SET language_code = 'pl' WHERE name IN ('consultations_note', 'team_note', 'education_note');
INSERT INTO config (name, value, type, description, language_code)
SELECT name, value, type, description, 'en'
FROM config
WHERE language_code = 'pl' AND name IN ('consultations_note', 'team_note', 'education_note');