drizzle setup
This commit is contained in:
17
drizzle.config.ts
Normal file
17
drizzle.config.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { config } from "dotenv";
|
||||||
|
import { type Config } from "drizzle-kit";
|
||||||
|
|
||||||
|
config({ path: ".env" });
|
||||||
|
|
||||||
|
export default {
|
||||||
|
out: "./drizzle",
|
||||||
|
schema: "./src/db/schema.ts",
|
||||||
|
dialect: "postgresql",
|
||||||
|
dbCredentials: {
|
||||||
|
url: process.env.DATABASE_URL!,
|
||||||
|
},
|
||||||
|
verbose: true,
|
||||||
|
strict: true,
|
||||||
|
} satisfies Config;
|
||||||
10
src/db.ts
Normal file
10
src/db.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import "dotenv/config";
|
||||||
|
import { drizzle } from "drizzle-orm/node-postgres";
|
||||||
|
|
||||||
|
// You can specify any property from the node-postgres connection options
|
||||||
|
const db = drizzle({
|
||||||
|
connection: {
|
||||||
|
connectionString: process.env.DATABASE_URL!,
|
||||||
|
ssl: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
7
src/db/schema.ts
Normal file
7
src/db/schema.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { integer, pgTable, varchar } from "drizzle-orm/pg-core";
|
||||||
|
|
||||||
|
export const usersTable = pgTable("users", {
|
||||||
|
id: integer().primaryKey().generatedAlwaysAsIdentity(),
|
||||||
|
name: varchar({ length: 255 }).notNull(),
|
||||||
|
email: varchar({ length: 255 }).notNull().unique(),
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user