Skip to content

Commit

Permalink
Fix database URI in drizzle.config.ts and add
Browse files Browse the repository at this point in the history
createdAt field to organizations table
  • Loading branch information
IhsenBouallegue committed Nov 14, 2023
1 parent 50d2e4b commit 397684e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 24 deletions.
28 changes: 14 additions & 14 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as dotenv from "dotenv";
import type { Config } from "drizzle-kit";

dotenv.config();

export default {
schema: "./src/lib/schema/*",
out: "./drizzle",
driver: "mysql2",
verbose: true,
dbCredentials: {
connectionString: `${process.env.DATABASE_URL}`,
},
} satisfies Config;
import * as dotenv from "dotenv";
import type { Config } from "drizzle-kit";

dotenv.config();

export default {
schema: "./src/lib/schema/*",
out: "./drizzle",
driver: "mysql2",
verbose: true,
dbCredentials: {
uri: `${process.env.DATABASE_URL}`,
},
} satisfies Config;
16 changes: 8 additions & 8 deletions src/lib/schema/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export const hubSpaces = mysqlTable(
"hubspaces",
{
id: varchar("id", { length: 256 })
.$defaultFn(() => HUBSPACE_KEY)
.primaryKey(),
.primaryKey()
.$defaultFn(() => HUBSPACE_KEY),
name: varchar("name", { length: 256 }).notNull(),
domain: varchar("domain", { length: 256 }).notNull(),
ownerId: varchar("owner_id", { length: 256 }).notNull(),
Expand All @@ -36,10 +36,10 @@ export const hubs = mysqlTable(
"hubs",
{
id: varchar("id", { length: 256 })
.$defaultFn(() => HUB_KEY)
.primaryKey(),
.primaryKey()
.$defaultFn(() => HUB_KEY),
name: varchar("name", { length: 256 }).notNull(),
logo: varchar("logo", { length: 256 }).default("").notNull(),
logo: varchar("logo", { length: 1024 }).default("").notNull(),
slug: varchar("slug", { length: 256 }).default("/").notNull(),
primaryColor: varchar("primary_color", { length: 256 })
.default("#ff008c")
Expand All @@ -62,12 +62,12 @@ export const hubs = mysqlTable(

export const links = mysqlTable("links", {
id: varchar("id", { length: 256 })
.$defaultFn(() => LINK_KEY)
.primaryKey()
.$defaultFn(() => LINK_KEY)
.notNull(),
title: varchar("title", { length: 256 }).notNull(),
description: text("description").notNull(),
image: varchar("image", { length: 256 }).default("").notNull(),
image: varchar("image", { length: 1024 }).default("").notNull(),
url: varchar("url", { length: 256 }).notNull(),
createdAt: timestamp("created_at").defaultNow(),
linkGroupId: varchar("link_group_id", { length: 256 }).notNull(),
Expand All @@ -76,8 +76,8 @@ export const links = mysqlTable("links", {

export const footerLinks = mysqlTable("footer_links", {
id: varchar("id", { length: 256 })
.$defaultFn(() => FOOTERLINK_KEY)
.primaryKey()
.$defaultFn(() => FOOTERLINK_KEY)
.notNull(),
title: varchar("title", { length: 256 }).notNull(),
url: varchar("url", { length: 256 }).notNull(),
Expand Down
2 changes: 1 addition & 1 deletion src/lib/schema/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const verificationTokens = mysqlTable(
expires: timestamp("expires", { mode: "date" }).notNull(),
},
(vt) => ({
compoundKey: primaryKey(vt.identifier, vt.token),
compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }),
})
);

Expand Down
4 changes: 3 additions & 1 deletion src/lib/schema/orgaizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
boolean,
mysqlTable,
primaryKey,
timestamp,
uniqueIndex,
varchar,
} from "drizzle-orm/mysql-core";
Expand All @@ -22,6 +23,7 @@ export const organizations = mysqlTable(
name: varchar("name", { length: 255 }).notNull(),
slug: varchar("slug", { length: 255 }).notNull(),
admin: varchar("admin", { length: 128 }).notNull(),
createdAt: timestamp("created_at").defaultNow(),
isPersonalOrganization: boolean("is_personal_organization")
.default(false)
.notNull(),
Expand Down Expand Up @@ -49,7 +51,7 @@ export const usersToOrganizations = mysqlTable(
organizationId: varchar("organization_id", { length: 128 }).notNull(),
},
(t) => ({
pk: primaryKey(t.userId, t.organizationId),
pk: primaryKey({ columns: [t.userId, t.organizationId] }),
})
);

Expand Down
1 change: 1 addition & 0 deletions src/lib/validations/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ export const organizationSchema = insertOrganizationSchema.omit({ id: true });
export const organizationSchemaWithoutAdmin = insertOrganizationSchema.omit({
id: true,
admin: true,
createdAt: true,
});

1 comment on commit 397684e

@vercel
Copy link

@vercel vercel bot commented on 397684e Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.