Merge pull request #157 from arillo/feature/postgres

Feature/postgres
This commit is contained in:
banglashi
2021-02-06 00:13:21 +01:00
committed by GitHub
3 changed files with 49 additions and 18 deletions

View File

@@ -64,6 +64,26 @@ For advanced media conversion:
By default, media files are uploaded to the ```storage``` folder. By default, media files are uploaded to the ```storage``` folder.
The database is stored in ```database.sqlite``` by default. The database is stored in ```database.sqlite``` by default.
# Other databases (Not officially supported)
## Postgres
Add the [pg](https://www.npmjs.com/package/pg) module and change the config/default.json to
```
"storage_dialect": "postgres",
```
Adapt the other values as needed
```
"storage_host": "localhost",
"storage_database": "spacedeck",
"storage_username": "username",
"storage_password": "password",
```
# Run with Docker # Run with Docker
- configure `config/default.json` - configure `config/default.json`

View File

@@ -7,6 +7,13 @@
"endpoint": "http://localhost:9666", "endpoint": "http://localhost:9666",
"invite_code": "top-sekrit", "invite_code": "top-sekrit",
"storage_dialect": "sqlite",
"storage_host": "localhost",
"storage_database": "spacedeck",
"storage_username": "username",
"storage_password": "password",
"storage_local_path": "./storage", "storage_local_path": "./storage",
"storage_local_db": "./database.sqlite", "storage_local_db": "./database.sqlite",
"storage_region": "eu-central-1", "storage_region": "eu-central-1",

View File

@@ -6,24 +6,28 @@ function sequel_log(a,b,c) {
} }
const Sequelize = require('sequelize'); const Sequelize = require('sequelize');
const sequelize = new Sequelize('database', 'username', 'password', { const sequelize = new Sequelize(
host: 'localhost', config.get('storage_database'),
dialect: 'sqlite', config.get('storage_username'),
config.get('storage_password'),
pool: { {
max: 5, host: config.get('storage_host'),
min: 0, dialect: config.get('storage_dialect'),
acquire: 30000, pool: {
idle: 10000 max: 5,
}, min: 0,
acquire: 30000,
// SQLite only idle: 10000
storage: config.get('storage_local_db'), },
logging: sequel_log, logging: sequel_log,
// http://docs.sequelizejs.com/manual/tutorial/querying.html#operators
// http://docs.sequelizejs.com/manual/tutorial/querying.html#operators operatorsAliases: false,
operatorsAliases: false // SQLite only
}); storage: config.get('storage_local_db')
}
);
// https://github.com/sequelize/sequelize/issues/8019#issuecomment-384316346
Sequelize.postgres.DECIMAL.parse = function (value) { return parseFloat(value); };
var User; var User;
var Session; var Session;