42 lines
No EOL
1,010 B
JavaScript
42 lines
No EOL
1,010 B
JavaScript
// db/init.js
|
|
const db = require('./knex');
|
|
|
|
async function init() {
|
|
const exists = await db.schema.hasTable('photos');
|
|
|
|
if (!exists) {
|
|
await db.schema.createTable('photos', (t) => {
|
|
t.string('id').primary();
|
|
t.string('user');
|
|
t.string('cartella');
|
|
t.string('name');
|
|
t.string('path');
|
|
t.string('thub1');
|
|
t.string('thub2');
|
|
t.string('mime_type');
|
|
t.integer('width');
|
|
t.integer('height');
|
|
t.integer('rotation');
|
|
t.integer('size_bytes');
|
|
t.integer('mtimeMs');
|
|
t.integer('duration_ms');
|
|
t.string('taken_at');
|
|
t.string('data');
|
|
t.float('lat');
|
|
t.float('lon');
|
|
t.float('alt');
|
|
t.text('location'); // JSON string
|
|
|
|
// 👉 NUOVO: hash identico al vecchio index.json
|
|
t.string('_indexHash');
|
|
});
|
|
|
|
console.log("✔ Tabella 'photos' creata correttamente (con _indexHash)");
|
|
} else {
|
|
console.log("✔ Tabella 'photos' già esistente");
|
|
}
|
|
|
|
process.exit();
|
|
}
|
|
|
|
init(); |