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.
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
- configure `config/default.json`

View File

@@ -7,6 +7,13 @@
"endpoint": "http://localhost:9666",
"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_db": "./database.sqlite",
"storage_region": "eu-central-1",

View File

@@ -6,24 +6,28 @@ function sequel_log(a,b,c) {
}
const Sequelize = require('sequelize');
const sequelize = new Sequelize('database', 'username', 'password', {
host: 'localhost',
dialect: 'sqlite',
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
},
// SQLite only
storage: config.get('storage_local_db'),
logging: sequel_log,
// http://docs.sequelizejs.com/manual/tutorial/querying.html#operators
operatorsAliases: false
});
const sequelize = new Sequelize(
config.get('storage_database'),
config.get('storage_username'),
config.get('storage_password'),
{
host: config.get('storage_host'),
dialect: config.get('storage_dialect'),
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
},
logging: sequel_log,
// http://docs.sequelizejs.com/manual/tutorial/querying.html#operators
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 Session;