use embed to include schema

This commit is contained in:
Ted Unangst 2022-05-31 02:32:22 -04:00
parent 2128c6579c
commit d2a6d6829a
6 changed files with 11 additions and 51 deletions

View File

@ -1,10 +1,7 @@
all: honk all: honk
schema.go: schema.sql honk: .preflightcheck schema.sql *.go go.mod
sh ./genschemago.sh
honk: .preflightcheck schema.go *.go go.mod
go build -mod=`ls -d vendor 2> /dev/null` -o honk go build -mod=`ls -d vendor 2> /dev/null` -o honk
.preflightcheck: preflight.sh .preflightcheck: preflight.sh

View File

@ -20,6 +20,7 @@ import (
"crypto/sha512" "crypto/sha512"
"database/sql" "database/sql"
"encoding/json" "encoding/json"
_ "embed"
"fmt" "fmt"
"html/template" "html/template"
"sort" "sort"
@ -34,6 +35,9 @@ import (
"humungus.tedunangst.com/r/webs/mz" "humungus.tedunangst.com/r/webs/mz"
) )
//go:embed schema.sql
var sqlSchema string
func userfromrow(row *sql.Row) (*WhatAbout, error) { func userfromrow(row *sql.Row) (*WhatAbout, error) {
user := new(WhatAbout) user := new(WhatAbout)
var seckey, options string var seckey, options string

View File

@ -2,6 +2,8 @@ changelog
=== next === next
- go version 1.16 required.
+ Specify banner: image in profile. + Specify banner: image in profile.
+ Update activity compatibility with mastodon. + Update activity compatibility with mastodon.

2
go.mod
View File

@ -1,6 +1,6 @@
module humungus.tedunangst.com/r/honk module humungus.tedunangst.com/r/honk
go 1.13 go 1.16
require ( require (
github.com/andybalholm/cascadia v1.3.1 github.com/andybalholm/cascadia v1.3.1

View File

@ -1,12 +1,12 @@
set -e set -e
go version > /dev/null 2>&1 || (echo go 1.13+ is required && false) go version > /dev/null 2>&1 || (echo go 1.16+ is required && false)
v=`go version | egrep -o 'go1[^ ]+'` v=`go version | egrep -o 'go1[^ ]+'`
case $v in case $v in
go1.10*|go1.11*|go1.12*) go1.10*|go1.11*|go1.12*|go1.13*|go1.14*|go1.15*)
echo go version is too old: $v echo go version is too old: $v
echo go 1.13+ is required echo go 1.16+ is required
false false
;; ;;
go1.1*) go1.1*)

View File

@ -1,43 +0,0 @@
package main
var sqlSchema = `
create table honks (honkid integer primary key, userid integer, what text, honker text, xid text, rid text, dt text, url text, audience text, noise text, convoy text, whofore integer, format text, precis text, oonker text, flags integer);
create table chonks (chonkid integer primary key, userid integer, xid text, who txt, target text, dt text, noise text, format text);
create table donks (honkid integer, chonkid integer, fileid integer);
create table filemeta (fileid integer primary key, xid text, name text, description text, url text, media text, local integer);
create table honkers (honkerid integer primary key, userid integer, name text, xid text, flavor text, combos text, owner text, meta text, folxid text);
create table xonkers (xonkerid integer primary key, name text, info text, flavor text, dt text);
create table zonkers (zonkerid integer primary key, userid integer, name text, wherefore text);
create table doovers(dooverid integer primary key, dt text, tries integer, userid integer, rcpt text, msg blob);
create table onts (ontology text, honkid integer);
create table honkmeta (honkid integer, genus text, json text);
create table hfcs (hfcsid integer primary key, userid integer, json text);
create table tracks (xid text, fetches text);
create index idx_honksxid on honks(xid);
create index idx_honksconvoy on honks(convoy);
create index idx_honkshonker on honks(honker);
create index idx_honksoonker on honks(oonker);
create index idx_donkshonk on donks(honkid);
create index idx_donkschonk on donks(chonkid);
create index idx_honkerxid on honkers(xid);
create index idx_xonkername on xonkers(name);
create index idx_zonkersname on zonkers(name);
create index idx_filesxid on filemeta(xid);
create index idx_filesurl on filemeta(url);
create index idx_ontology on onts(ontology);
create index idx_onthonkid on onts(honkid);
create index idx_honkmetaid on honkmeta(honkid);
create index idx_hfcsuser on hfcs(userid);
create index idx_trackhonkid on tracks(xid);
create table config (key text, value text);
create table users (userid integer primary key, username text, hash text, displayname text, about text, pubkey text, seckey text, options text);
create table auth (authid integer primary key, userid integer, hash text, expiry text);
CREATE index idxusers_username on users(username);
CREATE index idxauth_userid on auth(userid);
CREATE index idxauth_hash on auth(hash);
`