working with postgres
This commit is contained in:
parent
d8a72e5978
commit
1ef39baa57
6 changed files with 186 additions and 9 deletions
|
|
@ -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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue