UNPKG

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

Version:

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

51 lines (47 loc) 1.92 kB
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("country_code", 255).nullable(); table.string("country_name", 255).nullable(); table.datetime("date_created").nullable(); table.datetime("date_updated").nullable(); table.string("device", 255).nullable(); table.decimal("device_height", 10, 5).nullable(); table.decimal("device_width", 10, 5).nullable(); table.integer("duration").nullable(); table.string("endpoint", 255).nullable(); table.string("environment", 255).nullable(); table.specificType("geolocation", "POINT"); table.increments("id").unsigned().notNullable(); table.string("ip_address", 255).nullable(); table.string("kind", 255).nullable(); table.string("language", 255).nullable(); table.string("language_name", 255).nullable(); table.decimal("load_time", 10, 5).nullable(); table.json("location_payload").nullable(); table.string("navigation", 255).nullable(); table.string("orientation", 255).nullable(); table.string("origin", 255).nullable(); table.string("platform", 255).nullable(); table.decimal("render_time", 10, 5).nullable(); table.decimal("request_response_time", 10, 5).nullable(); table.decimal("screen_height", 10, 5).nullable(); table.decimal("screen_width", 10, 5).nullable(); table.string("section", 255).nullable(); table.string("session_id", 255).nullable(); table.string("source", 255).nullable(); table.string("timezone", 255).nullable(); table.string("title", 255).nullable(); table.string("url", 255).nullable(); table.primary(["id"]); }); } export async function down(knex) { // drop table await knex.schema.dropTableIfExists(COLLECTION_NAME); }