From 8078933b4d83d58858650e3339d034b06f92b0e7 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Mon, 27 Aug 2012 15:40:14 +0300 Subject: [PATCH] started postgres schema --- timespans/storage_postgres.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/timespans/storage_postgres.go b/timespans/storage_postgres.go index 85bb30411..1e128715e 100644 --- a/timespans/storage_postgres.go +++ b/timespans/storage_postgres.go @@ -29,6 +29,36 @@ type PostgresStorage struct { Db *sql.DB } +var ( + schema_sql = ` +CREATE TABLE destination IF NOT EXISTS ( + id SERIAL PRIMARY KEY, + name VARCHAR(512), + prefixes TEXT +); +CREATE TABLE activationprofile IF NOT EXISTS( + id SERIAL PRIMARY KEY, + destination INTEGER REFERENCES destination(id) ON DELETE CASCADE, + activationtime TIMESTAMP +); +CREATE TABLE interval IF NOT EXISTS( + id SERIAL PRIMARY KEY, + activationprofile INTEGER REFERENCES activationprofile(id) ON DELETE CASCADE, + years TEXT, + months TEXT, + monthdays TEXT, + weekdays TEXT, + starttime TIMESTAMP, + endtime TIMESTAMP, + weight FLOAT8, + connectfee FLOAT8, + price FLOAT8, + pricedunits FLOAT8, + rateincrements FLOAT8 +); +` +) + func NewPostgresStorage(host, port, name, user, password string) (DataStorage, error) { db, err := sql.Open("postgres", fmt.Sprintf("host=%s port=%s dbname=%s user=%s password=%s sslmode=disable", host, port, name, user, password)) if err != nil {