diff options
author | FChannel <> | 2021-05-13 22:15:52 -0700 |
---|---|---|
committer | FChannel <> | 2021-05-13 22:15:52 -0700 |
commit | 20d0aee3f0bf987eb7e8999977bb25577df7b2d3 (patch) | |
tree | 959643896353dc654a1f0be2c0c34b3a221ebf1b | |
parent | bd637f0f0d601d4aa5cb2dcfdf132060b4cf172c (diff) |
moved creating database schema into main program
-rw-r--r-- | databaseschema.psql | 6 | ||||
-rw-r--r-- | main.go | 12 |
2 files changed, 16 insertions, 2 deletions
diff --git a/databaseschema.psql b/databaseschema.psql index d168882..7e2443c 100644 --- a/databaseschema.psql +++ b/databaseschema.psql @@ -205,4 +205,8 @@ CONSTRAINT fk_object FOREIGN KEY (object) REFERENCES cacheactivitystream(id) CREATE TABLE IF NOT EXISTS removed( id varchar(100), type varchar(25) -);
\ No newline at end of file +); + + +ALTER TABLE activitystream ADD COLUMN IF NOT EXISTS tripcode varchar(50) default ''; +ALTER TABLE cacheactivitystream ADD COLUMN IF NOT EXISTS tripcode varchar(50) default '';
\ No newline at end of file @@ -48,6 +48,8 @@ func main() { defer db.Close() + RunDatabaseSchema(db) + go MakeCaptchas(db, 100) *Key = CreateClientKey() @@ -55,7 +57,7 @@ func main() { FollowingBoards = GetActorFollowingDB(db, Domain) Boards = GetBoardCollection(db) - + // root actor is used to follow remote feeds that are not local //name, prefname, summary, auth requirements, restricted if GetConfigValue("instancename") != "" { @@ -2015,3 +2017,11 @@ func remoteShort(url string) string { return "f" + actorname + "-" + id } + +func RunDatabaseSchema(db *sql.DB) { + query, err := ioutil.ReadFile("databaseschema.psql") + CheckError(err, "could not read databaseschema.psql file") + if _, err := db.Exec(string(query)); err != nil { + CheckError(err, "could not exec databaseschema.psql") + } +} |