Fix scheduled notification creator FK and default app timezone to EAT.
Point scheduled_notifications.created_by at team_members so admin JWT IDs validate, and set TZ=Africa/Addis_Ababa for the Docker app service. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
82e895010b
commit
880bdfb4b7
|
|
@ -0,0 +1,6 @@
|
|||
ALTER TABLE scheduled_notifications
|
||||
DROP CONSTRAINT IF EXISTS scheduled_notifications_created_by_fkey;
|
||||
|
||||
ALTER TABLE scheduled_notifications
|
||||
ADD CONSTRAINT scheduled_notifications_created_by_fkey
|
||||
FOREIGN KEY (created_by) REFERENCES users(id);
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
-- scheduled_notifications.created_by is the admin actor who scheduled the job.
|
||||
-- Admin panel auth (POST /team/login) JWT user_id is team_members.id, not users.id.
|
||||
|
||||
ALTER TABLE scheduled_notifications
|
||||
DROP CONSTRAINT IF EXISTS scheduled_notifications_created_by_fkey;
|
||||
|
||||
-- Remap legacy rows that stored platform users.id to a valid team member when possible.
|
||||
UPDATE scheduled_notifications sn
|
||||
SET created_by = tm.id
|
||||
FROM users u
|
||||
JOIN team_members tm ON LOWER(TRIM(tm.email)) = LOWER(TRIM(u.email))
|
||||
WHERE sn.created_by = u.id
|
||||
AND NOT EXISTS (SELECT 1 FROM team_members existing WHERE existing.id = sn.created_by);
|
||||
|
||||
-- Fallback: assign orphaned created_by values to the earliest team member.
|
||||
UPDATE scheduled_notifications sn
|
||||
SET created_by = (SELECT id FROM team_members ORDER BY id LIMIT 1)
|
||||
WHERE NOT EXISTS (SELECT 1 FROM team_members tm WHERE tm.id = sn.created_by);
|
||||
|
||||
ALTER TABLE scheduled_notifications
|
||||
ADD CONSTRAINT scheduled_notifications_created_by_fkey
|
||||
FOREIGN KEY (created_by) REFERENCES team_members(id);
|
||||
|
|
@ -106,6 +106,7 @@ services:
|
|||
environment:
|
||||
- DB_URL=postgresql://root:secret@postgres:5432/gh?sslmode=disable
|
||||
- MONGO_URI=mongodb://root:secret@mongo:27017
|
||||
- TZ=Africa/Addis_Ababa
|
||||
depends_on:
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ type ScheduledNotification struct {
|
|||
SentAt *time.Time `json:"sent_at,omitempty"`
|
||||
CancelledAt *time.Time `json:"cancelled_at,omitempty"`
|
||||
|
||||
CreatedBy int64 `json:"created_by"`
|
||||
CreatedBy int64 `json:"created_by"` // team_members.id of the staff actor who scheduled the job
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user