diff --git a/.gitignore b/.gitignore index 9cced06..301c4f2 100644 --- a/.gitignore +++ b/.gitignore @@ -136,4 +136,4 @@ dist .pnp.* -container-data/ \ No newline at end of file +container-data \ No newline at end of file diff --git a/database.js b/database.js index 625532d..e6afbac 100644 --- a/database.js +++ b/database.js @@ -4,8 +4,15 @@ const sequelize = new Sequelize({ dialect: 'sqlite', storage: './data/database.sqlite', define: { - timestamps: false + timestamps: false, + freezeTableName: true }, }); +sequelize.sync().then(() => { + console.log('Database synced'); +}).catch(err => { + console.error('Error syncing the database:', err); +}); + module.exports = sequelize; \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index ac5f64f..90d8c0a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ version: '3' services: express: build: . + user: "${UID:-1000}:${GID:-1000}" ports: - "3000:3000" volumes: diff --git a/index.js b/index.js index b448ea0..9a9d07f 100644 --- a/index.js +++ b/index.js @@ -9,14 +9,6 @@ const SessionNpubbed = require('./models/SessionNpubbed'); const app = express(); const port = 3000; -sequelize.sync() - .then(() => { - console.log('Database synced'); - }) - .catch(err => { - console.error('Error syncing the database:', err); - }); - app.use(cookieParser()); app.use(express.json()); diff --git a/models/SessionNpubbed.js b/models/SessionNpubbed.js index 39f3266..7d940c1 100644 --- a/models/SessionNpubbed.js +++ b/models/SessionNpubbed.js @@ -11,7 +11,6 @@ const SessionNpubbed = sequelize.define('SessionNpubbed', { sessionUuid: { type: DataTypes.UUID, allowNull: false, - unique: true, }, npub: { type: DataTypes.STRING, diff --git a/package.json b/package.json index 4edf805..0a95aa8 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,10 @@ "start": "node index.js", "start:containers": "docker compose up -d --build", "stop:containers": "docker compose down", + "purge-dev-data": "rm -rf ./container-data", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC" -} +} \ No newline at end of file