Skip to content
Snippets Groups Projects
Commit 75b46974 authored by Vinod Bangera's avatar Vinod Bangera
Browse files

added gitignore and table creation

parent 876ea386
Branches
No related tags found
No related merge requests found
PORT=5000
DB_USER=postgres
DB_HOST=127.0.0.1
DB_NAME=my_pgdb
DB_PASSWORD=Adarsh@2002
DB_PORT=5432
\ No newline at end of file
# Node.js
node_modules/
npm-debug.log
yarn-error.log
# Environment variables
.env
# Logs
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Database
*.sqlite
*.sqlite3
# IDEs and editors
.vscode/
.idea/
*.sublime-project
*.sublime-workspace
# Operating system files
.DS_Store
Thumbs.db
\ No newline at end of file
...@@ -10,7 +10,27 @@ const pool = new Pool({ ...@@ -10,7 +10,27 @@ const pool = new Pool({
}); });
pool.connect() pool.connect()
.then(() => console.log(" PostgreSQL Database Connected Successfully")) .then(async (client) => {
console.log("PostgreSQL Database Connected Successfully");
const createTableQuery = `
CREATE TABLE IF NOT EXISTS usage_metrics (
id SERIAL PRIMARY KEY,
email VARCHAR(255) NOT NULL,
projectId VARCHAR(255) NOT NULL,
requestType VARCHAR(50) CHECK (requestType IN ('completion', 'explanation', 'documentation', 'testcase')),
linesOfCodeSuggested INT DEFAULT 0,
linesOfCodeAccepted INT DEFAULT 0,
requestId UUID DEFAULT gen_random_uuid(),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
`;
await client.query(createTableQuery);
console.log("Table 'usage_metrics' is ready");
client.release();
})
.catch((err) => console.error("Database Connection Failed:", err)); .catch((err) => console.error("Database Connection Failed:", err));
module.exports = pool; module.exports = pool;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment