1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-19 03:29:37 +02:00

Database migration to support more weather properties

This commit is contained in:
Paweł Malak 2021-11-18 14:16:57 +01:00
parent e2285e2deb
commit a549149452
4 changed files with 60 additions and 13 deletions

View file

@ -0,0 +1,35 @@
const { DataTypes } = require('sequelize');
const { INTEGER, FLOAT } = DataTypes;
const loadConfig = require('../../utils/loadConfig');
const getExternalWeather = require('../../utils/getExternalWeather');
const up = async (query) => {
await query.addColumn('weather', 'humidity', {
type: INTEGER,
});
await query.addColumn('weather', 'windK', {
type: FLOAT,
});
await query.addColumn('weather', 'windM', {
type: FLOAT,
});
const { WEATHER_API_KEY: secret } = await loadConfig();
if (secret) {
await getExternalWeather();
}
};
const down = async (query) => {
await query.removeColumn('weather', 'humidity');
await query.removeColumn('weather', 'windK');
await query.removeColumn('weather', 'windM');
};
module.exports = {
up,
down,
};