fix: pass tags as native arrays not JSON strings in data migration
Some checks failed
Build and Push Backend Image / build (push) Successful in 38s
Build and Push Frontend Image / build (push) Has been cancelled

PostgreSQL text[] columns require native array values, not JSON strings.
Parse string tags from Directus and pass as JS arrays directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 19:36:04 +01:00
parent 480369aa4e
commit fbafbeca5d

View File

@@ -126,7 +126,7 @@ async function migrateUsers() {
if (tagsRes.rows[0]?.tags) { if (tagsRes.rows[0]?.tags) {
tags = Array.isArray(tagsRes.rows[0].tags) tags = Array.isArray(tagsRes.rows[0].tags)
? tagsRes.rows[0].tags ? tagsRes.rows[0].tags
: JSON.parse(tagsRes.rows[0].tags || "[]"); : JSON.parse(String(tagsRes.rows[0].tags || "[]"));
} }
} catch {} } catch {}
@@ -144,7 +144,7 @@ async function migrateUsers() {
user.artist_name, user.artist_name,
user.slug, user.slug,
user.description, user.description,
JSON.stringify(tags), tags,
role, role,
user.avatar, user.avatar,
true, true,
@@ -203,7 +203,7 @@ async function migrateArticles() {
article.excerpt, article.excerpt,
article.content, article.content,
article.image, article.image,
Array.isArray(article.tags) ? JSON.stringify(article.tags) : article.tags, Array.isArray(article.tags) ? article.tags : JSON.parse(String(article.tags || "[]")),
article.publish_date, article.publish_date,
article.author, article.author,
article.category, article.category,
@@ -240,7 +240,7 @@ async function migrateVideos() {
video.description, video.description,
video.image, video.image,
video.movie, video.movie,
Array.isArray(video.tags) ? JSON.stringify(video.tags) : video.tags, Array.isArray(video.tags) ? video.tags : JSON.parse(String(video.tags || "[]")),
video.upload_date, video.upload_date,
video.premium, video.premium,
video.featured, video.featured,
@@ -354,7 +354,7 @@ async function migrateRecordings() {
: JSON.stringify(recording.device_info), : JSON.stringify(recording.device_info),
recording.user_id, recording.user_id,
recording.status, recording.status,
Array.isArray(recording.tags) ? JSON.stringify(recording.tags) : recording.tags, Array.isArray(recording.tags) ? recording.tags : JSON.parse(String(recording.tags || "[]")),
recording.linked_video, recording.linked_video,
recording.public, recording.public,
recording.original_recording_id, recording.original_recording_id,