Jacob
Jacob
DTDrizzle Team
Created by Jacob on 10/17/2024 in #help
Drizzle/better-auth + Local PSQL
Thanks Darren 😄
30 replies
DTDrizzle Team
Created by Jacob on 10/17/2024 in #help
Drizzle/better-auth + Local PSQL
Okej then
30 replies
DTDrizzle Team
Created by Jacob on 10/17/2024 in #help
Drizzle/better-auth + Local PSQL
Basically what your saying is that my index.ts file should be passed into my drizzle.config.ts file right?
30 replies
DTDrizzle Team
Created by Jacob on 10/17/2024 in #help
Drizzle/better-auth + Local PSQL
So where can I find more info about how to do that exactly because I mostly just copied over code from the docs. I now need to understand exactly how it works
30 replies
DTDrizzle Team
Created by Jacob on 10/17/2024 in #help
Drizzle/better-auth + Local PSQL
What does that mean exactly.
30 replies
DTDrizzle Team
Created by Jacob on 10/17/2024 in #help
Drizzle/better-auth + Local PSQL
No description
30 replies
DTDrizzle Team
Created by Jacob on 10/17/2024 in #help
Drizzle/better-auth + Local PSQL
No description
30 replies
DTDrizzle Team
Created by Jacob on 10/17/2024 in #help
Drizzle/better-auth + Local PSQL
CREATE TABLE IF NOT EXISTS "account" (
"id" text PRIMARY KEY NOT NULL,
"accountId" text NOT NULL,
"providerId" text NOT NULL,
"userId" text NOT NULL,
"accessToken" text,
"refreshToken" text,
"idToken" text,
"expiresAt" timestamp,
"password" text
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "session" (
"id" text PRIMARY KEY NOT NULL,
"expiresAt" timestamp NOT NULL,
"ipAddress" text,
"userAgent" text,
"userId" text NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "user" (
"id" text PRIMARY KEY NOT NULL,
"name" text NOT NULL,
"email" text NOT NULL,
"emailVerified" boolean NOT NULL,
"image" text,
"createdAt" timestamp NOT NULL,
"updatedAt" timestamp NOT NULL,
CONSTRAINT "user_email_unique" UNIQUE("email")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "verification" (
"id" text PRIMARY KEY NOT NULL,
"identifier" text NOT NULL,
"value" text NOT NULL,
"expiresAt" timestamp NOT NULL
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "account" ADD CONSTRAINT "account_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "session" ADD CONSTRAINT "session_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
CREATE TABLE IF NOT EXISTS "account" (
"id" text PRIMARY KEY NOT NULL,
"accountId" text NOT NULL,
"providerId" text NOT NULL,
"userId" text NOT NULL,
"accessToken" text,
"refreshToken" text,
"idToken" text,
"expiresAt" timestamp,
"password" text
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "session" (
"id" text PRIMARY KEY NOT NULL,
"expiresAt" timestamp NOT NULL,
"ipAddress" text,
"userAgent" text,
"userId" text NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "user" (
"id" text PRIMARY KEY NOT NULL,
"name" text NOT NULL,
"email" text NOT NULL,
"emailVerified" boolean NOT NULL,
"image" text,
"createdAt" timestamp NOT NULL,
"updatedAt" timestamp NOT NULL,
CONSTRAINT "user_email_unique" UNIQUE("email")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "verification" (
"id" text PRIMARY KEY NOT NULL,
"identifier" text NOT NULL,
"value" text NOT NULL,
"expiresAt" timestamp NOT NULL
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "account" ADD CONSTRAINT "account_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "session" ADD CONSTRAINT "session_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
30 replies
DTDrizzle Team
Created by Jacob on 10/17/2024 in #help
Drizzle/better-auth + Local PSQL
No description
30 replies
DTDrizzle Team
Created by Jacob on 10/17/2024 in #help
Drizzle/better-auth + Local PSQL
Oh yeah. As I said earlier it does generate that directory
30 replies
DTDrizzle Team
Created by Jacob on 10/17/2024 in #help
Drizzle/better-auth + Local PSQL
Do you mean inside pgadmin itself?
30 replies
DTDrizzle Team
Created by Jacob on 10/17/2024 in #help
Drizzle/better-auth + Local PSQL
No description
30 replies
DTDrizzle Team
Created by Jacob on 10/17/2024 in #help
Drizzle/better-auth + Local PSQL
I bascially took what ever was in the auth-schema.ts and and placed it inside of the schema.ts file. I don't really use the other file. It's only usecase was to generate the info shown above. Yes I did run those commands and when I run the npx drizzle-kit generate it says No schema changes, nothing to migrate because I have already ran it before. This only changes in case I delete the drizzle directory inside of my project.
30 replies
DTDrizzle Team
Created by Jacob on 10/17/2024 in #help
Drizzle/better-auth + Local PSQL
From this point on I sort of move into the better-auth installation part of their docs and do the steps that are. I run the command of npx @better-auth/cli generate which gives me the back a auth-schema.ts file. That sort of looks like this
import { pgTable, text, timestamp, boolean } from "drizzle-orm/pg-core";

export const user = pgTable("user", {
id: text("id").primaryKey(),
name: text("name").notNull(),
email: text("email").notNull().unique(),
emailVerified: boolean("emailVerified").notNull(),
image: text("image"),
createdAt: timestamp("createdAt").notNull(),
updatedAt: timestamp("updatedAt").notNull(),
});

export const session = pgTable("session", {
id: text("id").primaryKey(),
expiresAt: timestamp("expiresAt").notNull(),
ipAddress: text("ipAddress"),
userAgent: text("userAgent"),
userId: text("userId")
.notNull()
.references(() => user.id),
});

export const account = pgTable("account", {
id: text("id").primaryKey(),
accountId: text("accountId").notNull(),
providerId: text("providerId").notNull(),
userId: text("userId")
.notNull()
.references(() => user.id),
accessToken: text("accessToken"),
refreshToken: text("refreshToken"),
idToken: text("idToken"),
expiresAt: timestamp("expiresAt"),
password: text("password"),
});

export const verification = pgTable("verification", {
id: text("id").primaryKey(),
identifier: text("identifier").notNull(),
value: text("value").notNull(),
expiresAt: timestamp("expiresAt").notNull(),
});
import { pgTable, text, timestamp, boolean } from "drizzle-orm/pg-core";

export const user = pgTable("user", {
id: text("id").primaryKey(),
name: text("name").notNull(),
email: text("email").notNull().unique(),
emailVerified: boolean("emailVerified").notNull(),
image: text("image"),
createdAt: timestamp("createdAt").notNull(),
updatedAt: timestamp("updatedAt").notNull(),
});

export const session = pgTable("session", {
id: text("id").primaryKey(),
expiresAt: timestamp("expiresAt").notNull(),
ipAddress: text("ipAddress"),
userAgent: text("userAgent"),
userId: text("userId")
.notNull()
.references(() => user.id),
});

export const account = pgTable("account", {
id: text("id").primaryKey(),
accountId: text("accountId").notNull(),
providerId: text("providerId").notNull(),
userId: text("userId")
.notNull()
.references(() => user.id),
accessToken: text("accessToken"),
refreshToken: text("refreshToken"),
idToken: text("idToken"),
expiresAt: timestamp("expiresAt"),
password: text("password"),
});

export const verification = pgTable("verification", {
id: text("id").primaryKey(),
identifier: text("identifier").notNull(),
value: text("value").notNull(),
expiresAt: timestamp("expiresAt").notNull(),
});
I then try to run this npx drizzle-kit migrate to migrate things over and I get this error.
npx drizzle-kit migrate
No config path provided, using default 'drizzle.config.ts'
Reading config file '/home/jacob/github/next/better-auth/drizzle.config.ts'
Using 'pg' driver for database querying
npx drizzle-kit migrate
No config path provided, using default 'drizzle.config.ts'
Reading config file '/home/jacob/github/next/better-auth/drizzle.config.ts'
Using 'pg' driver for database querying
30 replies