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: file:///srv/svn/repo/suika/trunk@815 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This commit is contained in:
parent
3a3759687a
commit
0174b40aca
@ -29,6 +29,6 @@ For development, you can use `go run ./cmd/suika` as usual.
|
|||||||
AGPLv3, see [LICENSE](LICENSE).
|
AGPLv3, see [LICENSE](LICENSE).
|
||||||
|
|
||||||
* Copyright (C) 2020 The soju Contributors
|
* 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
|
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.
|
# 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
|
# re-order messages that happened within the same second interval if merging
|
||||||
# two daily log files is necessary.
|
# two daily log files is necessary.
|
||||||
#
|
#
|
||||||
|
@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS "Config" (
|
|||||||
`
|
`
|
||||||
|
|
||||||
const postgresSchema = `
|
const postgresSchema = `
|
||||||
CREATE TABLE "User" (
|
CREATE TABLE IF NOT EXISTS "User" (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
username VARCHAR(255) NOT NULL UNIQUE,
|
username VARCHAR(255) NOT NULL UNIQUE,
|
||||||
password VARCHAR(255),
|
password VARCHAR(255),
|
||||||
@ -35,7 +35,7 @@ CREATE TABLE "User" (
|
|||||||
|
|
||||||
CREATE TYPE sasl_mechanism AS ENUM ('PLAIN', 'EXTERNAL');
|
CREATE TYPE sasl_mechanism AS ENUM ('PLAIN', 'EXTERNAL');
|
||||||
|
|
||||||
CREATE TABLE "Network" (
|
CREATE TABLE IF NOT EXISTS "Network" (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
name VARCHAR(255),
|
name VARCHAR(255),
|
||||||
"user" INTEGER NOT NULL REFERENCES "User"(id) ON DELETE CASCADE,
|
"user" INTEGER NOT NULL REFERENCES "User"(id) ON DELETE CASCADE,
|
||||||
@ -55,7 +55,7 @@ CREATE TABLE "Network" (
|
|||||||
UNIQUE("user", name)
|
UNIQUE("user", name)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE "Channel" (
|
CREATE TABLE IF NOT EXISTS "Channel" (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
network INTEGER NOT NULL REFERENCES "Network"(id) ON DELETE CASCADE,
|
network INTEGER NOT NULL REFERENCES "Network"(id) ON DELETE CASCADE,
|
||||||
name VARCHAR(255) NOT NULL,
|
name VARCHAR(255) NOT NULL,
|
||||||
@ -69,7 +69,7 @@ CREATE TABLE "Channel" (
|
|||||||
UNIQUE(network, name)
|
UNIQUE(network, name)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE "DeliveryReceipt" (
|
CREATE TABLE IF NOT EXISTS "DeliveryReceipt" (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
network INTEGER NOT NULL REFERENCES "Network"(id) ON DELETE CASCADE,
|
network INTEGER NOT NULL REFERENCES "Network"(id) ON DELETE CASCADE,
|
||||||
target VARCHAR(255) NOT NULL,
|
target VARCHAR(255) NOT NULL,
|
||||||
@ -78,7 +78,7 @@ CREATE TABLE "DeliveryReceipt" (
|
|||||||
UNIQUE(network, target, client)
|
UNIQUE(network, target, client)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE "ReadReceipt" (
|
CREATE TABLE IF NOT EXISTS"ReadReceipt" (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
network INTEGER NOT NULL REFERENCES "Network"(id) ON DELETE CASCADE,
|
network INTEGER NOT NULL REFERENCES "Network"(id) ON DELETE CASCADE,
|
||||||
target VARCHAR(255) NOT NULL,
|
target VARCHAR(255) NOT NULL,
|
||||||
@ -98,7 +98,7 @@ var postgresMigrations = []string{
|
|||||||
USING sasl_mechanism::sasl_mechanism;
|
USING sasl_mechanism::sasl_mechanism;
|
||||||
`,
|
`,
|
||||||
`
|
`
|
||||||
CREATE TABLE "ReadReceipt" (
|
CREATE TABLE IF NOT EXISTS "ReadReceipt" (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
network INTEGER NOT NULL REFERENCES "Network"(id) ON DELETE CASCADE,
|
network INTEGER NOT NULL REFERENCES "Network"(id) ON DELETE CASCADE,
|
||||||
target VARCHAR(255) NOT NULL,
|
target VARCHAR(255) NOT NULL,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user