mirror of
https://github.com/status-im/fathom.git
synced 2025-03-01 03:20:27 +00:00
add support for postgres too. closes #9
This commit is contained in:
parent
449c6745bb
commit
60cca7d40f
@ -4,9 +4,9 @@ import (
|
||||
"errors"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql" // mysql driver
|
||||
"github.com/jmoiron/sqlx"
|
||||
//_ "github.com/lib/pq" // postgresql driver
|
||||
"github.com/gobuffalo/packr"
|
||||
"github.com/jmoiron/sqlx"
|
||||
_ "github.com/lib/pq" // postgresql driver
|
||||
_ "github.com/mattn/go-sqlite3" //sqlite3 driver
|
||||
migrate "github.com/rubenv/sql-migrate"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
64
pkg/datastore/migrations/postgres/1_initial_tables.sql
Normal file
64
pkg/datastore/migrations/postgres/1_initial_tables.sql
Normal file
@ -0,0 +1,64 @@
|
||||
-- +migrate Up
|
||||
|
||||
CREATE TABLE users(
|
||||
id SERIAL PRIMARY KEY NOT NULL,
|
||||
email VARCHAR(255) NOT NULL,
|
||||
password VARCHAR(255) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE pageviews(
|
||||
id SERIAL PRIMARY KEY NOT NULL,
|
||||
hostname VARCHAR(255) NOT NULL,
|
||||
pathname VARCHAR(255) NOT NULL,
|
||||
session_id VARCHAR(16) NOT NULL,
|
||||
is_new_visitor BOOLEAN NOT NULL,
|
||||
is_new_session BOOLEAN NOT NULL,
|
||||
is_unique BOOLEAN NOT NULL,
|
||||
is_bounce BOOLEAN NULL,
|
||||
referrer VARCHAR(255) NULL,
|
||||
duration INTEGER NULL,
|
||||
timestamp TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE daily_page_stats(
|
||||
hostname VARCHAR(255) NOT NULL,
|
||||
pathname VARCHAR(255) NOT NULL,
|
||||
pageviews INTEGER NOT NULL,
|
||||
visitors INTEGER NOT NULL,
|
||||
entries INTEGER NOT NULL,
|
||||
bounce_rate NUMERIC(2) NOT NULL,
|
||||
avg_duration INTEGER NOT NULL,
|
||||
date DATE NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE daily_site_stats(
|
||||
pageviews INTEGER NOT NULL,
|
||||
visitors INTEGER NOT NULL,
|
||||
sessions INTEGER NOT NULL,
|
||||
bounce_rate NUMERIC(2) NOT NULL,
|
||||
avg_duration INTEGER NOT NULL,
|
||||
date DATE NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE daily_referrer_stats(
|
||||
url VARCHAR(255) NOT NULL,
|
||||
pageviews INTEGER NOT NULL,
|
||||
visitors INTEGER NOT NULL,
|
||||
bounce_rate NUMERIC(2) NOT NULL,
|
||||
avg_duration INTEGER NOT NULL,
|
||||
date DATE NOT NULL
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX unique_user_email ON users(email);
|
||||
CREATE UNIQUE INDEX unique_daily_site_stats ON daily_site_stats(date);
|
||||
CREATE UNIQUE INDEX unique_daily_page_stats ON daily_page_stats(pathname, date);
|
||||
CREATE UNIQUE INDEX unique_daily_referrer_stats ON daily_referrer_stats(url, date);
|
||||
|
||||
-- +migrate Down
|
||||
|
||||
DROP TABLE IF EXISTS users;
|
||||
DROP TABLE IF EXISTS pageviews;
|
||||
DROP TABLE IF EXISTS daily_page_stats;
|
||||
DROP TABLE IF EXISTS daily_site_stats;
|
||||
DROP TABLE IF EXISTS daily_referrer_stats;
|
||||
|
Loading…
x
Reference in New Issue
Block a user