Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions src/commands/add/auth/next-auth/generators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
export const apiAuthNextAuthTsOld = (
providers: AuthProvider[],
dbType: DBType | null,
orm: ORMType,
orm: ORMType
) => {
const { shared } = getFilePaths();
const dbIndex = getDbIndexPath();
Expand Down Expand Up @@ -50,7 +50,7 @@ ${providersToUse
(provider) =>
`import ${capitalised(provider.name)}Provider from "next-auth/providers/${
provider.name
}";`,
}";`
)
.join("\n")}

Expand Down Expand Up @@ -127,7 +127,7 @@ export const libAuthUtilsTsWithoutAuthOptions = () => {
const { "next-auth": nextAuth } = getFilePaths();
return `import { authOptions } from "${formatFilePath(
nextAuth.nextAuthApiRoute,
{ removeExtension: true, prefix: "alias" },
{ removeExtension: true, prefix: "alias" }
)}";
import { getServerSession } from "next-auth";
import { redirect } from "next/navigation";
Expand All @@ -147,7 +147,7 @@ export const checkAuth = async () => {
export const libAuthUtilsTs = (
providers: AuthProvider[],
dbType: DBType | null,
orm: ORMType,
orm: ORMType
) => {
const { shared } = getFilePaths();
const dbIndex = getDbIndexPath();
Expand Down Expand Up @@ -179,7 +179,7 @@ ${providersToUse
(provider) =>
`import ${capitalised(provider.name)}Provider from "next-auth/providers/${
provider.name
}";`,
}";`
)
.join("\n")}

Expand Down Expand Up @@ -272,7 +272,9 @@ export const accounts = pgTable(
session_state: text("session_state"),
},
(account) => ({
compoundKey: primaryKey(account.provider, account.providerAccountId),
compoundKey: primaryKey({
columns: [account.provider, account.providerAccountId],
}),
})
);

Expand All @@ -292,7 +294,7 @@ export const verificationTokens = pgTable(
expires: timestamp("expires", { mode: "date" }).notNull(),
},
(vt) => ({
compoundKey: primaryKey(vt.identifier, vt.token),
compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }),
})
);
`;
Expand Down Expand Up @@ -344,7 +346,9 @@ export const accounts = mysqlTable(
session_state: varchar("session_state", { length: 255 }),
},
(account) => ({
compoundKey: primaryKey(account.provider, account.providerAccountId),
compoundKey: primaryKey({
columns: [account.provider, account.providerAccountId],
}),
})
);

Expand All @@ -367,7 +371,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] }),
})
);`;
case "sqlite":
Expand Down Expand Up @@ -405,7 +409,9 @@ export const accounts = sqliteTable(
session_state: text("session_state"),
},
(account) => ({
compoundKey: primaryKey(account.provider, account.providerAccountId),
compoundKey: primaryKey({
columns: [account.provider, account.providerAccountId],
}),
})
);

Expand All @@ -425,7 +431,7 @@ export const verificationTokens = sqliteTable(
expires: integer("expires", { mode: "timestamp_ms" }).notNull(),
},
(vt) => ({
compoundKey: primaryKey(vt.identifier, vt.token),
compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }),
})
);`;
default:
Expand Down Expand Up @@ -539,7 +545,7 @@ export const protectedProcedure = t.procedure.use(isAuthed);
fs.writeFileSync(filePath, modifiedRouterContent);

consola.success(
"TRPC Router updated successfully to add protectedProcedure.",
"TRPC Router updated successfully to add protectedProcedure."
);
};

Expand Down Expand Up @@ -577,7 +583,7 @@ export const enableSessionInTRPCApi = () => {

export const createPrismaAuthSchema = (
driver: DBType,
usingPlanetScale: boolean,
usingPlanetScale: boolean
) => {
return `model Account {
id String @id @default(cuid())
Expand Down
6 changes: 3 additions & 3 deletions src/commands/add/misc/stripe/generators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ export const subscriptions = pgTable(
},
(table) => {
return {
pk: primaryKey(table.userId, table.stripeCustomerId),
pk: primaryKey({ columns: [table.userId, table.stripeCustomerId] }),
};
}
);
Expand All @@ -1001,7 +1001,7 @@ export const subscriptions = mysqlTable(
},
(table) => {
return {
pk: primaryKey(table.userId, table.stripeCustomerId),
pk: primaryKey({ columns: [table.userId, table.stripeCustomerId] }),
};
}
);
Expand Down Expand Up @@ -1034,7 +1034,7 @@ export const subscriptions = sqliteTable(
},
(table) => {
return {
pk: primaryKey(table.userId, table.stripeCustomerId),
pk: primaryKey({ columns: [table.userId, table.stripeCustomerId] }),
};
}
);
Expand Down