4.0.3: Исправлен user_id в weekly_goals
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m34s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m34s
This commit is contained in:
@@ -4345,7 +4345,8 @@ func (a *App) setupWeeklyGoals() error {
|
|||||||
min_goal_score,
|
min_goal_score,
|
||||||
max_goal_score,
|
max_goal_score,
|
||||||
max_score,
|
max_score,
|
||||||
priority
|
priority,
|
||||||
|
user_id
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
p.id,
|
p.id,
|
||||||
@@ -4367,7 +4368,8 @@ func (a *App) setupWeeklyGoals() error {
|
|||||||
WHEN p.priority = 2 THEN gm.median_score * 1.3
|
WHEN p.priority = 2 THEN gm.median_score * 1.3
|
||||||
ELSE gm.median_score * 1.2
|
ELSE gm.median_score * 1.2
|
||||||
END AS max_score,
|
END AS max_score,
|
||||||
p.priority
|
p.priority,
|
||||||
|
p.user_id
|
||||||
FROM projects p
|
FROM projects p
|
||||||
CROSS JOIN current_info ci
|
CROSS JOIN current_info ci
|
||||||
LEFT JOIN goal_metrics gm ON p.id = gm.project_id
|
LEFT JOIN goal_metrics gm ON p.id = gm.project_id
|
||||||
@@ -4376,7 +4378,8 @@ func (a *App) setupWeeklyGoals() error {
|
|||||||
SET
|
SET
|
||||||
min_goal_score = EXCLUDED.min_goal_score,
|
min_goal_score = EXCLUDED.min_goal_score,
|
||||||
max_goal_score = EXCLUDED.max_goal_score,
|
max_goal_score = EXCLUDED.max_goal_score,
|
||||||
priority = EXCLUDED.priority
|
priority = EXCLUDED.priority,
|
||||||
|
user_id = EXCLUDED.user_id
|
||||||
`
|
`
|
||||||
|
|
||||||
_, err := a.DB.Exec(setupQuery)
|
_, err := a.DB.Exec(setupQuery)
|
||||||
@@ -5090,10 +5093,13 @@ func (a *App) moveProjectHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Теперь обновляем оставшиеся записи (те, которые не конфликтуют)
|
// Теперь обновляем оставшиеся записи (те, которые не конфликтуют)
|
||||||
|
// Обновляем project_id и user_id из целевого проекта
|
||||||
_, err = tx.Exec(`
|
_, err = tx.Exec(`
|
||||||
UPDATE weekly_goals
|
UPDATE weekly_goals wg
|
||||||
SET project_id = $1
|
SET project_id = $1, user_id = p.user_id
|
||||||
WHERE project_id = $2
|
FROM projects p
|
||||||
|
WHERE wg.project_id = $2
|
||||||
|
AND p.id = $1
|
||||||
`, finalProjectID, req.ID)
|
`, finalProjectID, req.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error updating weekly_goals: %v", err)
|
log.Printf("Error updating weekly_goals: %v", err)
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
-- Rollback migration: This migration cannot be automatically rolled back
|
||||||
|
-- The user_id values were corrected from projects.user_id, so reverting would
|
||||||
|
-- require knowing the original incorrect values, which is not possible.
|
||||||
|
-- If rollback is needed, you would need to manually restore from a backup.
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
-- Migration: Fix weekly_goals.user_id by updating it from projects.user_id
|
||||||
|
-- This migration fixes the issue where weekly_goals.user_id was incorrectly set to NULL or wrong user_id
|
||||||
|
-- It updates all weekly_goals records to have the correct user_id from their associated project
|
||||||
|
|
||||||
|
UPDATE weekly_goals wg
|
||||||
|
SET user_id = p.user_id
|
||||||
|
FROM projects p
|
||||||
|
WHERE wg.project_id = p.id
|
||||||
|
AND (wg.user_id IS NULL OR wg.user_id != p.user_id);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "play-life-web",
|
"name": "play-life-web",
|
||||||
"version": "4.0.2",
|
"version": "4.0.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
Reference in New Issue
Block a user