nullable fields
All checks were successful
Deploy to Server / deploy (push) Successful in 33s

This commit is contained in:
2026-04-10 20:08:35 -05:00
parent d1141a7b3a
commit 3ffea6a92b
3 changed files with 21 additions and 13 deletions

View File

@@ -112,10 +112,16 @@ CREATE INDEX IF NOT EXISTS protocols_user_id_idx ON protocols(user_id);
-- User profile — lab defaults pre-filled on chemical entries
CREATE TABLE IF NOT EXISTS user_profile (
user_id TEXT NOT NULL PRIMARY KEY REFERENCES "user"("id") ON DELETE CASCADE,
pi_first_name TEXT NOT NULL,
bldg_code TEXT NOT NULL,
lab TEXT NOT NULL,
pi_first_name TEXT,
bldg_code TEXT,
lab TEXT,
contact TEXT,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- Allow existing deployments to have nullable profile fields.
-- DROP NOT NULL on an already-nullable column is a no-op in Postgres.
ALTER TABLE user_profile ALTER COLUMN pi_first_name DROP NOT NULL;
ALTER TABLE user_profile ALTER COLUMN bldg_code DROP NOT NULL;
ALTER TABLE user_profile ALTER COLUMN lab DROP NOT NULL;