New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
404 on localhost:4983/init Impossible to Load Drizzle Studio #366
Comments
I am getting the exact same issue on both 0.20.15 and 0.20.16 |
@versecafe Hey! Can you please share your schema and logs from browser console? |
import {
boolean,
datetime,
index,
int,
json,
mysqlEnum,
mysqlTable,
primaryKey,
text,
varchar,
} from "drizzle-orm/mysql-core";
const languages = mysqlEnum("language", [
"en",
"es",
"fr",
"de",
"it",
"pt",
"nl",
]).notNull();
export const answerTranslationsTable = mysqlTable(
"answer_translations",
{
answerId: int("answer_id")
.notNull()
.references(() => answersTable.id),
language: languages,
text: varchar("text", { length: 1023 }).notNull(),
},
(table) => {
return {
pk: primaryKey({
columns: [table.answerId, table.language],
}),
};
},
);
export interface Dimension {
dimension: string;
position: number;
}
export const answersTable = mysqlTable(
"answers",
{
id: int("id").autoincrement().notNull().primaryKey(),
questionId: int("question_id")
.notNull()
.references(() => questionsTable.id),
text: varchar("text", { length: 1023 }).notNull(),
imageUrl: varchar("image_url", { length: 1023 }),
dimensions: json("dimensions").$type<Dimension[]>().notNull(),
},
(table) => {
return {
questionAnswersIdx: index("question_answers_index").on(table.questionId),
};
},
);
export const articlesTable = mysqlTable("articles", {
authorId: varchar("author_id", { length: 255 }).references(
() => usersTable.id,
),
title: varchar("title", { length: 255 }).notNull(),
content: text("content").notNull(),
createdAt: datetime("created_at").notNull(),
imageUrl: varchar("image_url", { length: 1023 }).notNull(),
slug: varchar("slug", { length: 255 }).notNull().primaryKey(),
language: languages.default("en"),
site: mysqlEnum("site", ["psychometrica", "shared-smiles", "all"])
.default("all")
.notNull(),
published: boolean("published").default(false).notNull(),
description: varchar("description", { length: 255 }).notNull(),
});
export const communitiesTable = mysqlTable("communities", {
id: int("id").autoincrement().notNull().primaryKey(),
published: boolean("published").default(false).notNull(),
name: varchar("name", { length: 255 }).notNull(),
description: varchar("description", { length: 1023 }).notNull(),
imageUrl: varchar("image_url", { length: 1023 }).notNull(),
content: text("content").notNull(),
weights: json("weights").notNull(),
slug: varchar("slug", { length: 255 }).notNull().unique(),
});
export const communityMembersTable = mysqlTable(
"community_members",
{
userId: varchar("user_id", { length: 255 })
.notNull()
.references(() => usersTable.id),
communityId: int("community_id")
.notNull()
.references(() => communitiesTable.id),
role: mysqlEnum("role", ["member", "moderator", "admin"])
.default("member")
.notNull(),
},
(table) => {
return {
pk: primaryKey({
columns: [table.userId, table.communityId],
}),
};
},
);
export const communityTranslationsTable = mysqlTable(
"community_translations",
{
communityId: int("community_id")
.notNull()
.references(() => communitiesTable.id),
language: languages,
name: varchar("name", { length: 255 }).notNull(),
description: varchar("description", { length: 1023 }).notNull(),
content: text("content").notNull(),
},
(table) => {
return {
pk: primaryKey({
columns: [table.communityId, table.language],
}),
};
},
);
export const oauthAccountsTable = mysqlTable(
"oauth_accounts",
{
providerId: varchar("provider_id", { length: 255 }).notNull(),
providerUserId: varchar("provider_user_id", { length: 255 }).notNull(),
userId: varchar("user_id", { length: 255 })
.notNull()
.references(() => usersTable.id),
},
(table) => {
return {
pk: primaryKey({
columns: [table.providerId, table.providerUserId],
}),
};
},
);
export const questionTranslationsTable = mysqlTable(
"question_translations",
{
questionId: int("question_id")
.notNull()
.references(() => questionsTable.id),
language: languages,
text: varchar("text", { length: 1023 }).notNull(),
},
(table) => {
return {
pk: primaryKey({
columns: [table.questionId, table.language],
}),
};
},
);
export const questionsTable = mysqlTable(
"questions",
{
id: int("id").autoincrement().notNull().primaryKey(),
quizId: int("quiz_id").references(() => quizzesTable.id),
text: varchar("text", { length: 1023 }).notNull(),
displayType: mysqlEnum("display_type", [
"image-grid",
"image-list",
"text-grid",
"text-list",
"scale",
]).notNull(),
maxChoices: int("max_choices").default(1).notNull(),
imageUrl: varchar("image_url", { length: 1023 }),
sourceAnswerId: int("source_answer_id"),
variant: varchar("variant", { length: 50 }),
},
(table) => {
return {
quizQuestionsIdx: index("quiz_questions_index").on(table.quizId),
variantIdx: index("variant_index").on(table.variant),
};
},
);
export const quizLandersTable = mysqlTable("quiz_landers", {
slug: varchar("slug", { length: 255 })
.primaryKey()
.notNull()
.references(() => quizzesTable.slug),
title: varchar("title", { length: 255 }).notNull(),
description: varchar("description", { length: 255 }).notNull(),
content: text("content").notNull(),
});
export const quizTranslationsTable = mysqlTable(
"quiz_translations",
{
quizId: int("quiz_id")
.notNull()
.references(() => quizzesTable.id),
language: languages,
name: varchar("name", { length: 255 }).notNull(),
description: varchar("description", { length: 1023 }).notNull(),
},
(table) => {
return {
pk: primaryKey({
columns: [table.quizId, table.language],
}),
};
},
);
export const quizzesTable = mysqlTable(
"quizzes",
{
id: int("id").autoincrement().notNull(),
name: varchar("name", { length: 255 }).notNull(),
description: varchar("description", { length: 1023 }).default("").notNull(),
skipableQuestions: boolean("skipable_questions").default(false).notNull(),
published: boolean("published").default(false).notNull(),
imageUrls: json("image_urls").$type<{
logo: string;
tile: string;
icon: string;
}>(),
slug: varchar("slug", { length: 255 }).notNull().unique(),
category: varchar("category", { length: 255 }).default("").notNull(),
llmContext: varchar("llm_context", { length: 1023 }).default("").notNull(),
},
(table) => {
return {
pk: primaryKey({ columns: [table.id], name: "quizzes_id" }),
};
},
);
export const quizConfigsTable = mysqlTable(
"quiz_configs",
{
quiz_slug: varchar("quiz_slug", { length: 255 })
.notNull()
.references(() => quizzesTable.slug),
default: boolean("default").notNull().default(false),
premium: boolean("premium").notNull().default(false),
estimatedTime: int("estimated_time"),
title: varchar("title", { length: 255 }).notNull(),
description: varchar("description", { length: 255 }).notNull(),
type: mysqlEnum("type", ["static", "dynamic"]).notNull().default("dynamic"),
shuffle: boolean("shuffle").notNull().default(true),
variants:
json("variants").$type<{ variant: string; instances: number }[]>(),
},
(table) => {
return {
pk: primaryKey({ columns: [table.quiz_slug, table.title] }),
};
},
);
export const sessionsTable = mysqlTable("sessions", {
id: varchar("id", {
length: 255,
})
.notNull()
.primaryKey(),
userId: varchar("user_id", {
length: 255,
})
.notNull()
.references(() => usersTable.id),
expiresAt: datetime("expires_at").notNull(),
});
export const userAnswersTable = mysqlTable(
"user_answers",
{
userId: varchar("user_id", { length: 255 })
.notNull()
.references(() => usersTable.id),
quizId: int("quiz_id")
.notNull()
.references(() => quizzesTable.id),
answerId: int("answer_id")
.notNull()
.references(() => answersTable.id),
dimensions: json("dimensions").$type<Dimension[]>().notNull(),
},
(table) => {
return {
pk: primaryKey({
columns: [table.userId, table.quizId, table.answerId],
}),
};
},
);
export const usersTable = mysqlTable("users", {
id: varchar("id", { length: 255 }).notNull().primaryKey(),
username: varchar("username", { length: 255 }).notNull(),
avatarUrl: varchar("avatar_url", { length: 1023 }),
email: varchar("email", { length: 255 }),
role: mysqlEnum("role", ["user", "creator", "moderator", "admin"])
.default("user")
.notNull(),
}); |
@versecafe @hectorruizlaph Can you try a hard refresh in browser? |
@hectorruizlaph Tried hard refreshes, cache clears, and wiping node modules and a full reboot |
Can you provide responses from requests to localhost? Or just check maybe there error in response |
Same here...It was working just fine but then now it's returning 404 and forcing me to upgrade even though I'm on the latest version. |
@kimjisena Hey! Do you have version 0.20.17? If yes then maybe try reinstalling |
@versecafe @kimjisena I've tried everything, with no success, I'm using "next": "^14.1.3", "drizzle-kit": "^0.20.17", "mysql2": "^3.6.1", pnpm |
For me, it started working again with 0.20.16 when I deleted my local database and created it again (I am using Turso local development), and uninstalled drizzle-kit, and installed it again. After updating to 0.20.17, everything is still working fine. I'm not sure what really fixed it though. |
I tried reinstalling everything to no avail. One thing I haven't tried is dropping the database and rerunning migrations (as someone has suggested in the thread). Let me try that too. |
@kimjisena Can you provide database url without credentials? |
here's the contents of my drizzle config // drizzle.config.ts
import "dotenv/config";
import type { Config } from "drizzle-kit";
export default {
schema: "./src/db/schemas/index.ts",
out: "./src/db/migrations",
driver: "pg", // 'pg' | 'mysql2' | 'better-sqlite' | 'libsql' | 'turso'
dbCredentials: {
host: process.env.PG_HOST as string,
port: Number(process.env.PG_PORT),
user: process.env.PG_USER,
password: process.env.PG_PASSWORD,
database: process.env.PG_NAME as string,
},
} satisfies Config; |
Oh, you're using Postgres. Then can you show your schema? |
Yes, I'm using Postgres. Actually, in the initial set up I was using MySQL and it was working fine (I even tweeted about it). But then I decided to switch to Postgres so I updated my schemas and everything. I can generate migrations just fine and I can run them. All tables are being created correctly but Drizzle Studio is somehow not working. As for schemas, I have several schema files that I have re-exported in one file (see code below): // ./src/db/schemas/index.ts
export { asset } from "./asset";
// ... more schemas
// ... even more schemas
export {
transaction,
transactionStatusEnum,
transactionTypeEnum,
} from "./transaction";
export { userGroup } from "./user-group";
export { userMessage } from "./user-message";
export { user, userRoleEnum, userStatusEnum } from "./user"; |
@kimjisena And you also have this error? |
|
@kimjisena Then try removing the node_modules and package lock file and reinstalling the dependencies (also check that you have the latest version of drizzle-kit) |
At first I was just removing This finally worked. Thanks!
|
I've tried removing the node_modules and pnpm_lock.yaml file and reinstalling the dependencies (using drizzle-kit 0.20.17) and I still have this issue Any suggestions what can I do next? |
@stefanikostic Hey! Can you please share your schema? |
Yes, here it is: import { relations } from 'drizzle-orm'; export const quizzes = sqliteTable('quizzes', { export const quizRelations = relations(quizzes, ({ many }) => ({ export const questions = sqliteTable('questions', { export const questionsRelations = relations(questions, ({ one, many }) => ({ export const answers = sqliteTable('answers', { export const answersRelations = relations(answers, ({ one }) => ({ |
Having the same issue here. No workaround |
Same issue here |
+1 on this issue. mysql |
+1 on this issue Also happening to me on Chrome. postgres |
attempting to run
pnpm drizzle-kit studio
starts up onlocal.drizzle.studio
but only as a skeleton due to/init
returning a 404, this is on the latest0.20.16
and even after downgrading to a previously functioning0.20.14
The text was updated successfully, but these errors were encountered: