From 0174b40acaa6336804516a3bfcb08f4771acda94 Mon Sep 17 00:00:00 2001 From: "yakumo.izuru" Date: Fri, 28 Apr 2023 22:23:47 +0000 Subject: [PATCH] Support existing Postgres database schemas (if switching from SQLite) and other minor changes. Signed-off-by: Izuru Yakumo git-svn-id: file:///srv/svn/repo/suika/trunk@815 f0ae65fe-ee39-954e-97ec-027ff2717ef4 --- README.md | 2 +- contrib/casemap-logs.sh | 2 +- db_postgres.go | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 185a989..5151c10 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,6 @@ For development, you can use `go run ./cmd/suika` as usual. AGPLv3, see [LICENSE](LICENSE). * Copyright (C) 2020 The soju Contributors -* Copyright (C) 2023-present Aoi K. +* Copyright (C) 2023-present Izuru Yakumo The code for `version.go` is stolen verbatim from one of [@prologic](https://git.mills.io/prologic)'s projects. It's probably under MIT diff --git a/contrib/casemap-logs.sh b/contrib/casemap-logs.sh index 72be262..709d581 100755 --- a/contrib/casemap-logs.sh +++ b/contrib/casemap-logs.sh @@ -2,7 +2,7 @@ # Converts a log dir to its case-mapped form. # -# soju needs to be stopped for this script to work properly. The script may +# suika needs to be stopped for this script to work properly. The script may # re-order messages that happened within the same second interval if merging # two daily log files is necessary. # diff --git a/db_postgres.go b/db_postgres.go index 1fbdf04..d26b9ec 100644 --- a/db_postgres.go +++ b/db_postgres.go @@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS "Config" ( ` const postgresSchema = ` -CREATE TABLE "User" ( +CREATE TABLE IF NOT EXISTS "User" ( id SERIAL PRIMARY KEY, username VARCHAR(255) NOT NULL UNIQUE, password VARCHAR(255), @@ -35,7 +35,7 @@ CREATE TABLE "User" ( CREATE TYPE sasl_mechanism AS ENUM ('PLAIN', 'EXTERNAL'); -CREATE TABLE "Network" ( +CREATE TABLE IF NOT EXISTS "Network" ( id SERIAL PRIMARY KEY, name VARCHAR(255), "user" INTEGER NOT NULL REFERENCES "User"(id) ON DELETE CASCADE, @@ -55,7 +55,7 @@ CREATE TABLE "Network" ( UNIQUE("user", name) ); -CREATE TABLE "Channel" ( +CREATE TABLE IF NOT EXISTS "Channel" ( id SERIAL PRIMARY KEY, network INTEGER NOT NULL REFERENCES "Network"(id) ON DELETE CASCADE, name VARCHAR(255) NOT NULL, @@ -69,7 +69,7 @@ CREATE TABLE "Channel" ( UNIQUE(network, name) ); -CREATE TABLE "DeliveryReceipt" ( +CREATE TABLE IF NOT EXISTS "DeliveryReceipt" ( id SERIAL PRIMARY KEY, network INTEGER NOT NULL REFERENCES "Network"(id) ON DELETE CASCADE, target VARCHAR(255) NOT NULL, @@ -78,7 +78,7 @@ CREATE TABLE "DeliveryReceipt" ( UNIQUE(network, target, client) ); -CREATE TABLE "ReadReceipt" ( +CREATE TABLE IF NOT EXISTS"ReadReceipt" ( id SERIAL PRIMARY KEY, network INTEGER NOT NULL REFERENCES "Network"(id) ON DELETE CASCADE, target VARCHAR(255) NOT NULL, @@ -98,7 +98,7 @@ var postgresMigrations = []string{ USING sasl_mechanism::sasl_mechanism; `, ` - CREATE TABLE "ReadReceipt" ( + CREATE TABLE IF NOT EXISTS "ReadReceipt" ( id SERIAL PRIMARY KEY, network INTEGER NOT NULL REFERENCES "Network"(id) ON DELETE CASCADE, target VARCHAR(255) NOT NULL,