CyberCipher
CyberCipher
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
Thanks! @Kuba
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
I'm also learning sveltekit BTW. I chose this framework as I wanted to learn it.
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
I see. Perhaps I should move the drizzle client config to svelte's "backend" thing..
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
I'll ask in svelte discord channel for this.
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
Ah! I see what you mean.
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
I am using sveltekit.
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
How can I handle this better?
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
and I do infact have a new user,
drizzle=# select * from core.user;
id | username | email | token | hashed_password | avatar_url | user_role | last_login | created_at
--------------------------------------+----------+--------------+-------+-----------------+------------+-----------+------------+-------------------------------
e7552979-fc72-406b-8158-da06afd7e5c1 | foo1 | [email protected] | | foo1bar1 | asdads | USER | | 2024-10-01 17:55:55.456252+00
(1 row)
drizzle=# select * from core.user;
id | username | email | token | hashed_password | avatar_url | user_role | last_login | created_at
--------------------------------------+----------+--------------+-------+-----------------+------------+-----------+------------+-------------------------------
e7552979-fc72-406b-8158-da06afd7e5c1 | foo1 | [email protected] | | foo1bar1 | asdads | USER | | 2024-10-01 17:55:55.456252+00
(1 row)
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
interesting, in db.ts I did,
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import * as schema from "./schema";

const client = postgres(import.meta.env.VITE_DATABASE_URL as string);

export const db = drizzle(client, { schema, logger: true });
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import * as schema from "./schema";

const client = postgres(import.meta.env.VITE_DATABASE_URL as string);

export const db = drizzle(client, { schema, logger: true });
and it looks like its not crashing anymore..
 npm run dev

> vite dev


VITE v5.4.8 ready in 942 ms

➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
Query: insert into "core"."user" ("id", "username", "email", "token", "hashed_password", "avatar_url", "user_role", "last_login", "created_at") values default, $1, $2, default, $3, $4, default, default, default) returning "id", "username", "email", "token", "hashed_password", "avatar_url", "user_role", last_login", "created_at" -- params: ["foo1", "[email protected]", "foo1bar1", "asdads"]
 npm run dev

> vite dev


VITE v5.4.8 ready in 942 ms

➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
Query: insert into "core"."user" ("id", "username", "email", "token", "hashed_password", "avatar_url", "user_role", "last_login", "created_at") values default, $1, $2, default, $3, $4, default, default, default) returning "id", "username", "email", "token", "hashed_password", "avatar_url", "user_role", last_login", "created_at" -- params: ["foo1", "[email protected]", "foo1bar1", "asdads"]
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
so I have now these 2 fields in .env file,
DATABASE_URL=postgres://drizzle:drizzle@localhost:5432/drizzle
VITE_DATABASE_URL=postgres://drizzle:drizzle@localhost:5432/drizzle
DATABASE_URL=postgres://drizzle:drizzle@localhost:5432/drizzle
VITE_DATABASE_URL=postgres://drizzle:drizzle@localhost:5432/drizzle
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
I would also have to change the same in drizzle.config.ts as well I guess? otherwise how would it pick it up?
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
you mean rename the DATABASE_URL to VITE_DATABASE_URL in .env file and use import.meta.env.VITE_DATABASE_URL in db.ts instead?
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
in which file? everywhere?
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
Yes, a .env file and I use the dotenv package I think.
"dotenv": "^16.4.5",
"dotenv": "^16.4.5",
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
Can this migrate.ts file inherit this from drizzle.config.ts?
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
I see.
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
but once again it crashes,
 npm run dev

> vite dev


VITE v5.4.8 ready in 891 ms

➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
Query: insert into "core"."user" ("id", "username", "email", "token", "hashed_password", "avatar_url", "user_role", "last_login", "created_at") values (default, $1, $2, default, $3, $4, default, default, default) returning "id", "username", "email", "token", "hashed_password", "avatar_url", "user_role", "last_login", "created_at" -- params: ["foo1", "[email protected]", "foo1bar1", "asdads"]
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^

PostgresError: password authentication failed for user "apoorv"
at ErrorResponse (file:///home/apoorv/repos/sonora/node_modules/postgres/src/connection.js:788:26)
at handle (file:///home/apoorv/repos/sonora/node_modules/postgres/src/connection.js:474:6)
at Socket.data (file:///home/apoorv/repos/sonora/node_modules/postgres/src/connection.js:315:9)
at Socket.emit (node:events:517:28)
at addChunk (node:internal/streams/readable:368:12)
at readableAddChunk (node:internal/streams/readable:341:9)
at Readable.push (node:internal/streams/readable:278:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
at TCP.callbackTrampoline (node:internal/async_hooks:128:17) {
severity_local: 'FATAL',
severity: 'FATAL',
code: '28P01',
file: 'auth.c',
line: '321',
routine: 'auth_failed'
}

Node.js v18.19.0
 npm run dev

> vite dev


VITE v5.4.8 ready in 891 ms

➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
Query: insert into "core"."user" ("id", "username", "email", "token", "hashed_password", "avatar_url", "user_role", "last_login", "created_at") values (default, $1, $2, default, $3, $4, default, default, default) returning "id", "username", "email", "token", "hashed_password", "avatar_url", "user_role", "last_login", "created_at" -- params: ["foo1", "[email protected]", "foo1bar1", "asdads"]
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^

PostgresError: password authentication failed for user "apoorv"
at ErrorResponse (file:///home/apoorv/repos/sonora/node_modules/postgres/src/connection.js:788:26)
at handle (file:///home/apoorv/repos/sonora/node_modules/postgres/src/connection.js:474:6)
at Socket.data (file:///home/apoorv/repos/sonora/node_modules/postgres/src/connection.js:315:9)
at Socket.emit (node:events:517:28)
at addChunk (node:internal/streams/readable:368:12)
at readableAddChunk (node:internal/streams/readable:341:9)
at Readable.push (node:internal/streams/readable:278:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
at TCP.callbackTrampoline (node:internal/async_hooks:128:17) {
severity_local: 'FATAL',
severity: 'FATAL',
code: '28P01',
file: 'auth.c',
line: '321',
routine: 'auth_failed'
}

Node.js v18.19.0
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
drizzle.config.ts,
import { defineConfig } from 'drizzle-kit';

export default defineConfig({
schema: "./src/lib/database/schema.ts",
out: "./src/lib/database/migrations",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL as string,
},
verbose: true,
strict: true
});

console.log(`DATABASE_URL: ${process.env.DATABASE_URL as string}`);
import { defineConfig } from 'drizzle-kit';

export default defineConfig({
schema: "./src/lib/database/schema.ts",
out: "./src/lib/database/migrations",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL as string,
},
verbose: true,
strict: true
});

console.log(`DATABASE_URL: ${process.env.DATABASE_URL as string}`);
 npm run db:generate

> [email protected] db:generate
> drizzle-kit generate --name=drizzle

No config path provided, using default 'drizzle.config.ts'
Reading config file '/home/apoorv/repos/sonora/drizzle.config.ts'
DATABASE_URL: postgres://drizzle:drizzle@localhost:5432/drizzle
10 tables
album 6 columns 2 indexes 2 fks
artist 3 columns 0 indexes 0 fks
artist_collaboration 2 columns 0 indexes 2 fks
artist_genre 2 columns 0 indexes 2 fks
genre 3 columns 0 indexes 0 fks
playlist 4 columns 1 indexes 1 fks
playlist_track 3 columns 2 indexes 2 fks
record_label 3 columns 0 indexes 0 fks
track 6 columns 2 indexes 2 fks
user 9 columns 1 indexes 0 fks

[✓] Your SQL migration file ➜ src/lib/database/migrations/0000_drizzle.sql :rocket:

~/repos/sonora via  v18.19.0
 npm run db:migrate

> [email protected] db:migrate
> tsx src/lib/database/migrate.ts
 npm run db:generate

> [email protected] db:generate
> drizzle-kit generate --name=drizzle

No config path provided, using default 'drizzle.config.ts'
Reading config file '/home/apoorv/repos/sonora/drizzle.config.ts'
DATABASE_URL: postgres://drizzle:drizzle@localhost:5432/drizzle
10 tables
album 6 columns 2 indexes 2 fks
artist 3 columns 0 indexes 0 fks
artist_collaboration 2 columns 0 indexes 2 fks
artist_genre 2 columns 0 indexes 2 fks
genre 3 columns 0 indexes 0 fks
playlist 4 columns 1 indexes 1 fks
playlist_track 3 columns 2 indexes 2 fks
record_label 3 columns 0 indexes 0 fks
track 6 columns 2 indexes 2 fks
user 9 columns 1 indexes 0 fks

[✓] Your SQL migration file ➜ src/lib/database/migrations/0000_drizzle.sql :rocket:

~/repos/sonora via  v18.19.0
 npm run db:migrate

> [email protected] db:migrate
> tsx src/lib/database/migrate.ts
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
in that case, I guess the migration one doesn't gets the URL from drizzle.config.ts?
57 replies
DTDrizzle Team
Created by CyberCipher on 9/30/2024 in #help
PostgresError: password authentication failed for user.
Oh! wait.. I just noticed.. its not DB_URL its DATABASE_URL, I have no idea how it got changed..
57 replies