-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
38 lines (33 loc) · 839 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const fs = require('fs');
const path = require('path');
const tempDirectory = 'data/E4/TEMP/';
var names = [];
exports.up = function(knex, Promise) {
let migrationPromises = [];
fs.readdir(tempDirectory, function(err, files) {
if (err) {
console.error('Could not list the dirrectory.', err);
process.exit(1);
}
for (var file in files) {
names.push(file);
migrationPromises.push(
knex.schema.createTable(file, (table) => {
table.increments();
table.string('date');
table.float('temperature');
})
);
}
})
return Promise.all(migrationPromises);
};
exports.down = function(knex, Promise) {
let promises = [];
for (var file in names) {
promises.push(
knex.schema.dropTable(file);
)
}
return Promise.all(promises);
};