Skip services.group_title copy when the legacy column is absent.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -15,13 +15,23 @@ export async function ensureServicesSchema(payload: Payload) {
|
|||||||
await exec(
|
await exec(
|
||||||
payload,
|
payload,
|
||||||
sql`
|
sql`
|
||||||
UPDATE services_locales AS sl
|
DO $$ BEGIN
|
||||||
SET group_title = s.group_title
|
IF EXISTS (
|
||||||
FROM services AS s
|
SELECT 1
|
||||||
WHERE sl._parent_id = s.id
|
FROM information_schema.columns
|
||||||
AND sl._locale = 'ru'
|
WHERE table_schema = 'public'
|
||||||
AND (sl.group_title IS NULL OR sl.group_title = '')
|
AND table_name = 'services'
|
||||||
AND s.group_title IS NOT NULL
|
AND column_name = 'group_title'
|
||||||
|
) THEN
|
||||||
|
UPDATE services_locales AS sl
|
||||||
|
SET group_title = s.group_title
|
||||||
|
FROM services AS s
|
||||||
|
WHERE sl._parent_id = s.id
|
||||||
|
AND sl._locale = 'ru'
|
||||||
|
AND (sl.group_title IS NULL OR sl.group_title = '')
|
||||||
|
AND s.group_title IS NOT NULL;
|
||||||
|
END IF;
|
||||||
|
END $$
|
||||||
`,
|
`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user