UNPKG

@tanglemedia/directus-extension-bundle-page-views

Version:

A Directus extension bundle that adds a page views collection and dashboard to track page views.

29 lines (25 loc) 932 B
const COLLECTION_NAME = "tngl_page_views"; export async function up(knex) { // if tngl_page_views table exists, do not proceed with migration if (await knex.schema.hasTable(COLLECTION_NAME)) { return; } // create tngl_page_views table await knex.schema.createTable(COLLECTION_NAME, (table) => { table.string("device", 255).nullable(); table.specificType("geolocation", "POINT").nullable(); table.increments("id").unsigned().notNullable(); table.string("ip_address", 255).nullable(); table.string("platform", 255).nullable(); table.string("city", 255).nullable(); table.string("country", 255).nullable(); table.string("page_title", 255).nullable(); table.string("page_url", 255).nullable(); table.datetime("visit_date").nullable(); table.primary(["id"]); }); } export async function down(knex) { // drop table await knex.schema.dropTableIfExists(COLLECTION_NAME); }