Commit 66c3d61e authored by Poojasri's avatar Poojasri
Browse files

project setup

parent 01c1e983
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
# Dependency directory
node_modules

# vscode 
.vscode

# .env
*.env
 No newline at end of file
+25 −0
Original line number Diff line number Diff line
import { drizzle } from "drizzle-orm/node-postgres";
import pg from "pg";

const { Client } = pg;

const client = new Client({
  host: "localhost",
  port: 5432,
  user: "postgres",
  password: "root",
  database: "call_for_app_hono_db",
});

client
  .connect()
  .then(() => {
    console.log("DB connected successfully!");
  })
  .catch((err) => {
    console.error("Connection error", err.stack);
  });

const db = drizzle(client);

export default db;
+13 −0
Original line number Diff line number Diff line
import 'dotenv/config';
import { migrate } from 'drizzle-orm/postgres-js/migrator';
import db from './db.connect';

(async () => {
  try {
    // Run migrations
    await migrate(db, { migrationsFolder: './drizzle' });
    console.log('Migrations ran successfully');
  } catch (error) {
    console.error('Error running migrations:', error);
  }
})();
+16 −0
Original line number Diff line number Diff line
import { defineConfig } from "drizzle-kit";
import dotenv from "dotenv";

dotenv.config();

export default defineConfig({
  schema: "./src/user/user.model.ts",
  out: "./drizzle",
  dialect: "postgresql",
  dbCredentials: {
    host: process.env.DB_HOST || "localhost",
    user: process.env.DB_USER || "postgres",
    password: process.env.DB_PASSWORD || "root", 
    database: process.env.DB_NAME || "call_for_app_hono_db",
  },
});
+11 −0
Original line number Diff line number Diff line
CREATE TABLE IF NOT EXISTS "users" (
	"id" serial PRIMARY KEY NOT NULL,
	"first_name" varchar NOT NULL,
	"last_name" varchar,
	"email" varchar NOT NULL,
	"phone_number" varchar,
	"password" varchar NOT NULL,
	"created_by" integer NOT NULL,
	"updated_by" integer NOT NULL,
	CONSTRAINT "users_email_unique" UNIQUE("email")
);
Loading