wlvz
wlvz
Explore posts from servers
DTDrizzle Team
Created by wlvz on 10/22/2023 in #help
db:push constraint is not found in the table
Hi, I'm using planetscale and trying to push to my db but I get the error: errno: 3821, sql: 'ALTER TABLE Subtopic DROP CONSTRAINT Subtopic_name_key;', sqlState: 'HY000', sqlMessage: target: database.-.primary: vttablet: rpc error: code = Unknown desc = Check constraint 'Subtopic_name_key' is not found in the table. (errno 3821) (sqlstate HY000) (CallerID: yc7blbqh18eaxxd6jg4n): Sql: "alter table Subtopic drop check Subtopic_name_key", BindVars: {REDACTED} Anyone know how I can fix this?
1 replies
DTDrizzle Team
Created by wlvz on 6/28/2023 in #help
Cannot read properties of undefined (reading 'connectionString')
In my drizzle.config.ts I have the code:
import type { Config } from "drizzle-kit";
import 'dotenv/config'

export default {
schema: "./lib/db/schema.ts",
out: "./drizzle",
connectionString: process.env.DATABASE_URL,
driver: "mysql2",
} satisfies Config;
import type { Config } from "drizzle-kit";
import 'dotenv/config'

export default {
schema: "./lib/db/schema.ts",
out: "./drizzle",
connectionString: process.env.DATABASE_URL,
driver: "mysql2",
} satisfies Config;
and when I go to run drizzle-kit introspect:mysql I get the error:
TypeError: Cannot read properties of undefined (reading 'connectionString').
TypeError: Cannot read properties of undefined (reading 'connectionString').
I checked my .env.local and DATABASE_URL is defined:
DATABASE_URL='mysql://abcd@aws.connect.psdb.cloud/username?ssl={"rejectUnauthorized":true}'
DATABASE_URL='mysql://abcd@aws.connect.psdb.cloud/username?ssl={"rejectUnauthorized":true}'
3 replies
DTDrizzle Team
Created by wlvz on 6/27/2023 in #help
Invalid input Only "mysql2" is available options for "--driver"
I'm trying to run drizzle-kit introspect:mysql by following the docs and I have the config file:
import type { Config } from "drizzle-kit";
import dotenv from "dotenv";
dotenv.config({ path: " .env.local" });

export default {
schema: "./lib/db/schema.ts",
out: "./drizzle",
connectionString: process.env.DATABASE_URL,
} satisfies Config;
import type { Config } from "drizzle-kit";
import dotenv from "dotenv";
dotenv.config({ path: " .env.local" });

export default {
schema: "./lib/db/schema.ts",
out: "./drizzle",
connectionString: process.env.DATABASE_URL,
} satisfies Config;
and in my package.json I have:
"introspect": "drizzle-kit introspect:mysql"
"introspect": "drizzle-kit introspect:mysql"
in my scripts. But when I go to run "npm run introspect" I get the error:
drizzle-kit: v0.19.2
drizzle-orm: v0.27.0

No config path provided, using default 'drizzle.config.ts'
Reading config file '/Users/user/Code/testproject/drizzle.config.ts'
Invalid input Only "mysql2" is available options for "--driver"
drizzle-kit: v0.19.2
drizzle-orm: v0.27.0

No config path provided, using default 'drizzle.config.ts'
Reading config file '/Users/user/Code/testproject/drizzle.config.ts'
Invalid input Only "mysql2" is available options for "--driver"
4 replies
DTDrizzle Team
Created by wlvz on 6/25/2023 in #help
net::ERR_NAME_NOT_RESOLVED
Hi, I was following the drizzle planetscale starter made by josh (https://github.com/joschan21/drizzle-planetscale-starter) and I came across some erros I didn't know how to fix. I have the following server component:
import { db } from "app/lib/db/index";
import { subjects } from "app/lib/db/schema"

export const runtime = 'edge'

export default async function Home() {
const subjectList = await db.select().from(subjects)

return (
<>
<p>my subjects:</p>
{subjectList.map((subject) => (
<div key={subject.id}>{subject.name}</div>
))}
</>
)
}
import { db } from "app/lib/db/index";
import { subjects } from "app/lib/db/schema"

export const runtime = 'edge'

export default async function Home() {
const subjectList = await db.select().from(subjects)

return (
<>
<p>my subjects:</p>
{subjectList.map((subject) => (
<div key={subject.id}>{subject.name}</div>
))}
</>
)
}
and when I try view this I get thousands of console errors (more errors just keep coming, its like an infinite amount of console errors) of just the same thing:
// index.js:115 POST https://undefined/psdb.v1alpha1.Database/Execute net::ERR_NAME_NOT_RESOLVED
// index.js:115 POST https://undefined/psdb.v1alpha1.Database/Execute net::ERR_NAME_NOT_RESOLVED
I'm pretty sure this has to do with my database URL, but I could be wrong My db/index looks like this:
import { drizzle } from "drizzle-orm/planetscale-serverless";
import { connect } from "@planetscale/database";

// create the connection
const connection = connect({
host: process.env.DATABASE_URL,
});

export const db = drizzle(connection);
import { drizzle } from "drizzle-orm/planetscale-serverless";
import { connect } from "@planetscale/database";

// create the connection
const connection = connect({
host: process.env.DATABASE_URL,
});

export const db = drizzle(connection);
and my drizzle.config.ts looks like this:
import type { Config } from "drizzle-kit";

export default {
schema: "./app/lib/db/schema.ts",
out: "./drizzle",
dbCredentials: {
connectionString: process.env.DATABASE_URL,
}
} satisfies Config;
import type { Config } from "drizzle-kit";

export default {
schema: "./app/lib/db/schema.ts",
out: "./drizzle",
dbCredentials: {
connectionString: process.env.DATABASE_URL,
}
} satisfies Config;
my .env looks like this:
DATABASE_URL='mysql:url@aws.connect.psdb.cloud/mydbname?ssl={"rejectUnauthorized":true}'
DATABASE_URL='mysql:url@aws.connect.psdb.cloud/mydbname?ssl={"rejectUnauthorized":true}'
with ?ssl={"rejectUnauthorized":true} coming from the docs. any idea on how to fix this? thanks
3 replies