Implemented a simple table for storing visits

This commit is contained in:
Nicolai Ort 2021-08-14 09:15:15 +02:00
parent 6680ce7e50
commit 5e9dec640a
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
1 changed files with 5 additions and 2 deletions

View File

@ -1,7 +1,10 @@
exports.up = function (knex) {
return knex.schema.table('urls', function (table) {
table.integer('visits');
return knex.schema.createTable('visits', function (table) {
table.timestamp('timestamp').defaultTo(knex.fn.now());
table.string('shortcode');
table.primary(['shortcode', 'timestamp']);
table.foreign('shortcode').references('shortcode').inTable('urls');
});
};