Skip to content

Commit 42f2753

Browse files
committed
Added explicit char set for DB
1 parent e5cf8e2 commit 42f2753

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

backend/PyMatcha/utils/tables.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def _create_user_table(db):
2828
c.execute(DISABLE_SQL_NOTES)
2929
c.execute(
3030
"""
31-
CREATE TABLE IF NOT EXISTS users
31+
CREATE TABLE IF NOT EXISTS users
3232
(
3333
id INT auto_increment PRIMARY KEY,
3434
first_name VARCHAR(256) NOT NULL,
@@ -49,10 +49,11 @@ def _create_user_table(db):
4949
is_profile_completed BOOLEAN DEFAULT (FALSE),
5050
is_confirmed BOOLEAN DEFAULT (FALSE),
5151
confirmed_on DATETIME DEFAULT NULL
52-
);
52+
) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ;
5353
"""
5454
)
5555
c.execute(ENABLE_SQL_NOTES)
56+
c.close()
5657

5758

5859
def _create_tags_table(db):
@@ -66,10 +67,11 @@ def _create_tags_table(db):
6667
id INT auto_increment PRIMARY KEY,
6768
user_id INT NOT NULL,
6869
name VARCHAR(256)
69-
)
70+
) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ;
7071
"""
7172
)
7273
c.execute(ENABLE_SQL_NOTES)
74+
c.close()
7375

7476

7577
def _create_views_table(db):
@@ -84,10 +86,11 @@ def _create_views_table(db):
8486
profile_id INT NOT NULL,
8587
viewer_id INT NOT NULL,
8688
dt_seen DATETIME DEFAULT NOW()
87-
)
89+
) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ;
8890
"""
8991
)
9092
c.execute(ENABLE_SQL_NOTES)
93+
c.close()
9194

9295

9396
def _create_reports_table(db):
@@ -105,10 +108,11 @@ def _create_reports_table(db):
105108
details VARCHAR(256),
106109
reason ENUM('harassment', 'bot', 'spam', 'inappropriate content'),
107110
status ENUM('processing request', 'insufficient evidence', 'convicted and banned')
108-
)
111+
) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ;
109112
"""
110113
)
111114
c.execute(ENABLE_SQL_NOTES)
115+
c.close()
112116

113117

114118
def _create_likes_table(db):
@@ -124,10 +128,11 @@ def _create_likes_table(db):
124128
liker_id INT NOT NULL,
125129
dt_liked DATETIME DEFAULT NOW(),
126130
is_superlike BOOLEAN DEFAULT FALSE
127-
)
131+
) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ;
128132
"""
129133
)
130134
c.execute(ENABLE_SQL_NOTES)
135+
c.close()
131136

132137

133138
def _create_matches_table(db):
@@ -142,11 +147,12 @@ def _create_matches_table(db):
142147
user_1 INT NOT NULL,
143148
user_2 INT NOT NULL,
144149
dt_matched DATETIME DEFAULT NOW()
145-
)
150+
) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ;
146151
"""
147152
)
148153
# TODO: Is conversation started boolean ?
149154
c.execute(ENABLE_SQL_NOTES)
155+
c.close()
150156

151157

152158
def _create_messages_table(db):
@@ -165,10 +171,11 @@ def _create_messages_table(db):
165171
content LONGTEXT NOT NULL,
166172
is_liked BOOLEAN DEFAULT FALSE,
167173
is_seen BOOLEAN DEFAULT FALSE
168-
)
174+
) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ;
169175
"""
170176
)
171177
c.execute(ENABLE_SQL_NOTES)
178+
c.close()
172179

173180

174181
def create_tables(db):

0 commit comments

Comments
 (0)