diff --git a/cmd/welcome/main.go b/cmd/welcome/main.go new file mode 100644 index 0000000..2d7bffa --- /dev/null +++ b/cmd/welcome/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("welcome") +} diff --git a/cmd/welcome/welcome b/cmd/welcome/welcome new file mode 100755 index 0000000..d31c5ed Binary files /dev/null and b/cmd/welcome/welcome differ diff --git a/review/review.go b/review/review.go new file mode 100644 index 0000000..1242b9b --- /dev/null +++ b/review/review.go @@ -0,0 +1,17 @@ +package review + +import ( + "database/sql" + _ "github.com/mattn/go-sqlite3" +) + +const dsn = "/town/var/users.db?mode=rw" + +func ConnectDB() (*sql.DB, error) { + db, err := sql.Open("sqlite3", dsn) + if err != nil { + return nil, err + } + + return db, nil +} diff --git a/scripts/reset_invites_db.sh b/scripts/reset_invites_db.sh new file mode 100755 index 0000000..8b3a9d1 --- /dev/null +++ b/scripts/reset_invites_db.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +dbpath="/town/var/invites/invites.db" +srcpath="/town/src/town" + +rm -f "$dbpath" +sqlite3 < "${srcpath}/sql/create_invites_db.sql" "$dbpath" +chown welcome:admin "$dbpath" +chmod o-r "$dbpath" +chmod g+w "$dbpath" diff --git a/scripts/reset_signups_db.sh b/scripts/reset_signups_db.sh new file mode 100755 index 0000000..24b1031 --- /dev/null +++ b/scripts/reset_signups_db.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +dbpath="/town/var/signups/signups.db" +srcpath="/town/src/town" + +rm -f "$dbpath" +sqlite3 < "${srcpath}/sql/create_signups_db.sql" "$dbpath" +chown join:admin "$dbpath" +chmod o-r "$dbpath" +chmod g+w "$dbpath" diff --git a/sql/create_invites_db.sql b/sql/create_invites_db.sql new file mode 100644 index 0000000..fdfc214 --- /dev/null +++ b/sql/create_invites_db.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS invites ( + id INTEGER PRIMARY KEY, + created TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M', 'now', 'localtime')), + code TEXT, + email TEXT, + used INTEGER DEFAULT 0 +); diff --git a/sql/create_user_db.sql b/sql/create_user_db.sql index b5890af..38854e2 100644 --- a/sql/create_user_db.sql +++ b/sql/create_user_db.sql @@ -28,18 +28,9 @@ CREATE TABLE IF NOT EXISTS user_notes ( CREATE TABLE IF NOT EXISTS notes ( id INTEGER PRIMARY KEY, - adminid INTEGER, - text TEXT, + author INTEGER, + content TEXT, created TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M', 'now', 'localtime')), FOREIGN KEY (adminid) REFERENCES users(adminid) ); - -CREATE TABLE IF NOT EXISTS signup_notes ( - noteid INTEGER, - signupid INTEGER, - - PRIMARY KEY (noteid, signupid), - FOREIGN KEY (noteid) REFERENCES notes(noteid), - FOREIGN KEY (signupid) REFERENCES signups(signupid) -);