diff options
| author | Zephyrrus <[email protected]> | 2021-01-05 22:58:41 +0200 |
|---|---|---|
| committer | Zephyrrus <[email protected]> | 2021-01-07 10:47:16 +0200 |
| commit | f151a8ac3a8f944829e55fc007823b167f1a2597 (patch) | |
| tree | a6611e4ef497ee560812105c15d377364bddf1d6 /src/api/database/migrations/20210105222742_addStatisticsTable.js | |
| parent | feat: Add experimental stats endpoint (no cache system yet) (diff) | |
| download | host.fuwn.me-f151a8ac3a8f944829e55fc007823b167f1a2597.tar.xz host.fuwn.me-f151a8ac3a8f944829e55fc007823b167f1a2597.zip | |
chore: Move statistics related functions to it's own file
fix: Extract database constructor to a separate file to ensure we only create one knex instance/db
feat: Add cron for saving the stats to the database every hour
feat: Get cached stats from database (if a stat is not found in the db, generate it)
Diffstat (limited to 'src/api/database/migrations/20210105222742_addStatisticsTable.js')
| -rw-r--r-- | src/api/database/migrations/20210105222742_addStatisticsTable.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/api/database/migrations/20210105222742_addStatisticsTable.js b/src/api/database/migrations/20210105222742_addStatisticsTable.js new file mode 100644 index 0000000..d920ac1 --- /dev/null +++ b/src/api/database/migrations/20210105222742_addStatisticsTable.js @@ -0,0 +1,16 @@ + +exports.up = async knex => { + await knex.schema.createTable('statistics', table => { + table.increments(); + table.integer('batchId'); + table.string('type'); + table.json('data'); + table.timestamp('createdAt'); + + table.unique(['batchId', 'type']); + }); +}; + +exports.down = async knex => { + await knex.schema.dropTableIfExists('statistics'); +}; |