Adding relations for reset tokens.

This commit is contained in:
Bradley Shellnut 2024-03-01 18:01:45 -08:00
parent f3cb74ac7a
commit 24004c4533
4 changed files with 1346 additions and 0 deletions

View file

@ -0,0 +1,12 @@
CREATE TABLE IF NOT EXISTS "password_reset_tokens" (
"id" varchar(255) PRIMARY KEY NOT NULL,
"user_id" varchar(255) NOT NULL,
"expires_at" timestamp (6) with time zone,
"created_at" timestamp (6) with time zone DEFAULT now()
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "password_reset_tokens" ADD CONSTRAINT "password_reset_tokens_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;

File diff suppressed because it is too large Load diff

View file

@ -106,6 +106,13 @@
"when": 1708479971410,
"tag": "0014_organic_morlocks",
"breakpoints": true
},
{
"idx": 15,
"version": "5",
"when": 1709344835732,
"tag": "0015_awesome_gabe_jones",
"breakpoints": true
}
]
}

View file

@ -161,6 +161,13 @@ export const password_reset_tokens = pgTable('password_reset_tokens', {
}).default(sql`now()`)
});
export const password_reset_token_relations = relations(password_reset_tokens, ({ one }) => ({
user: one(users, {
fields: [password_reset_tokens.user_id],
references: [users.id]
})
}));
export const collections = pgTable('collections', {
id: varchar('id', {
length: 255