finish review for now; start on welcome

trunk
vilmibm 2023-02-24 20:55:16 +00:00
parent ced73adb77
commit fca0ecae4e
7 changed files with 57 additions and 11 deletions

View File

@ -0,0 +1,7 @@
package main
import "fmt"
func main() {
fmt.Println("welcome")
}

BIN
cmd/welcome/welcome 100755

Binary file not shown.

17
review/review.go 100644
View File

@ -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
}

View File

@ -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"

View File

@ -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"

View File

@ -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
);

View File

@ -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)
);