Next.js Discord

Discord Forum

Sequelize and SQlite database not created

Unanswered
Sphecid wasp posted this in #help-forum
Open in Discord
Avatar
Sphecid waspOP
Good evening!
I'm currently creating a site with nextjs and I'm using sequelize and sqlite for the database part. The problem is that in my sequelize config, even though I've specified the database path, nothing is created.
The strangest thing is that the information is saved in db because when I do User.findAll, I get my test users

import { Sequelize } from "sequelize";
import "../envConfig.js";
import sqlite3 from "sqlite3";

const sequelize = new Sequelize({
    host: "localhost",
    username: process.env.DB_USER,
    password: process.env.DB_PASSWORD,
    database: "bdd",
    dialect: "sqlite",
    storage: "../app/data/bdd.sqlite",
    logging: false,
    dialectModule: sqlite3,
    define: {
        freezeTableName: true,
        timestamps: false
    }
});

const initializeDatabase = async () => {
    console.log("Initializing database");
    try {
        await sequelize.authenticate();

        await sequelize.sync({alter: true });

        console.log("Database initialized successfully");
    } catch (error) {
        console.error("Database initialization failed:", error);
    }
};

initializeDatabase();

export default sequelize

0 Replies