working with postgres

This commit is contained in:
counterweight 2025-02-08 17:02:59 +01:00
parent d8a72e5978
commit 1ef39baa57
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
6 changed files with 186 additions and 9 deletions

View file

@ -1,18 +1,19 @@
const { Sequelize } = require('sequelize');
const dotenv = require('dotenv');
dotenv.config();
const sequelize = new Sequelize({
dialect: 'sqlite',
storage: './data/database.sqlite',
dialect: 'postgres',
host: 'postgres',
port: 5432,
database: process.env.POSTGRES_DB,
username: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
define: {
timestamps: false,
freezeTableName: true
},
});
sequelize.sync().then(() => {
console.log('Database synced');
}).catch(err => {
console.error('Error syncing the database:', err);
});
module.exports = sequelize;