ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/missionmatch / db/migrations/0059_touch_last_login.sql

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/missionmatch / db/migrations/0059_touch_last_login.sql
DateNot specified in source
RepositoryJanady13/missionmatch
Revision720d47fae476b0d38477ae4401697d372b1ea2bc
Branchfeature/opportunity-to-outcome
Path or archive memberdb/migrations/0059_touch_last_login.sql
Original SHA-256fef2eb31de60d4c25fa7f0053e6e20892908af5daf446c057617937b57978da9
Git blob SHAd3a9c18331865a96156d2a1d2046bbdcf136c0f5
Reading-copy SHA-256fef2eb31de60d4c25fa7f0053e6e20892908af5daf446c057617937b57978da9

Original source ↗

Every recorded occurrence

These 2 records contain identical original source bytes. Their paths and revisions remain part of the archive.

Original recordBranch or archiveRevision / identifierOriginal location
Janady13/missionmatch / db/migrations/0059_touch_last_login.sqlfeature/opportunity-to-outcome720d47fae476b0d38477ae4401697d372b1ea2bcOpen original
Janady13/missionmatch / db/migrations/0059_touch_last_login.sqlfeature/aioe-upgrade2178e7298d0e5d9af83afa12402fd587f0ba6ed8Open original

Recovered source transcript

-- +goose Up -- Records the last sign in, which nothing has ever done. -- -- users.last_login_at and its generated query have existed since the foundation migration and no code -- path called them, so the column was NULL for every account that had ever signed in. The People screen -- added in phase 19 showed "never signed in" beside the owner who was reading it. -- -- The first attempt at a fix was a plain UPDATE from the auth service, and it silently did nothing. -- Login happens BEFORE any tenant context exists, so app.current_org_id is unset and the row level -- policy on users matches zero rows. Every other privileged auth write goes through a SECURITY DEFINER -- function for exactly this reason; the stamp needs the same treatment rather than an exception. -- -- Scoped as tightly as the job allows: it writes one column on one row identified by primary key, and it -- can neither read nor return anything. -- +goose StatementBegin CREATE OR REPLACE FUNCTION auth_touch_last_login(p_user_id uuid) RETURNS void AS $$ BEGIN UPDATE users SET last_login_at = now(), updated_at = now() WHERE id = p_user_id; END; $$ LANGUAGE plpgsql SECURITY DEFINER SET search_path = public, pg_temp; -- +goose StatementEnd REVOKE ALL ON FUNCTION auth_touch_last_login(uuid) FROM PUBLIC; GRANT EXECUTE ON FUNCTION auth_touch_last_login(uuid) TO missionmatch_app; -- +goose Down DROP FUNCTION IF EXISTS auth_touch_last_login(uuid);

Search equations, builds, manuscript text, and recovered sources.