Switch startup, config, commands and db migrations to mautrix-go systems

This commit is contained in:
Tulir Asokan
2022-05-22 22:16:42 +03:00
parent cf5384d908
commit 9f9f7ca4fd
74 changed files with 3470 additions and 5682 deletions

View File

@@ -0,0 +1,105 @@
-- v1: Initial revision
CREATE TABLE portal (
channel_id TEXT,
receiver TEXT,
mxid TEXT UNIQUE,
name TEXT NOT NULL,
topic TEXT NOT NULL,
avatar TEXT NOT NULL,
avatar_url TEXT,
encrypted BOOLEAN NOT NULL DEFAULT false,
type INT,
dmuser TEXT,
first_event_id TEXT,
PRIMARY KEY (channel_id, receiver)
);
CREATE TABLE puppet (
id TEXT PRIMARY KEY,
display_name TEXT,
avatar TEXT,
avatar_url TEXT,
enable_presence BOOLEAN NOT NULL DEFAULT true,
enable_receipts BOOLEAN NOT NULL DEFAULT true,
custom_mxid TEXT,
access_token TEXT,
next_batch TEXT
);
CREATE TABLE "user" (
mxid TEXT PRIMARY KEY,
id TEXT UNIQUE,
management_room TEXT,
token TEXT
);
CREATE TABLE message (
channel_id TEXT NOT NULL,
receiver TEXT NOT NULL,
discord_message_id TEXT NOT NULL,
matrix_message_id TEXT NOT NULL UNIQUE,
author_id TEXT NOT NULL,
timestamp BIGINT NOT NULL,
PRIMARY KEY(discord_message_id, channel_id, receiver),
FOREIGN KEY(channel_id, receiver) REFERENCES portal(channel_id, receiver) ON DELETE CASCADE
);
CREATE TABLE reaction (
channel_id TEXT NOT NULL,
receiver TEXT NOT NULL,
discord_message_id TEXT NOT NULL,
matrix_event_id TEXT NOT NULL UNIQUE,
author_id TEXT NOT NULL,
matrix_name TEXT,
matrix_url TEXT,
discord_id TEXT,
UNIQUE (discord_id, author_id, discord_message_id, channel_id, receiver),
FOREIGN KEY(channel_id, receiver) REFERENCES portal(channel_id, receiver) ON DELETE CASCADE
);
CREATE TABLE attachment (
channel_id TEXT NOT NULL,
receiver TEXT NOT NULL,
discord_message_id TEXT NOT NULL,
discord_attachment_id TEXT NOT NULL,
matrix_event_id TEXT NOT NULL UNIQUE,
PRIMARY KEY(discord_attachment_id, matrix_event_id),
FOREIGN KEY(channel_id, receiver) REFERENCES portal(channel_id, receiver) ON DELETE CASCADE
);
CREATE TABLE emoji (
discord_id TEXT PRIMARY KEY,
discord_name TEXT,
matrix_url TEXT
);
CREATE TABLE guild (
discord_id TEXT NOT NULL,
guild_id TEXT NOT NULL,
guild_name TEXT NOT NULL,
bridge BOOLEAN DEFAULT FALSE,
PRIMARY KEY(discord_id, guild_id)
);

View File

@@ -0,0 +1,32 @@
// mautrix-discord - A Matrix-Discord puppeting bridge.
// Copyright (C) 2022 Tulir Asokan
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package upgrades
import (
"embed"
"maunium.net/go/mautrix/util/dbutil"
)
var Table dbutil.UpgradeTable
//go:embed *.sql
var rawUpgrades embed.FS
func init() {
Table.RegisterFS(rawUpgrades)
}