added drizzle and connected to vercel
All checks were successful
Vercel Production Deployment / Deploy-Production (push) Successful in 2m21s
All checks were successful
Vercel Production Deployment / Deploy-Production (push) Successful in 2m21s
This commit is contained in:
parent
8b2feffb1e
commit
98ffb58cdb
2
.gitignore
vendored
2
.gitignore
vendored
@ -34,3 +34,5 @@ yarn-error.log*
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
||||
.vercel
|
||||
|
10
drizzle.config.ts
Normal file
10
drizzle.config.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import "@/drizzle/envConfig";
|
||||
import { defineConfig } from "drizzle-kit";
|
||||
|
||||
export default defineConfig({
|
||||
schema: "./drizzle/schema.ts",
|
||||
dialect: "postgresql",
|
||||
dbCredentials: {
|
||||
url: process.env.POSTGRES_URL!,
|
||||
},
|
||||
});
|
10
drizzle/db.ts
Normal file
10
drizzle/db.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import "@/drizzle/envConfig";
|
||||
import { drizzle } from "drizzle-orm/vercel-postgres";
|
||||
import { sql } from "@vercel/postgres";
|
||||
import * as schema from "./schema";
|
||||
|
||||
export const db = drizzle(sql, { schema });
|
||||
|
||||
export const getUsers = async () => {
|
||||
return db.query.UsersTable.findMany();
|
||||
};
|
4
drizzle/envConfig.ts
Normal file
4
drizzle/envConfig.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { loadEnvConfig } from "@next/env";
|
||||
|
||||
const projectDir = process.cwd();
|
||||
loadEnvConfig(projectDir);
|
25
drizzle/schema.ts
Normal file
25
drizzle/schema.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { drizzle } from "drizzle-orm/vercel-postgres";
|
||||
import { sql } from "@vercel/postgres";
|
||||
import {
|
||||
pgTable,
|
||||
serial,
|
||||
text,
|
||||
timestamp,
|
||||
uniqueIndex,
|
||||
} from "drizzle-orm/pg-core";
|
||||
|
||||
export const UsersTable = pgTable(
|
||||
"users",
|
||||
{
|
||||
id: serial("id").primaryKey(),
|
||||
name: text("name").notNull(),
|
||||
email: text("email").notNull(),
|
||||
image: text("image").notNull(),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
},
|
||||
(users) => {
|
||||
return {
|
||||
uniqueIdx: uniqueIndex("unique_idx").on(users.email),
|
||||
};
|
||||
}
|
||||
);
|
1483
package-lock.json
generated
1483
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@ -9,18 +9,22 @@
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^18",
|
||||
"react-dom": "^18",
|
||||
"next": "14.2.3"
|
||||
"@next/env": "^14.2.3",
|
||||
"@vercel/postgres": "^0.8.0",
|
||||
"drizzle-orm": "^0.30.10",
|
||||
"next": "14.2.3",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^18",
|
||||
"@types/react-dom": "^18",
|
||||
"postcss": "^8",
|
||||
"tailwindcss": "^3.4.1",
|
||||
"eslint": "^8",
|
||||
"eslint-config-next": "14.2.3"
|
||||
"@types/node": "^20.12.12",
|
||||
"@types/react": "^18.3.2",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"drizzle-kit": "^0.21.2",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-next": "14.2.3",
|
||||
"postcss": "^8.4.38",
|
||||
"tailwindcss": "^3.4.3",
|
||||
"typescript": "^5.4.5"
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,12 @@
|
||||
"@/*": ["./*"]
|
||||
}
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts",
|
||||
"drizzle.config.ts"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user