Support existing Postgres database schemas (if switching from SQLite)
and other minor changes. Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja> git-svn-id: https://svn.yakumo.dev/yakumo.izuru/suika/trunk@815 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This commit is contained in:
parent
3fa92e48c2
commit
d916bab2bc
@ -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
|
||||
|
@ -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.
|
||||
#
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user