Unify auth middleware and remove X-User-ID trust, add project_members authorization, sandbox workspaces via resolver, and admin-only reconcile by run_id. Introduce goose migrations with startup schema gate, fail closed when DB unavailable outside explicit ALLOW_IN_MEMORY, bundle web/dist in app Dockerfile, and remove frontend pseudo-login fallback.
24 lines
991 B
SQL
24 lines
991 B
SQL
-- +goose Up
|
|
CREATE TABLE IF NOT EXISTS project_members (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
project_id BIGINT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
user_id BIGINT NOT NULL,
|
|
project_role TEXT NOT NULL DEFAULT 'member',
|
|
status TEXT NOT NULL DEFAULT 'active',
|
|
joined_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
CONSTRAINT uq_project_member UNIQUE (project_id, user_id)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_project_members_user ON project_members(user_id);
|
|
CREATE INDEX IF NOT EXISTS idx_project_members_project ON project_members(project_id);
|
|
|
|
INSERT INTO project_members (project_id, user_id, project_role, status, joined_at, updated_at)
|
|
SELECT p.id, p.creator_user_id, 'owner', 'active', now(), now()
|
|
FROM projects p
|
|
WHERE p.creator_user_id IS NOT NULL AND p.creator_user_id > 0
|
|
ON CONFLICT (project_id, user_id) DO NOTHING;
|
|
|
|
-- +goose Down
|
|
DROP TABLE IF EXISTS project_members;
|