From 23a044d07634180926b05801150d2fa11ed1e6c7 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Mon, 19 Oct 2015 10:41:57 -0700 Subject: [PATCH] fix postgres table creation --- remote/context.go | 31 +++++++++++++++++++++++++++++ shared/database/postgres/1_init.sql | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 remote/context.go diff --git a/remote/context.go b/remote/context.go new file mode 100644 index 000000000..19eeb895d --- /dev/null +++ b/remote/context.go @@ -0,0 +1,31 @@ +package remote + +import ( + "code.google.com/p/go.net/context" +) + +const reqkey = "remote" + +// NewContext returns a Context whose Value method returns +// the applications Remote instance. +func NewContext(parent context.Context, v Remote) context.Context { + return &wrapper{parent, v} +} + +type wrapper struct { + context.Context + v Remote +} + +// Value returns the named key from the context. +func (c *wrapper) Value(key interface{}) interface{} { + if key == reqkey { + return c.v + } + return c.Context.Value(key) +} + +// FromContext returns the Remote associated with this context. +func FromContext(c context.Context) Remote { + return c.Value(reqkey).(Remote) +} diff --git a/shared/database/postgres/1_init.sql b/shared/database/postgres/1_init.sql index d98f3699c..c3e96371a 100644 --- a/shared/database/postgres/1_init.sql +++ b/shared/database/postgres/1_init.sql @@ -112,7 +112,7 @@ CREATE TABLE IF NOT EXISTS logs ( ); CREATE TABLE IF NOT EXISTS nodes ( - node_id INTEGER PRIMARY KEY AUTOINCREMENT + node_id SERIAL PRIMARY KEY ,node_addr VARCHAR(1024) ,node_arch VARCHAR(50) ,node_cert BYTEA