Skip to content

Commit 9c1097f

Browse files
authored
Merge pull request #15 from encryption4all/feat/add-users-table
feat: add users table and Yivi-based registration
2 parents 8e40573 + 2b982aa commit 9c1097f

33 files changed

Lines changed: 2042 additions & 226 deletions

File tree

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ FF_PORTAL_API_KEYS=false
1616
FF_PORTAL_ORG_INFO=false
1717
FF_PORTAL_EMAIL_LOG=false
1818
FF_PORTAL_DNS=false
19+
FF_PORTAL_MEMBERS=false
1920
FF_ADMIN_PANEL=false
2021
FF_ADMIN_ORG_STATUS=false
2122
FF_ADMIN_AUDIT_LOG=false
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
CREATE TABLE "users" (
2+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3+
"email" varchar(256) NOT NULL,
4+
"full_name" varchar(256) NOT NULL,
5+
"phone" varchar(32),
6+
"org_id" uuid NOT NULL,
7+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
8+
CONSTRAINT "users_email_unique" UNIQUE("email")
9+
);
10+
--> statement-breakpoint
11+
ALTER TABLE "organizations" RENAME COLUMN "email" TO "signing_email"; -- safe: new column name, code updated in same deploy
12+
--> statement-breakpoint
13+
ALTER TABLE "organizations" ADD COLUMN "contact_user_id" uuid;--> statement-breakpoint
14+
ALTER TABLE "organizations" DROP COLUMN "contact_name"; -- safe: replaced by users.full_name via contact_user_id
15+
--> statement-breakpoint
16+
ALTER TABLE "organizations" DROP COLUMN "phone"; -- safe: moved to users table
17+
--> statement-breakpoint
18+
ALTER TABLE "sessions" ADD COLUMN "user_id" uuid;--> statement-breakpoint
19+
ALTER TABLE "users" ADD CONSTRAINT "users_org_id_organizations_id_fk" FOREIGN KEY ("org_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
20+
CREATE INDEX "idx_users_org" ON "users" USING btree ("org_id"); -- safe: new table, no existing rows
21+
--> statement-breakpoint
22+
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;

0 commit comments

Comments
 (0)