mirror of
https://github.com/spacebarchat/server.git
synced 2026-06-07 04:31:39 +00:00
Push local state...
This commit is contained in:
+112
-13604
File diff suppressed because it is too large
Load Diff
+76
-73
@@ -1,81 +1,84 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Discord Test Client</title>
|
||||
<link rel="stylesheet" href="/assets/fosscord.css" />
|
||||
<link id="logincss" rel="stylesheet" href="/assets/fosscord-login.css" />
|
||||
<link id="customcss" rel="stylesheet" href="/assets/user.css" />
|
||||
<!-- inline plugin marker -->
|
||||
<!-- preload plugin marker -->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app-mount"></div>
|
||||
<script>
|
||||
window.__OVERLAY__ = /overlay/.test(location.pathname);
|
||||
window.__BILLING_STANDALONE__ = /^\/billing/.test(location.pathname);
|
||||
window.GLOBAL_ENV = {
|
||||
API_ENDPOINT: "/api",
|
||||
API_VERSION: 9,
|
||||
GATEWAY_ENDPOINT: `${location.protocol === "https:" ? "wss://" : "ws://"}${location.hostname}:3002`,
|
||||
WEBAPP_ENDPOINT: "",
|
||||
CDN_HOST: `${location.hostname}:3003`,
|
||||
ASSET_ENDPOINT: "",
|
||||
MEDIA_PROXY_ENDPOINT: "https://media.discordapp.net",
|
||||
WIDGET_ENDPOINT: `//${location.host}/widget`,
|
||||
INVITE_HOST: `${location.hostname}/invite`,
|
||||
GUILD_TEMPLATE_HOST: "${location.host}",
|
||||
GIFT_CODE_HOST: "${location.hostname}",
|
||||
RELEASE_CHANNEL: "stable",
|
||||
MARKETING_ENDPOINT: "//discord.com",
|
||||
BRAINTREE_KEY: "production_5st77rrc_49pp2rp4phym7387",
|
||||
STRIPE_KEY: "pk_live_CUQtlpQUF0vufWpnpUmQvcdi",
|
||||
NETWORKING_ENDPOINT: "//router.discordapp.net",
|
||||
RTC_LATENCY_ENDPOINT: "//${location.hostname}/rtc",
|
||||
PROJECT_ENV: "production",
|
||||
REMOTE_AUTH_ENDPOINT: "//localhost:3020",
|
||||
SENTRY_TAGS: { buildId: "75e36d9", buildType: "normal" },
|
||||
MIGRATION_SOURCE_ORIGIN: "https://${location.hostname}",
|
||||
MIGRATION_DESTINATION_ORIGIN: "https://${location.hostname}",
|
||||
HTML_TIMESTAMP: Date.now(),
|
||||
ALGOLIA_KEY: "aca0d7082e4e63af5ba5917d5e96bed0"
|
||||
};
|
||||
GLOBAL_ENV.MEDIA_PROXY_ENDPOINT = location.protocol + "//" + GLOBAL_ENV.CDN_HOST;
|
||||
const localStorage = window.localStorage;
|
||||
// TODO: remote auth
|
||||
// window.GLOBAL_ENV.REMOTE_AUTH_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ENDPOINT.replace(/wss?:/, "");
|
||||
localStorage.setItem("gatewayURL", window.GLOBAL_ENV.GATEWAY_ENDPOINT);
|
||||
localStorage.setItem(
|
||||
"DeveloperOptionsStore",
|
||||
`{"trace":false,"canary":false,"logGatewayEvents":true,"logOverlayEvents":true,"logAnalyticsEvents":true,"sourceMapsEnabled":false,"axeEnabled":false}`
|
||||
);
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Discord Test Client</title>
|
||||
<link rel="stylesheet" href="/assets/fosscord.css" />
|
||||
<link id="logincss" rel="stylesheet" href="/assets/fosscord-login.css" />
|
||||
<link id="customcss" rel="stylesheet" href="/assets/user.css" />
|
||||
<!-- inline plugin marker -->
|
||||
<!-- preload plugin marker -->
|
||||
</head>
|
||||
|
||||
setInterval(() => {
|
||||
let token = JSON.parse(localStorage.getItem("token"));
|
||||
if (token) {
|
||||
let logincss = document.querySelector('#logincss'),
|
||||
canRemove = logincss ? logincss: "";
|
||||
if(canRemove !== "") {
|
||||
<body>
|
||||
<div id="app-mount"></div>
|
||||
<script>
|
||||
window.__OVERLAY__ = /overlay/.test(location.pathname);
|
||||
window.__BILLING_STANDALONE__ = /^\/billing/.test(location.pathname);
|
||||
window.GLOBAL_ENV = {
|
||||
API_ENDPOINT: "/api",
|
||||
API_VERSION: 9,
|
||||
GATEWAY_ENDPOINT: `${location.protocol === "https:" ? "wss://" : "ws://"}${location.hostname}:3002`,
|
||||
WEBAPP_ENDPOINT: "",
|
||||
CDN_HOST: `${location.hostname}:3003`,
|
||||
ASSET_ENDPOINT: "",
|
||||
MEDIA_PROXY_ENDPOINT: "https://media.discordapp.net",
|
||||
WIDGET_ENDPOINT: `//${location.host}/widget`,
|
||||
INVITE_HOST: `${location.hostname}/invite`,
|
||||
GUILD_TEMPLATE_HOST: "${location.host}",
|
||||
GIFT_CODE_HOST: "${location.hostname}",
|
||||
RELEASE_CHANNEL: "stable",
|
||||
MARKETING_ENDPOINT: "//discord.com",
|
||||
BRAINTREE_KEY: "production_5st77rrc_49pp2rp4phym7387",
|
||||
STRIPE_KEY: "pk_live_CUQtlpQUF0vufWpnpUmQvcdi",
|
||||
NETWORKING_ENDPOINT: "//router.discordapp.net",
|
||||
RTC_LATENCY_ENDPOINT: "//${location.hostname}/rtc",
|
||||
ACTIVITY_APPLICATION_HOST: 'discordsays.com',
|
||||
PROJECT_ENV: "production",
|
||||
REMOTE_AUTH_ENDPOINT: "//localhost:3020",
|
||||
SENTRY_TAGS: { buildId: "75e36d9", buildType: "normal" },
|
||||
MIGRATION_SOURCE_ORIGIN: "https://${location.hostname}",
|
||||
MIGRATION_DESTINATION_ORIGIN: "https://${location.hostname}",
|
||||
HTML_TIMESTAMP: Date.now(),
|
||||
ALGOLIA_KEY: "aca0d7082e4e63af5ba5917d5e96bed0",
|
||||
};
|
||||
GLOBAL_ENV.MEDIA_PROXY_ENDPOINT = location.protocol + "//" + GLOBAL_ENV.CDN_HOST;
|
||||
const localStorage = window.localStorage;
|
||||
// TODO: remote auth
|
||||
// window.GLOBAL_ENV.REMOTE_AUTH_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ENDPOINT.replace(/wss?:/, "");
|
||||
localStorage.setItem("gatewayURL", window.GLOBAL_ENV.GATEWAY_ENDPOINT);
|
||||
localStorage.setItem(
|
||||
"DeveloperOptionsStore",
|
||||
`{"trace":false,"canary":false,"logGatewayEvents":true,"logOverlayEvents":true,"logAnalyticsEvents":true,"sourceMapsEnabled":false,"axeEnabled":false}`
|
||||
);
|
||||
|
||||
setInterval(() => {
|
||||
let token = JSON.parse(localStorage.getItem("token"));
|
||||
if (token) {
|
||||
let logincss = document.querySelector('#logincss'),
|
||||
canRemove = logincss ? logincss : "";
|
||||
if (canRemove !== "") {
|
||||
document.querySelector("#logincss").remove();
|
||||
canRemove = "";
|
||||
}
|
||||
}
|
||||
}, 1000)
|
||||
|
||||
const settings = JSON.parse(localStorage.getItem("UserSettingsStore"));
|
||||
if (settings && settings.locale.length <= 2) {
|
||||
// fix client locale wrong and client not loading at all
|
||||
settings.locale = "en-US";
|
||||
localStorage.setItem("UserSettingsStore", JSON.stringify(settings));
|
||||
}
|
||||
</script>
|
||||
<script src="/assets/checkLocale.js"></script>
|
||||
<script src="/assets/1e18f2aac02e172db283.js"></script>
|
||||
<script src="/assets/681e53cdfefa5b82249a.js"></script>
|
||||
<script src="/assets/7a036838c0a0e73f59d8.js"></script>
|
||||
<script src="/assets/b6cf2184a7a05e7525ce.js"></script>
|
||||
<!-- plugin marker -->
|
||||
</body>
|
||||
</html>
|
||||
}, 1000)
|
||||
|
||||
const settings = JSON.parse(localStorage.getItem("UserSettingsStore"));
|
||||
if (settings && settings.locale.length <= 2) {
|
||||
// fix client locale wrong and client not loading at all
|
||||
settings.locale = "en-US";
|
||||
localStorage.setItem("UserSettingsStore", JSON.stringify(settings));
|
||||
}
|
||||
</script>
|
||||
<script src="/assets/checkLocale.js"></script>
|
||||
<script src="/assets/2f2e0c25e45eb2f5a6f1.js"></script>
|
||||
<script src="/assets/006e72c08a4c69cb66fc.js"></script>
|
||||
<script src="/assets/2f94a3ba801087653a38.js"></script>
|
||||
<script src="/assets/f7703f092bdbfc607cc7.js"></script>
|
||||
<!-- plugin marker -->
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -30,6 +30,7 @@ export interface RegisterSchema {
|
||||
date_of_birth?: Date; // "2000-04-03"
|
||||
gift_code_sku_id?: string;
|
||||
captcha_key?: string;
|
||||
promotional_email_opt_in?: boolean;
|
||||
}
|
||||
|
||||
router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Response) => {
|
||||
|
||||
@@ -21,6 +21,7 @@ export interface GuildUpdateSchema extends Omit<GuildCreateSchema, "channels" |
|
||||
afk_timeout?: number;
|
||||
afk_channel_id?: string;
|
||||
preferred_locale?: string;
|
||||
premium_progress_bar_enabled?: boolean;
|
||||
}
|
||||
|
||||
router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
|
||||
@@ -10,8 +10,8 @@ router.patch("/", route({ body: "UserSettingsSchema" }), async (req: Request, re
|
||||
const body = req.body as UserSettings;
|
||||
if (body.locale === "en") body.locale = "en-US"; // fix discord client crash on unkown locale
|
||||
|
||||
const user = await User.findOneOrFail({ where: { id: req.user_id, bot: false } });
|
||||
user.settings = { ...user.settings, ...body };
|
||||
const user = await User.findOneOrFail({ where: { id: req.user_id, bot: false }, relations: ["settings"] });
|
||||
user.settings = { ...user.settings, ...body } as UserSettings;
|
||||
await user.save();
|
||||
|
||||
res.sendStatus(204);
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
#!/bin/sh
|
||||
read -p "Enter migration filename: " FILENAME
|
||||
|
||||
if [ ! -z "$1" ]
|
||||
then
|
||||
FILENAME="$1"
|
||||
echo "Using filename: $FILENAME"
|
||||
else
|
||||
read -p "Enter migration filename: " FILENAME
|
||||
fi
|
||||
|
||||
[ -f ".env" ] && (
|
||||
mv .env .env.tmp
|
||||
source .env.tmp
|
||||
@@ -8,8 +16,8 @@ read -p "Enter migration filename: " FILENAME
|
||||
make_migration() {
|
||||
echo "Creating migrations for $2"
|
||||
mkdir "../util/src/migrations/$2"
|
||||
npm run build clean logerrors pretty-errors
|
||||
THREADS=1 DATABASE="$1" DB_MIGRATE=a npm run start:bundle
|
||||
# npm run build clean logerrors pretty-errors
|
||||
# THREADS=1 DATABASE="$1" DB_MIGRATE=a npm run start:bundle
|
||||
THREADS=1 DATABASE="$1" DB_MIGRATE=a npx typeorm-ts-node-commonjs migration:generate "../util/src/migrations/$2/$FILENAME" -d ../util/src/util/Database.ts -p
|
||||
npm run build clean logerrors pretty-errors
|
||||
THREADS=1 DATABASE="$1" DB_MIGRATE=a npm run start:bundle
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const { execIn, getLines, parts } = require('./utils');
|
||||
|
||||
if (!process.argv[2] || !fs.existsSync(process.argv[2])) {
|
||||
console.log("Please pass a directory that exists!");
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(`// ${process.argv[2]}/index.ts`)
|
||||
const recurse = process.argv.includes("--recursive")
|
||||
|
||||
const files = fs.readdirSync(process.argv[2]).filter(x => x.endsWith('.ts') && x != 'index.ts');
|
||||
|
||||
let output = '';
|
||||
|
||||
files.forEach(x => output += `export * from "./${x.replaceAll('.ts','')}";\n`)
|
||||
|
||||
const dirs = fs.readdirSync(process.argv[2]).filter(x => {
|
||||
try {
|
||||
fs.readdirSync(path.join(process.argv[2], x));
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
dirs.forEach(x => {
|
||||
output += `export * from "./${x}/index";\n`
|
||||
})
|
||||
console.log(output);
|
||||
fs.writeFileSync(path.join(process.argv[2], "index.ts"), output)
|
||||
|
||||
dirs.forEach(x => {
|
||||
if(recurse) console.log(execIn([process.argv[0], process.argv[1], `"${path.join(process.argv[2], x)}"`, "--recursive"].join(' '), process.cwd()))
|
||||
})
|
||||
@@ -0,0 +1,9 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const { env } = require("process");
|
||||
const { execSync } = require("child_process");
|
||||
const { argv, stdout, exit } = require("process");
|
||||
|
||||
const { execIn, getLines, parts } = require("./utils");
|
||||
|
||||
execIn("node scripts/generate_schema.js", path.join("..", "..", "api"));
|
||||
@@ -28,13 +28,14 @@ function copyRecursiveSync(src, dest) {
|
||||
}
|
||||
}
|
||||
|
||||
function execIn(cmd, workdir) {
|
||||
function execIn(cmd, workdir, opts) {
|
||||
try {
|
||||
return execSync(cmd, {
|
||||
cwd: workdir,
|
||||
shell: true,
|
||||
env: process.env,
|
||||
encoding: "utf-8",
|
||||
...opts
|
||||
});
|
||||
} catch (error) {
|
||||
return error.stdout;
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
PrivateSessionProjection,
|
||||
MemberPrivateProjection,
|
||||
PresenceUpdateEvent,
|
||||
UserSettings,
|
||||
} from "@fosscord/util";
|
||||
import { Send } from "../util/Send";
|
||||
import { CLOSECODES, OPCODES } from "../util/Constants";
|
||||
@@ -56,7 +57,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
||||
await Promise.all([
|
||||
User.findOneOrFail({
|
||||
where: { id: this.user_id },
|
||||
relations: ["relationships", "relationships.to"],
|
||||
relations: ["relationships", "relationships.to", "settings"],
|
||||
select: [...PrivateUserProjection, "relationships"],
|
||||
}),
|
||||
ReadState.find({ where: { user_id: this.user_id } }),
|
||||
@@ -101,6 +102,10 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
||||
]);
|
||||
|
||||
if (!user) return this.close(CLOSECODES.Authentication_failed);
|
||||
if (!user.settings) {
|
||||
user.settings = new UserSettings();
|
||||
await user.settings.save();
|
||||
}
|
||||
|
||||
if (!identify.intents) identify.intents = BigInt("0x6ffffffff");
|
||||
this.intents = new Intents(identify.intents);
|
||||
|
||||
@@ -20,6 +20,11 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) {
|
||||
check.call(this, VoiceStateUpdateSchema, data.d);
|
||||
const body = data.d as VoiceStateUpdateSchema;
|
||||
|
||||
if(body.guild_id == null) {
|
||||
console.log(`[Gateway] VoiceStateUpdate called with guild_id == null by user ${this.user_id}!`);
|
||||
return;
|
||||
}
|
||||
|
||||
let voiceState: VoiceState;
|
||||
try {
|
||||
voiceState = await VoiceState.findOneOrFail({
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { GuildDefaults } from ".";
|
||||
import { GuildDefaults, UserDefaults } from ".";
|
||||
|
||||
export class DefaultsConfiguration {
|
||||
guild: GuildDefaults = new GuildDefaults();
|
||||
user: UserDefaults = new UserDefaults();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export class UserDefaults {
|
||||
premium: boolean = false;
|
||||
premium_type: number = 2;
|
||||
verified: boolean = true;
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
export * from "./GuildDefaults";
|
||||
export * from "./UserDefaults";
|
||||
|
||||
@@ -53,7 +53,7 @@ export class Guild extends BaseClass {
|
||||
afk_channel?: Channel;
|
||||
|
||||
@Column({ nullable: true })
|
||||
afk_timeout?: number;
|
||||
afk_timeout?: number = Config.get().defaults.guild.afkTimeout;
|
||||
|
||||
// * commented out -> use owner instead
|
||||
// application id of the guild creator if it is bot-created
|
||||
@@ -71,7 +71,7 @@ export class Guild extends BaseClass {
|
||||
banner?: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
default_message_notifications?: number;
|
||||
default_message_notifications?: number = Config.get().defaults.guild.defaultMessageNotifications;
|
||||
|
||||
@Column({ nullable: true })
|
||||
description?: string;
|
||||
@@ -80,7 +80,7 @@ export class Guild extends BaseClass {
|
||||
discovery_splash?: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
explicit_content_filter?: number;
|
||||
explicit_content_filter?: number = Config.get().defaults.guild.explicitContentFilter;
|
||||
|
||||
@Column({ type: "simple-array" })
|
||||
features: string[]; //TODO use enum
|
||||
@@ -96,19 +96,19 @@ export class Guild extends BaseClass {
|
||||
large?: boolean;
|
||||
|
||||
@Column({ nullable: true })
|
||||
max_members?: number; // e.g. default 100.000
|
||||
max_members?: number = Config.get().limits.guild.maxMembers; // e.g. default 100.000
|
||||
|
||||
@Column({ nullable: true })
|
||||
max_presences?: number;
|
||||
max_presences?: number = Config.get().defaults.guild.maxPresences;
|
||||
|
||||
@Column({ nullable: true })
|
||||
max_video_channel_users?: number; // ? default: 25, is this max 25 streaming or watching
|
||||
max_video_channel_users?: number = Config.get().defaults.guild.maxVideoChannelUsers; // ? default: 25, is this max 25 streaming or watching
|
||||
|
||||
@Column({ nullable: true })
|
||||
member_count?: number;
|
||||
member_count?: number = 0;
|
||||
|
||||
@Column({ nullable: true })
|
||||
presence_count?: number; // users online
|
||||
presence_count?: number = 0; // users online
|
||||
|
||||
@OneToMany(() => Member, (member: Member) => member.guild, {
|
||||
cascade: true,
|
||||
@@ -278,6 +278,10 @@ export class Guild extends BaseClass {
|
||||
// only for developer portal
|
||||
permissions?: number;
|
||||
|
||||
//new guild settings, 11/08/2022:
|
||||
@Column({ nullable: true })
|
||||
premium_progress_bar_enabled: boolean = false;
|
||||
|
||||
static async createGuild(body: {
|
||||
name?: string;
|
||||
icon?: string | null;
|
||||
|
||||
+35
-123
@@ -1,11 +1,11 @@
|
||||
import { Column, Entity, FindOneOptions, FindOptionsSelectByString, JoinColumn, OneToMany } from "typeorm";
|
||||
import { Column, Entity, FindOneOptions, FindOptionsSelectByString, JoinColumn, OneToMany, OneToOne } from "typeorm";
|
||||
import { OrmUtils } from "../util/imports/OrmUtils";
|
||||
import { BaseClass } from "./BaseClass";
|
||||
import { BitField } from "../util/BitField";
|
||||
import { Relationship } from "./Relationship";
|
||||
import { ConnectedAccount } from "./ConnectedAccount";
|
||||
import { Config, FieldErrors, Snowflake, trimSpecial } from "..";
|
||||
import { Member, Session } from ".";
|
||||
import { Member, Session, UserSettings } from ".";
|
||||
|
||||
export enum PublicUserEnum {
|
||||
username,
|
||||
@@ -83,28 +83,28 @@ export class User extends BaseClass {
|
||||
phone?: string; // phone number of the user
|
||||
|
||||
@Column({ select: false })
|
||||
desktop: boolean; // if the user has desktop app installed
|
||||
desktop: boolean = false; // if the user has desktop app installed
|
||||
|
||||
@Column({ select: false })
|
||||
mobile: boolean; // if the user has mobile app installed
|
||||
mobile: boolean = false; // if the user has mobile app installed
|
||||
|
||||
@Column()
|
||||
premium: boolean; // if user bought individual premium
|
||||
premium: boolean = Config.get().defaults.user.premium; // if user bought individual premium
|
||||
|
||||
@Column()
|
||||
premium_type: number; // individual premium level
|
||||
premium_type: number = Config.get().defaults.user.premium_type; // individual premium level
|
||||
|
||||
@Column()
|
||||
bot: boolean; // if user is bot
|
||||
bot: boolean = false; // if user is bot
|
||||
|
||||
@Column()
|
||||
bio: string; // short description of the user (max 190 chars -> should be configurable)
|
||||
|
||||
@Column()
|
||||
system: boolean; // shouldn't be used, the api sends this field type true, if the generated message comes from a system generated author
|
||||
system: boolean = false; // shouldn't be used, the api sends this field type true, if the generated message comes from a system generated author
|
||||
|
||||
@Column({ select: false })
|
||||
nsfw_allowed: boolean; // if the user can do age-restricted actions (NSFW channels/guilds/commands)
|
||||
nsfw_allowed: boolean = true; // if the user can do age-restricted actions (NSFW channels/guilds/commands) // TODO: depending on age
|
||||
|
||||
@Column({ select: false })
|
||||
mfa_enabled: boolean; // if multi factor authentication is enabled
|
||||
@@ -116,31 +116,31 @@ export class User extends BaseClass {
|
||||
totp_last_ticket?: string;
|
||||
|
||||
@Column()
|
||||
created_at: Date; // registration date
|
||||
created_at: Date = new Date(); // registration date
|
||||
|
||||
@Column({ nullable: true })
|
||||
premium_since: Date; // premium date
|
||||
premium_since: Date = new Date(); // premium date
|
||||
|
||||
@Column({ select: false })
|
||||
verified: boolean; // if the user is offically verified
|
||||
verified: boolean = Config.get().defaults.user.verified; // if the user is offically verified
|
||||
|
||||
@Column()
|
||||
disabled: boolean; // if the account is disabled
|
||||
disabled: boolean = false; // if the account is disabled
|
||||
|
||||
@Column()
|
||||
deleted: boolean; // if the user was deleted
|
||||
deleted: boolean = false; // if the user was deleted
|
||||
|
||||
@Column({ nullable: true, select: false })
|
||||
email?: string; // email of the user
|
||||
|
||||
@Column()
|
||||
flags: string; // UserFlags
|
||||
flags: string = "0"; // UserFlags // TODO: generate
|
||||
|
||||
@Column()
|
||||
public_flags: number;
|
||||
public_flags: number = 0;
|
||||
|
||||
@Column({ type: "bigint" })
|
||||
rights: string; // Rights
|
||||
rights: string = Config.get().register.defaultRights; // Rights
|
||||
|
||||
@OneToMany(() => Session, (session: Session) => session.user)
|
||||
sessions: Session[];
|
||||
@@ -166,17 +166,28 @@ export class User extends BaseClass {
|
||||
};
|
||||
|
||||
@Column({ type: "simple-array", select: false })
|
||||
fingerprints: string[]; // array of fingerprints -> used to prevent multiple accounts
|
||||
fingerprints: string[] = []; // array of fingerprints -> used to prevent multiple accounts
|
||||
|
||||
@Column({ type: "simple-json", select: false })
|
||||
|
||||
@OneToOne(()=> UserSettings, {
|
||||
cascade: true,
|
||||
orphanedRowAction: "delete",
|
||||
eager: false
|
||||
})
|
||||
@JoinColumn()
|
||||
settings: UserSettings;
|
||||
|
||||
// workaround to prevent fossord-unaware clients from deleting settings not used by them
|
||||
@Column({ type: "simple-json", select: false })
|
||||
extended_settings: string;
|
||||
extended_settings: string = "{}";
|
||||
|
||||
@Column({ type: "simple-json" })
|
||||
notes: { [key: string]: string }; //key is ID of user
|
||||
notes: { [key: string]: string } = {}; //key is ID of user
|
||||
|
||||
async save(): Promise<any> {
|
||||
await this.settings.save();
|
||||
return this.save();
|
||||
}
|
||||
|
||||
toPublicUser() {
|
||||
const user: any = {};
|
||||
@@ -256,40 +267,20 @@ export class User extends BaseClass {
|
||||
const language = req?.language === "en" ? "en-US" : req?.language || "en-US";
|
||||
|
||||
const user = OrmUtils.mergeDeep(new User(), {
|
||||
created_at: new Date(),
|
||||
//required:
|
||||
username: username,
|
||||
discriminator,
|
||||
id: Snowflake.generate(),
|
||||
bot: false,
|
||||
system: false,
|
||||
premium_since: new Date(),
|
||||
desktop: false,
|
||||
mobile: false,
|
||||
premium: true,
|
||||
premium_type: 2,
|
||||
bio: "",
|
||||
mfa_enabled: false,
|
||||
totp_secret: "",
|
||||
totp_backup_codes: [],
|
||||
verified: true,
|
||||
disabled: false,
|
||||
deleted: false,
|
||||
email: email,
|
||||
rights: Config.get().register.defaultRights, // TODO: grant rights correctly, as 0 actually stands for no rights at all
|
||||
nsfw_allowed: true, // TODO: depending on age
|
||||
public_flags: "0",
|
||||
flags: "0", // TODO: generate
|
||||
data: {
|
||||
hash: password,
|
||||
valid_tokens_since: new Date(),
|
||||
},
|
||||
settings: { ...defaultSettings, locale: language },
|
||||
extended_settings: {},
|
||||
fingerprints: [],
|
||||
notes: {},
|
||||
settings: { ...new UserSettings(), locale: language }
|
||||
});
|
||||
|
||||
await user.save();
|
||||
await user.settings.save();
|
||||
|
||||
setImmediate(async () => {
|
||||
if (Config.get().guild.autoJoin.enabled) {
|
||||
@@ -303,85 +294,6 @@ export class User extends BaseClass {
|
||||
}
|
||||
}
|
||||
|
||||
export const defaultSettings: UserSettings = {
|
||||
afk_timeout: 3600,
|
||||
allow_accessibility_detection: true,
|
||||
animate_emoji: true,
|
||||
animate_stickers: 0,
|
||||
contact_sync_enabled: false,
|
||||
convert_emoticons: false,
|
||||
custom_status: null,
|
||||
default_guilds_restricted: false,
|
||||
detect_platform_accounts: false,
|
||||
developer_mode: true,
|
||||
disable_games_tab: true,
|
||||
enable_tts_command: false,
|
||||
explicit_content_filter: 0,
|
||||
friend_source_flags: { all: true },
|
||||
gateway_connected: false,
|
||||
gif_auto_play: true,
|
||||
guild_folders: [],
|
||||
guild_positions: [],
|
||||
inline_attachment_media: true,
|
||||
inline_embed_media: true,
|
||||
locale: "en-US",
|
||||
message_display_compact: false,
|
||||
native_phone_integration_enabled: true,
|
||||
render_embeds: true,
|
||||
render_reactions: true,
|
||||
restricted_guilds: [],
|
||||
show_current_game: true,
|
||||
status: "online",
|
||||
stream_notifications_enabled: false,
|
||||
theme: "dark",
|
||||
timezone_offset: 0, // TODO: timezone from request
|
||||
};
|
||||
|
||||
export interface UserSettings {
|
||||
afk_timeout: number;
|
||||
allow_accessibility_detection: boolean;
|
||||
animate_emoji: boolean;
|
||||
animate_stickers: number;
|
||||
contact_sync_enabled: boolean;
|
||||
convert_emoticons: boolean;
|
||||
custom_status: {
|
||||
emoji_id?: string;
|
||||
emoji_name?: string;
|
||||
expires_at?: number;
|
||||
text?: string;
|
||||
} | null;
|
||||
default_guilds_restricted: boolean;
|
||||
detect_platform_accounts: boolean;
|
||||
developer_mode: boolean;
|
||||
disable_games_tab: boolean;
|
||||
enable_tts_command: boolean;
|
||||
explicit_content_filter: number;
|
||||
friend_source_flags: { all: boolean };
|
||||
gateway_connected: boolean;
|
||||
gif_auto_play: boolean;
|
||||
// every top guild is displayed as a "folder"
|
||||
guild_folders: {
|
||||
color: number;
|
||||
guild_ids: string[];
|
||||
id: number;
|
||||
name: string;
|
||||
}[];
|
||||
guild_positions: string[]; // guild ids ordered by position
|
||||
inline_attachment_media: boolean;
|
||||
inline_embed_media: boolean;
|
||||
locale: string; // en_US
|
||||
message_display_compact: boolean;
|
||||
native_phone_integration_enabled: boolean;
|
||||
render_embeds: boolean;
|
||||
render_reactions: boolean;
|
||||
restricted_guilds: string[];
|
||||
show_current_game: boolean;
|
||||
status: "online" | "offline" | "dnd" | "idle" | "invisible";
|
||||
stream_notifications_enabled: boolean;
|
||||
theme: "dark" | "white"; // dark
|
||||
timezone_offset: number; // e.g -60
|
||||
}
|
||||
|
||||
export const CUSTOM_USER_FLAG_OFFSET = BigInt(1) << BigInt(32);
|
||||
|
||||
export class UserFlags extends BitField {
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
import { Column, Entity, JoinColumn } from "typeorm";
|
||||
import { BaseClassWithoutId, PrimaryIdColumn } from ".";
|
||||
|
||||
@Entity("user_settings")
|
||||
export class UserSettings extends BaseClassWithoutId {
|
||||
@PrimaryIdColumn()
|
||||
id: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
afk_timeout: number = 3600;
|
||||
|
||||
@Column({ nullable: true })
|
||||
allow_accessibility_detection: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
animate_emoji: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
animate_stickers: number = 0;
|
||||
|
||||
@Column({ nullable: true })
|
||||
contact_sync_enabled: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
convert_emoticons: boolean = false;
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
custom_status: CustomStatus | null = null;
|
||||
|
||||
@Column({ nullable: true })
|
||||
default_guilds_restricted: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
detect_platform_accounts: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
developer_mode: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
disable_games_tab: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
enable_tts_command: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
explicit_content_filter: number = 0;
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
friend_source_flags: FriendSourceFlags = { all: true };
|
||||
|
||||
@Column({ nullable: true })
|
||||
gateway_connected: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
gif_auto_play: boolean = false;
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
guild_folders: GuildFolder[] = []; // every top guild is displayed as a "folder"
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
guild_positions: string[] = []; // guild ids ordered by position
|
||||
|
||||
@Column({ nullable: true })
|
||||
inline_attachment_media: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
inline_embed_media: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
locale: string = "en-US"; // en_US
|
||||
|
||||
@Column({ nullable: true })
|
||||
message_display_compact: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
native_phone_integration_enabled: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
render_embeds: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
render_reactions: boolean = true;
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
restricted_guilds: string[] = [];
|
||||
|
||||
@Column({ nullable: true })
|
||||
show_current_game: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
status: "online" | "offline" | "dnd" | "idle" | "invisible" = "online";
|
||||
|
||||
@Column({ nullable: true })
|
||||
stream_notifications_enabled: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
theme: "dark" | "white" = "dark"; // dark
|
||||
|
||||
@Column({ nullable: true })
|
||||
timezone_offset: number = 0; // e.g -60
|
||||
}
|
||||
|
||||
interface CustomStatus {
|
||||
emoji_id?: string;
|
||||
emoji_name?: string;
|
||||
expires_at?: number;
|
||||
text?: string;
|
||||
}
|
||||
|
||||
interface GuildFolder {
|
||||
color: number;
|
||||
guild_ids: string[];
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface FriendSourceFlags {
|
||||
all: boolean
|
||||
}
|
||||
@@ -30,3 +30,4 @@ export * from "./Webhook";
|
||||
export * from "./ClientRelease";
|
||||
export * from "./BackupCodes";
|
||||
export * from "./Note";
|
||||
export * from "./UserSettings";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PublicUser, User, UserSettings } from "../entities/User";
|
||||
import { PublicUser, User } from "../entities/User";
|
||||
import { Channel } from "../entities/Channel";
|
||||
import { Guild } from "../entities/Guild";
|
||||
import { Member, PublicMember, UserGuildSettings } from "../entities/Member";
|
||||
@@ -12,7 +12,7 @@ import { Interaction } from "./Interaction";
|
||||
import { ConnectedAccount } from "../entities/ConnectedAccount";
|
||||
import { Relationship, RelationshipType } from "../entities/Relationship";
|
||||
import { Presence } from "./Presence";
|
||||
import { Sticker } from "..";
|
||||
import { Sticker, UserSettings } from "..";
|
||||
import { Activity, Status } from ".";
|
||||
|
||||
export interface Event {
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class CodeCleanup31660258393551 implements MigrationInterface {
|
||||
name = 'CodeCleanup31660258393551'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP FOREIGN KEY \`FK_2ce5a55796fe4c2f77ece57a647\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP INDEX \`REL_2ce5a55796fe4c2f77ece57a64\` ON \`applications\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE \`user_settings\` (
|
||||
\`id\` varchar(255) NOT NULL,
|
||||
\`afk_timeout\` int NULL,
|
||||
\`allow_accessibility_detection\` tinyint NULL,
|
||||
\`animate_emoji\` tinyint NULL,
|
||||
\`animate_stickers\` int NULL,
|
||||
\`contact_sync_enabled\` tinyint NULL,
|
||||
\`convert_emoticons\` tinyint NULL,
|
||||
\`custom_status\` text NULL,
|
||||
\`default_guilds_restricted\` tinyint NULL,
|
||||
\`detect_platform_accounts\` tinyint NULL,
|
||||
\`developer_mode\` tinyint NULL,
|
||||
\`disable_games_tab\` tinyint NULL,
|
||||
\`enable_tts_command\` tinyint NULL,
|
||||
\`explicit_content_filter\` int NULL,
|
||||
\`friend_source_flags\` text NULL,
|
||||
\`gateway_connected\` tinyint NULL,
|
||||
\`gif_auto_play\` tinyint NULL,
|
||||
\`guild_folders\` text NULL,
|
||||
\`guild_positions\` text NULL,
|
||||
\`inline_attachment_media\` tinyint NULL,
|
||||
\`inline_embed_media\` tinyint NULL,
|
||||
\`locale\` varchar(255) NULL,
|
||||
\`message_display_compact\` tinyint NULL,
|
||||
\`native_phone_integration_enabled\` tinyint NULL,
|
||||
\`render_embeds\` tinyint NULL,
|
||||
\`render_reactions\` tinyint NULL,
|
||||
\`restricted_guilds\` text NULL,
|
||||
\`show_current_game\` tinyint NULL,
|
||||
\`status\` varchar(255) NULL,
|
||||
\`stream_notifications_enabled\` tinyint NULL,
|
||||
\`theme\` varchar(255) NULL,
|
||||
\`timezone_offset\` int NULL,
|
||||
PRIMARY KEY (\`id\`)
|
||||
) ENGINE = InnoDB
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`users\` DROP COLUMN \`settings\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`type\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`hook\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`redirect_uris\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`rpc_application_state\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`store_application_state\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`verification_state\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`interactions_endpoint_url\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`integration_public\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`integration_require_code_grant\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`discoverability_state\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`discovery_eligibility_flags\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`tags\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`install_params\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`bot_user_id\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`guilds\`
|
||||
ADD \`premium_progress_bar_enabled\` tinyint NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`rpc_origins\` text NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`primary_sku_id\` varchar(255) NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`slug\` varchar(255) NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`guild_id\` varchar(255) NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` CHANGE \`description\` \`description\` varchar(255) NOT NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`flags\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`flags\` varchar(255) NOT NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD CONSTRAINT \`FK_e5bf78cdbbe9ba91062d74c5aba\` FOREIGN KEY (\`guild_id\`) REFERENCES \`guilds\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP FOREIGN KEY \`FK_e5bf78cdbbe9ba91062d74c5aba\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`flags\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`flags\` int NOT NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` CHANGE \`description\` \`description\` varchar(255) NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`guild_id\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`slug\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`primary_sku_id\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`rpc_origins\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`guilds\` DROP COLUMN \`premium_progress_bar_enabled\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`bot_user_id\` varchar(255) NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`install_params\` text NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`tags\` text NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`discovery_eligibility_flags\` int NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`discoverability_state\` int NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`integration_require_code_grant\` tinyint NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`integration_public\` tinyint NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`interactions_endpoint_url\` varchar(255) NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`verification_state\` int NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`store_application_state\` int NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`rpc_application_state\` int NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`redirect_uris\` text NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`hook\` tinyint NOT NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`type\` text NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`users\`
|
||||
ADD \`settings\` text NOT NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE \`user_settings\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE UNIQUE INDEX \`REL_2ce5a55796fe4c2f77ece57a64\` ON \`applications\` (\`bot_user_id\`)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD CONSTRAINT \`FK_2ce5a55796fe4c2f77ece57a647\` FOREIGN KEY (\`bot_user_id\`) REFERENCES \`users\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class CodeCleanup41660260587556 implements MigrationInterface {
|
||||
name = 'CodeCleanup41660260587556'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`users\`
|
||||
ADD \`settingsId\` varchar(255) NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`users\`
|
||||
ADD UNIQUE INDEX \`IDX_76ba283779c8441fd5ff819c8c\` (\`settingsId\`)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE UNIQUE INDEX \`REL_76ba283779c8441fd5ff819c8c\` ON \`users\` (\`settingsId\`)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`users\`
|
||||
ADD CONSTRAINT \`FK_76ba283779c8441fd5ff819c8cf\` FOREIGN KEY (\`settingsId\`) REFERENCES \`user_settings\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`users\` DROP FOREIGN KEY \`FK_76ba283779c8441fd5ff819c8cf\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP INDEX \`REL_76ba283779c8441fd5ff819c8c\` ON \`users\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`users\` DROP INDEX \`IDX_76ba283779c8441fd5ff819c8c\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`users\` DROP COLUMN \`settingsId\`
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class CodeCleanup21660257815436 implements MigrationInterface {
|
||||
name = 'CodeCleanup21660257815436'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "user_settings" (
|
||||
"id" character varying NOT NULL,
|
||||
"afk_timeout" integer,
|
||||
"allow_accessibility_detection" boolean,
|
||||
"animate_emoji" boolean,
|
||||
"animate_stickers" integer,
|
||||
"contact_sync_enabled" boolean,
|
||||
"convert_emoticons" boolean,
|
||||
"custom_status" text,
|
||||
"default_guilds_restricted" boolean,
|
||||
"detect_platform_accounts" boolean,
|
||||
"developer_mode" boolean,
|
||||
"disable_games_tab" boolean,
|
||||
"enable_tts_command" boolean,
|
||||
"explicit_content_filter" integer,
|
||||
"friend_source_flags" text,
|
||||
"gateway_connected" boolean,
|
||||
"gif_auto_play" boolean,
|
||||
"guild_folders" text,
|
||||
"guild_positions" text,
|
||||
"inline_attachment_media" boolean,
|
||||
"inline_embed_media" boolean,
|
||||
"locale" character varying,
|
||||
"message_display_compact" boolean,
|
||||
"native_phone_integration_enabled" boolean,
|
||||
"render_embeds" boolean,
|
||||
"render_reactions" boolean,
|
||||
"restricted_guilds" text,
|
||||
"show_current_game" boolean,
|
||||
"status" character varying,
|
||||
"stream_notifications_enabled" boolean,
|
||||
"theme" character varying,
|
||||
"timezone_offset" integer,
|
||||
CONSTRAINT "PK_00f004f5922a0744d174530d639" PRIMARY KEY ("id")
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "guilds"
|
||||
ADD "premium_progress_bar_enabled" boolean
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "guilds" DROP COLUMN "premium_progress_bar_enabled"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "user_settings"
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class CodeCleanup31660258372154 implements MigrationInterface {
|
||||
name = 'CodeCleanup31660258372154'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "users" DROP COLUMN "settings"
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "users"
|
||||
ADD "settings" text NOT NULL
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class CodeCleanup41660260565996 implements MigrationInterface {
|
||||
name = 'CodeCleanup41660260565996'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "users"
|
||||
ADD "settingsId" character varying
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "users"
|
||||
ADD CONSTRAINT "UQ_76ba283779c8441fd5ff819c8cf" UNIQUE ("settingsId")
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "users"
|
||||
ADD CONSTRAINT "FK_76ba283779c8441fd5ff819c8cf" FOREIGN KEY ("settingsId") REFERENCES "user_settings"("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "users" DROP CONSTRAINT "FK_76ba283779c8441fd5ff819c8cf"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "users" DROP CONSTRAINT "UQ_76ba283779c8441fd5ff819c8cf"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "users" DROP COLUMN "settingsId"
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,326 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class CodeCleanup11660257576211 implements MigrationInterface {
|
||||
name = 'CodeCleanup11660257576211'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "user_settings" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"afk_timeout" integer,
|
||||
"allow_accessibility_detection" boolean,
|
||||
"animate_emoji" boolean,
|
||||
"animate_stickers" integer,
|
||||
"contact_sync_enabled" boolean,
|
||||
"convert_emoticons" boolean,
|
||||
"custom_status" text,
|
||||
"default_guilds_restricted" boolean,
|
||||
"detect_platform_accounts" boolean,
|
||||
"developer_mode" boolean,
|
||||
"disable_games_tab" boolean,
|
||||
"enable_tts_command" boolean,
|
||||
"explicit_content_filter" integer,
|
||||
"friend_source_flags" text,
|
||||
"gateway_connected" boolean,
|
||||
"gif_auto_play" boolean,
|
||||
"guild_folders" text,
|
||||
"guild_positions" text,
|
||||
"inline_attachment_media" boolean,
|
||||
"inline_embed_media" boolean,
|
||||
"locale" varchar,
|
||||
"message_display_compact" boolean,
|
||||
"native_phone_integration_enabled" boolean,
|
||||
"render_embeds" boolean,
|
||||
"render_reactions" boolean,
|
||||
"restricted_guilds" text,
|
||||
"show_current_game" boolean,
|
||||
"status" varchar,
|
||||
"stream_notifications_enabled" boolean,
|
||||
"theme" varchar,
|
||||
"timezone_offset" integer
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "temporary_guilds" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"afk_channel_id" varchar,
|
||||
"afk_timeout" integer,
|
||||
"banner" varchar,
|
||||
"default_message_notifications" integer,
|
||||
"description" varchar,
|
||||
"discovery_splash" varchar,
|
||||
"explicit_content_filter" integer,
|
||||
"features" text NOT NULL,
|
||||
"primary_category_id" integer,
|
||||
"icon" varchar,
|
||||
"large" boolean,
|
||||
"max_members" integer,
|
||||
"max_presences" integer,
|
||||
"max_video_channel_users" integer,
|
||||
"member_count" integer,
|
||||
"presence_count" integer,
|
||||
"template_id" varchar,
|
||||
"mfa_level" integer,
|
||||
"name" varchar NOT NULL,
|
||||
"owner_id" varchar,
|
||||
"preferred_locale" varchar,
|
||||
"premium_subscription_count" integer,
|
||||
"premium_tier" integer,
|
||||
"public_updates_channel_id" varchar,
|
||||
"rules_channel_id" varchar,
|
||||
"region" varchar,
|
||||
"splash" varchar,
|
||||
"system_channel_id" varchar,
|
||||
"system_channel_flags" integer,
|
||||
"unavailable" boolean,
|
||||
"verification_level" integer,
|
||||
"welcome_screen" text NOT NULL,
|
||||
"widget_channel_id" varchar,
|
||||
"widget_enabled" boolean,
|
||||
"nsfw_level" integer,
|
||||
"nsfw" boolean,
|
||||
"parent" varchar,
|
||||
"premium_progress_bar_enabled" boolean NOT NULL,
|
||||
CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "temporary_guilds"(
|
||||
"id",
|
||||
"afk_channel_id",
|
||||
"afk_timeout",
|
||||
"banner",
|
||||
"default_message_notifications",
|
||||
"description",
|
||||
"discovery_splash",
|
||||
"explicit_content_filter",
|
||||
"features",
|
||||
"primary_category_id",
|
||||
"icon",
|
||||
"large",
|
||||
"max_members",
|
||||
"max_presences",
|
||||
"max_video_channel_users",
|
||||
"member_count",
|
||||
"presence_count",
|
||||
"template_id",
|
||||
"mfa_level",
|
||||
"name",
|
||||
"owner_id",
|
||||
"preferred_locale",
|
||||
"premium_subscription_count",
|
||||
"premium_tier",
|
||||
"public_updates_channel_id",
|
||||
"rules_channel_id",
|
||||
"region",
|
||||
"splash",
|
||||
"system_channel_id",
|
||||
"system_channel_flags",
|
||||
"unavailable",
|
||||
"verification_level",
|
||||
"welcome_screen",
|
||||
"widget_channel_id",
|
||||
"widget_enabled",
|
||||
"nsfw_level",
|
||||
"nsfw",
|
||||
"parent"
|
||||
)
|
||||
SELECT "id",
|
||||
"afk_channel_id",
|
||||
"afk_timeout",
|
||||
"banner",
|
||||
"default_message_notifications",
|
||||
"description",
|
||||
"discovery_splash",
|
||||
"explicit_content_filter",
|
||||
"features",
|
||||
"primary_category_id",
|
||||
"icon",
|
||||
"large",
|
||||
"max_members",
|
||||
"max_presences",
|
||||
"max_video_channel_users",
|
||||
"member_count",
|
||||
"presence_count",
|
||||
"template_id",
|
||||
"mfa_level",
|
||||
"name",
|
||||
"owner_id",
|
||||
"preferred_locale",
|
||||
"premium_subscription_count",
|
||||
"premium_tier",
|
||||
"public_updates_channel_id",
|
||||
"rules_channel_id",
|
||||
"region",
|
||||
"splash",
|
||||
"system_channel_id",
|
||||
"system_channel_flags",
|
||||
"unavailable",
|
||||
"verification_level",
|
||||
"welcome_screen",
|
||||
"widget_channel_id",
|
||||
"widget_enabled",
|
||||
"nsfw_level",
|
||||
"nsfw",
|
||||
"parent"
|
||||
FROM "guilds"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "guilds"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "temporary_guilds"
|
||||
RENAME TO "guilds"
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "guilds"
|
||||
RENAME TO "temporary_guilds"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "guilds" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"afk_channel_id" varchar,
|
||||
"afk_timeout" integer,
|
||||
"banner" varchar,
|
||||
"default_message_notifications" integer,
|
||||
"description" varchar,
|
||||
"discovery_splash" varchar,
|
||||
"explicit_content_filter" integer,
|
||||
"features" text NOT NULL,
|
||||
"primary_category_id" integer,
|
||||
"icon" varchar,
|
||||
"large" boolean,
|
||||
"max_members" integer,
|
||||
"max_presences" integer,
|
||||
"max_video_channel_users" integer,
|
||||
"member_count" integer,
|
||||
"presence_count" integer,
|
||||
"template_id" varchar,
|
||||
"mfa_level" integer,
|
||||
"name" varchar NOT NULL,
|
||||
"owner_id" varchar,
|
||||
"preferred_locale" varchar,
|
||||
"premium_subscription_count" integer,
|
||||
"premium_tier" integer,
|
||||
"public_updates_channel_id" varchar,
|
||||
"rules_channel_id" varchar,
|
||||
"region" varchar,
|
||||
"splash" varchar,
|
||||
"system_channel_id" varchar,
|
||||
"system_channel_flags" integer,
|
||||
"unavailable" boolean,
|
||||
"verification_level" integer,
|
||||
"welcome_screen" text NOT NULL,
|
||||
"widget_channel_id" varchar,
|
||||
"widget_enabled" boolean,
|
||||
"nsfw_level" integer,
|
||||
"nsfw" boolean,
|
||||
"parent" varchar,
|
||||
CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "guilds"(
|
||||
"id",
|
||||
"afk_channel_id",
|
||||
"afk_timeout",
|
||||
"banner",
|
||||
"default_message_notifications",
|
||||
"description",
|
||||
"discovery_splash",
|
||||
"explicit_content_filter",
|
||||
"features",
|
||||
"primary_category_id",
|
||||
"icon",
|
||||
"large",
|
||||
"max_members",
|
||||
"max_presences",
|
||||
"max_video_channel_users",
|
||||
"member_count",
|
||||
"presence_count",
|
||||
"template_id",
|
||||
"mfa_level",
|
||||
"name",
|
||||
"owner_id",
|
||||
"preferred_locale",
|
||||
"premium_subscription_count",
|
||||
"premium_tier",
|
||||
"public_updates_channel_id",
|
||||
"rules_channel_id",
|
||||
"region",
|
||||
"splash",
|
||||
"system_channel_id",
|
||||
"system_channel_flags",
|
||||
"unavailable",
|
||||
"verification_level",
|
||||
"welcome_screen",
|
||||
"widget_channel_id",
|
||||
"widget_enabled",
|
||||
"nsfw_level",
|
||||
"nsfw",
|
||||
"parent"
|
||||
)
|
||||
SELECT "id",
|
||||
"afk_channel_id",
|
||||
"afk_timeout",
|
||||
"banner",
|
||||
"default_message_notifications",
|
||||
"description",
|
||||
"discovery_splash",
|
||||
"explicit_content_filter",
|
||||
"features",
|
||||
"primary_category_id",
|
||||
"icon",
|
||||
"large",
|
||||
"max_members",
|
||||
"max_presences",
|
||||
"max_video_channel_users",
|
||||
"member_count",
|
||||
"presence_count",
|
||||
"template_id",
|
||||
"mfa_level",
|
||||
"name",
|
||||
"owner_id",
|
||||
"preferred_locale",
|
||||
"premium_subscription_count",
|
||||
"premium_tier",
|
||||
"public_updates_channel_id",
|
||||
"rules_channel_id",
|
||||
"region",
|
||||
"splash",
|
||||
"system_channel_id",
|
||||
"system_channel_flags",
|
||||
"unavailable",
|
||||
"verification_level",
|
||||
"welcome_screen",
|
||||
"widget_channel_id",
|
||||
"widget_enabled",
|
||||
"nsfw_level",
|
||||
"nsfw",
|
||||
"parent"
|
||||
FROM "temporary_guilds"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "temporary_guilds"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "user_settings"
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,572 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class CodeCleanup21660257795259 implements MigrationInterface {
|
||||
name = 'CodeCleanup21660257795259'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "temporary_guilds" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"afk_channel_id" varchar,
|
||||
"afk_timeout" integer,
|
||||
"banner" varchar,
|
||||
"default_message_notifications" integer,
|
||||
"description" varchar,
|
||||
"discovery_splash" varchar,
|
||||
"explicit_content_filter" integer,
|
||||
"features" text NOT NULL,
|
||||
"primary_category_id" integer,
|
||||
"icon" varchar,
|
||||
"large" boolean,
|
||||
"max_members" integer,
|
||||
"max_presences" integer,
|
||||
"max_video_channel_users" integer,
|
||||
"member_count" integer,
|
||||
"presence_count" integer,
|
||||
"template_id" varchar,
|
||||
"mfa_level" integer,
|
||||
"name" varchar NOT NULL,
|
||||
"owner_id" varchar,
|
||||
"preferred_locale" varchar,
|
||||
"premium_subscription_count" integer,
|
||||
"premium_tier" integer,
|
||||
"public_updates_channel_id" varchar,
|
||||
"rules_channel_id" varchar,
|
||||
"region" varchar,
|
||||
"splash" varchar,
|
||||
"system_channel_id" varchar,
|
||||
"system_channel_flags" integer,
|
||||
"unavailable" boolean,
|
||||
"verification_level" integer,
|
||||
"welcome_screen" text NOT NULL,
|
||||
"widget_channel_id" varchar,
|
||||
"widget_enabled" boolean,
|
||||
"nsfw_level" integer,
|
||||
"nsfw" boolean,
|
||||
"parent" varchar,
|
||||
"premium_progress_bar_enabled" boolean NOT NULL,
|
||||
CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "temporary_guilds"(
|
||||
"id",
|
||||
"afk_channel_id",
|
||||
"afk_timeout",
|
||||
"banner",
|
||||
"default_message_notifications",
|
||||
"description",
|
||||
"discovery_splash",
|
||||
"explicit_content_filter",
|
||||
"features",
|
||||
"primary_category_id",
|
||||
"icon",
|
||||
"large",
|
||||
"max_members",
|
||||
"max_presences",
|
||||
"max_video_channel_users",
|
||||
"member_count",
|
||||
"presence_count",
|
||||
"template_id",
|
||||
"mfa_level",
|
||||
"name",
|
||||
"owner_id",
|
||||
"preferred_locale",
|
||||
"premium_subscription_count",
|
||||
"premium_tier",
|
||||
"public_updates_channel_id",
|
||||
"rules_channel_id",
|
||||
"region",
|
||||
"splash",
|
||||
"system_channel_id",
|
||||
"system_channel_flags",
|
||||
"unavailable",
|
||||
"verification_level",
|
||||
"welcome_screen",
|
||||
"widget_channel_id",
|
||||
"widget_enabled",
|
||||
"nsfw_level",
|
||||
"nsfw",
|
||||
"parent",
|
||||
"premium_progress_bar_enabled"
|
||||
)
|
||||
SELECT "id",
|
||||
"afk_channel_id",
|
||||
"afk_timeout",
|
||||
"banner",
|
||||
"default_message_notifications",
|
||||
"description",
|
||||
"discovery_splash",
|
||||
"explicit_content_filter",
|
||||
"features",
|
||||
"primary_category_id",
|
||||
"icon",
|
||||
"large",
|
||||
"max_members",
|
||||
"max_presences",
|
||||
"max_video_channel_users",
|
||||
"member_count",
|
||||
"presence_count",
|
||||
"template_id",
|
||||
"mfa_level",
|
||||
"name",
|
||||
"owner_id",
|
||||
"preferred_locale",
|
||||
"premium_subscription_count",
|
||||
"premium_tier",
|
||||
"public_updates_channel_id",
|
||||
"rules_channel_id",
|
||||
"region",
|
||||
"splash",
|
||||
"system_channel_id",
|
||||
"system_channel_flags",
|
||||
"unavailable",
|
||||
"verification_level",
|
||||
"welcome_screen",
|
||||
"widget_channel_id",
|
||||
"widget_enabled",
|
||||
"nsfw_level",
|
||||
"nsfw",
|
||||
"parent",
|
||||
"premium_progress_bar_enabled"
|
||||
FROM "guilds"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "guilds"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "temporary_guilds"
|
||||
RENAME TO "guilds"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "temporary_guilds" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"afk_channel_id" varchar,
|
||||
"afk_timeout" integer,
|
||||
"banner" varchar,
|
||||
"default_message_notifications" integer,
|
||||
"description" varchar,
|
||||
"discovery_splash" varchar,
|
||||
"explicit_content_filter" integer,
|
||||
"features" text NOT NULL,
|
||||
"primary_category_id" integer,
|
||||
"icon" varchar,
|
||||
"large" boolean,
|
||||
"max_members" integer,
|
||||
"max_presences" integer,
|
||||
"max_video_channel_users" integer,
|
||||
"member_count" integer,
|
||||
"presence_count" integer,
|
||||
"template_id" varchar,
|
||||
"mfa_level" integer,
|
||||
"name" varchar NOT NULL,
|
||||
"owner_id" varchar,
|
||||
"preferred_locale" varchar,
|
||||
"premium_subscription_count" integer,
|
||||
"premium_tier" integer,
|
||||
"public_updates_channel_id" varchar,
|
||||
"rules_channel_id" varchar,
|
||||
"region" varchar,
|
||||
"splash" varchar,
|
||||
"system_channel_id" varchar,
|
||||
"system_channel_flags" integer,
|
||||
"unavailable" boolean,
|
||||
"verification_level" integer,
|
||||
"welcome_screen" text NOT NULL,
|
||||
"widget_channel_id" varchar,
|
||||
"widget_enabled" boolean,
|
||||
"nsfw_level" integer,
|
||||
"nsfw" boolean,
|
||||
"parent" varchar,
|
||||
"premium_progress_bar_enabled" boolean,
|
||||
CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "temporary_guilds"(
|
||||
"id",
|
||||
"afk_channel_id",
|
||||
"afk_timeout",
|
||||
"banner",
|
||||
"default_message_notifications",
|
||||
"description",
|
||||
"discovery_splash",
|
||||
"explicit_content_filter",
|
||||
"features",
|
||||
"primary_category_id",
|
||||
"icon",
|
||||
"large",
|
||||
"max_members",
|
||||
"max_presences",
|
||||
"max_video_channel_users",
|
||||
"member_count",
|
||||
"presence_count",
|
||||
"template_id",
|
||||
"mfa_level",
|
||||
"name",
|
||||
"owner_id",
|
||||
"preferred_locale",
|
||||
"premium_subscription_count",
|
||||
"premium_tier",
|
||||
"public_updates_channel_id",
|
||||
"rules_channel_id",
|
||||
"region",
|
||||
"splash",
|
||||
"system_channel_id",
|
||||
"system_channel_flags",
|
||||
"unavailable",
|
||||
"verification_level",
|
||||
"welcome_screen",
|
||||
"widget_channel_id",
|
||||
"widget_enabled",
|
||||
"nsfw_level",
|
||||
"nsfw",
|
||||
"parent",
|
||||
"premium_progress_bar_enabled"
|
||||
)
|
||||
SELECT "id",
|
||||
"afk_channel_id",
|
||||
"afk_timeout",
|
||||
"banner",
|
||||
"default_message_notifications",
|
||||
"description",
|
||||
"discovery_splash",
|
||||
"explicit_content_filter",
|
||||
"features",
|
||||
"primary_category_id",
|
||||
"icon",
|
||||
"large",
|
||||
"max_members",
|
||||
"max_presences",
|
||||
"max_video_channel_users",
|
||||
"member_count",
|
||||
"presence_count",
|
||||
"template_id",
|
||||
"mfa_level",
|
||||
"name",
|
||||
"owner_id",
|
||||
"preferred_locale",
|
||||
"premium_subscription_count",
|
||||
"premium_tier",
|
||||
"public_updates_channel_id",
|
||||
"rules_channel_id",
|
||||
"region",
|
||||
"splash",
|
||||
"system_channel_id",
|
||||
"system_channel_flags",
|
||||
"unavailable",
|
||||
"verification_level",
|
||||
"welcome_screen",
|
||||
"widget_channel_id",
|
||||
"widget_enabled",
|
||||
"nsfw_level",
|
||||
"nsfw",
|
||||
"parent",
|
||||
"premium_progress_bar_enabled"
|
||||
FROM "guilds"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "guilds"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "temporary_guilds"
|
||||
RENAME TO "guilds"
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "guilds"
|
||||
RENAME TO "temporary_guilds"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "guilds" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"afk_channel_id" varchar,
|
||||
"afk_timeout" integer,
|
||||
"banner" varchar,
|
||||
"default_message_notifications" integer,
|
||||
"description" varchar,
|
||||
"discovery_splash" varchar,
|
||||
"explicit_content_filter" integer,
|
||||
"features" text NOT NULL,
|
||||
"primary_category_id" integer,
|
||||
"icon" varchar,
|
||||
"large" boolean,
|
||||
"max_members" integer,
|
||||
"max_presences" integer,
|
||||
"max_video_channel_users" integer,
|
||||
"member_count" integer,
|
||||
"presence_count" integer,
|
||||
"template_id" varchar,
|
||||
"mfa_level" integer,
|
||||
"name" varchar NOT NULL,
|
||||
"owner_id" varchar,
|
||||
"preferred_locale" varchar,
|
||||
"premium_subscription_count" integer,
|
||||
"premium_tier" integer,
|
||||
"public_updates_channel_id" varchar,
|
||||
"rules_channel_id" varchar,
|
||||
"region" varchar,
|
||||
"splash" varchar,
|
||||
"system_channel_id" varchar,
|
||||
"system_channel_flags" integer,
|
||||
"unavailable" boolean,
|
||||
"verification_level" integer,
|
||||
"welcome_screen" text NOT NULL,
|
||||
"widget_channel_id" varchar,
|
||||
"widget_enabled" boolean,
|
||||
"nsfw_level" integer,
|
||||
"nsfw" boolean,
|
||||
"parent" varchar,
|
||||
"premium_progress_bar_enabled" boolean NOT NULL,
|
||||
CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "guilds"(
|
||||
"id",
|
||||
"afk_channel_id",
|
||||
"afk_timeout",
|
||||
"banner",
|
||||
"default_message_notifications",
|
||||
"description",
|
||||
"discovery_splash",
|
||||
"explicit_content_filter",
|
||||
"features",
|
||||
"primary_category_id",
|
||||
"icon",
|
||||
"large",
|
||||
"max_members",
|
||||
"max_presences",
|
||||
"max_video_channel_users",
|
||||
"member_count",
|
||||
"presence_count",
|
||||
"template_id",
|
||||
"mfa_level",
|
||||
"name",
|
||||
"owner_id",
|
||||
"preferred_locale",
|
||||
"premium_subscription_count",
|
||||
"premium_tier",
|
||||
"public_updates_channel_id",
|
||||
"rules_channel_id",
|
||||
"region",
|
||||
"splash",
|
||||
"system_channel_id",
|
||||
"system_channel_flags",
|
||||
"unavailable",
|
||||
"verification_level",
|
||||
"welcome_screen",
|
||||
"widget_channel_id",
|
||||
"widget_enabled",
|
||||
"nsfw_level",
|
||||
"nsfw",
|
||||
"parent",
|
||||
"premium_progress_bar_enabled"
|
||||
)
|
||||
SELECT "id",
|
||||
"afk_channel_id",
|
||||
"afk_timeout",
|
||||
"banner",
|
||||
"default_message_notifications",
|
||||
"description",
|
||||
"discovery_splash",
|
||||
"explicit_content_filter",
|
||||
"features",
|
||||
"primary_category_id",
|
||||
"icon",
|
||||
"large",
|
||||
"max_members",
|
||||
"max_presences",
|
||||
"max_video_channel_users",
|
||||
"member_count",
|
||||
"presence_count",
|
||||
"template_id",
|
||||
"mfa_level",
|
||||
"name",
|
||||
"owner_id",
|
||||
"preferred_locale",
|
||||
"premium_subscription_count",
|
||||
"premium_tier",
|
||||
"public_updates_channel_id",
|
||||
"rules_channel_id",
|
||||
"region",
|
||||
"splash",
|
||||
"system_channel_id",
|
||||
"system_channel_flags",
|
||||
"unavailable",
|
||||
"verification_level",
|
||||
"welcome_screen",
|
||||
"widget_channel_id",
|
||||
"widget_enabled",
|
||||
"nsfw_level",
|
||||
"nsfw",
|
||||
"parent",
|
||||
"premium_progress_bar_enabled"
|
||||
FROM "temporary_guilds"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "temporary_guilds"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "guilds"
|
||||
RENAME TO "temporary_guilds"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "guilds" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"afk_channel_id" varchar,
|
||||
"afk_timeout" integer,
|
||||
"banner" varchar,
|
||||
"default_message_notifications" integer,
|
||||
"description" varchar,
|
||||
"discovery_splash" varchar,
|
||||
"explicit_content_filter" integer,
|
||||
"features" text NOT NULL,
|
||||
"primary_category_id" integer,
|
||||
"icon" varchar,
|
||||
"large" boolean,
|
||||
"max_members" integer,
|
||||
"max_presences" integer,
|
||||
"max_video_channel_users" integer,
|
||||
"member_count" integer,
|
||||
"presence_count" integer,
|
||||
"template_id" varchar,
|
||||
"mfa_level" integer,
|
||||
"name" varchar NOT NULL,
|
||||
"owner_id" varchar,
|
||||
"preferred_locale" varchar,
|
||||
"premium_subscription_count" integer,
|
||||
"premium_tier" integer,
|
||||
"public_updates_channel_id" varchar,
|
||||
"rules_channel_id" varchar,
|
||||
"region" varchar,
|
||||
"splash" varchar,
|
||||
"system_channel_id" varchar,
|
||||
"system_channel_flags" integer,
|
||||
"unavailable" boolean,
|
||||
"verification_level" integer,
|
||||
"welcome_screen" text NOT NULL,
|
||||
"widget_channel_id" varchar,
|
||||
"widget_enabled" boolean,
|
||||
"nsfw_level" integer,
|
||||
"nsfw" boolean,
|
||||
"parent" varchar,
|
||||
"premium_progress_bar_enabled" boolean NOT NULL,
|
||||
CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "guilds"(
|
||||
"id",
|
||||
"afk_channel_id",
|
||||
"afk_timeout",
|
||||
"banner",
|
||||
"default_message_notifications",
|
||||
"description",
|
||||
"discovery_splash",
|
||||
"explicit_content_filter",
|
||||
"features",
|
||||
"primary_category_id",
|
||||
"icon",
|
||||
"large",
|
||||
"max_members",
|
||||
"max_presences",
|
||||
"max_video_channel_users",
|
||||
"member_count",
|
||||
"presence_count",
|
||||
"template_id",
|
||||
"mfa_level",
|
||||
"name",
|
||||
"owner_id",
|
||||
"preferred_locale",
|
||||
"premium_subscription_count",
|
||||
"premium_tier",
|
||||
"public_updates_channel_id",
|
||||
"rules_channel_id",
|
||||
"region",
|
||||
"splash",
|
||||
"system_channel_id",
|
||||
"system_channel_flags",
|
||||
"unavailable",
|
||||
"verification_level",
|
||||
"welcome_screen",
|
||||
"widget_channel_id",
|
||||
"widget_enabled",
|
||||
"nsfw_level",
|
||||
"nsfw",
|
||||
"parent",
|
||||
"premium_progress_bar_enabled"
|
||||
)
|
||||
SELECT "id",
|
||||
"afk_channel_id",
|
||||
"afk_timeout",
|
||||
"banner",
|
||||
"default_message_notifications",
|
||||
"description",
|
||||
"discovery_splash",
|
||||
"explicit_content_filter",
|
||||
"features",
|
||||
"primary_category_id",
|
||||
"icon",
|
||||
"large",
|
||||
"max_members",
|
||||
"max_presences",
|
||||
"max_video_channel_users",
|
||||
"member_count",
|
||||
"presence_count",
|
||||
"template_id",
|
||||
"mfa_level",
|
||||
"name",
|
||||
"owner_id",
|
||||
"preferred_locale",
|
||||
"premium_subscription_count",
|
||||
"premium_tier",
|
||||
"public_updates_channel_id",
|
||||
"rules_channel_id",
|
||||
"region",
|
||||
"splash",
|
||||
"system_channel_id",
|
||||
"system_channel_flags",
|
||||
"unavailable",
|
||||
"verification_level",
|
||||
"welcome_screen",
|
||||
"widget_channel_id",
|
||||
"widget_enabled",
|
||||
"nsfw_level",
|
||||
"nsfw",
|
||||
"parent",
|
||||
"premium_progress_bar_enabled"
|
||||
FROM "temporary_guilds"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "temporary_guilds"
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class CodeCleanup31660258351379 implements MigrationInterface {
|
||||
name = 'CodeCleanup31660258351379'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "temporary_users" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"username" varchar NOT NULL,
|
||||
"discriminator" varchar NOT NULL,
|
||||
"avatar" varchar,
|
||||
"accent_color" integer,
|
||||
"banner" varchar,
|
||||
"phone" varchar,
|
||||
"desktop" boolean NOT NULL,
|
||||
"mobile" boolean NOT NULL,
|
||||
"premium" boolean NOT NULL,
|
||||
"premium_type" integer NOT NULL,
|
||||
"bot" boolean NOT NULL,
|
||||
"bio" varchar NOT NULL,
|
||||
"system" boolean NOT NULL,
|
||||
"nsfw_allowed" boolean NOT NULL,
|
||||
"mfa_enabled" boolean NOT NULL,
|
||||
"totp_secret" varchar,
|
||||
"totp_last_ticket" varchar,
|
||||
"created_at" datetime NOT NULL,
|
||||
"premium_since" datetime,
|
||||
"verified" boolean NOT NULL,
|
||||
"disabled" boolean NOT NULL,
|
||||
"deleted" boolean NOT NULL,
|
||||
"email" varchar,
|
||||
"flags" varchar NOT NULL,
|
||||
"public_flags" integer NOT NULL,
|
||||
"rights" bigint NOT NULL,
|
||||
"data" text NOT NULL,
|
||||
"fingerprints" text NOT NULL,
|
||||
"extended_settings" text NOT NULL,
|
||||
"notes" text NOT NULL
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "temporary_users"(
|
||||
"id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes"
|
||||
)
|
||||
SELECT "id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes"
|
||||
FROM "users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "temporary_users"
|
||||
RENAME TO "users"
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "users"
|
||||
RENAME TO "temporary_users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "users" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"username" varchar NOT NULL,
|
||||
"discriminator" varchar NOT NULL,
|
||||
"avatar" varchar,
|
||||
"accent_color" integer,
|
||||
"banner" varchar,
|
||||
"phone" varchar,
|
||||
"desktop" boolean NOT NULL,
|
||||
"mobile" boolean NOT NULL,
|
||||
"premium" boolean NOT NULL,
|
||||
"premium_type" integer NOT NULL,
|
||||
"bot" boolean NOT NULL,
|
||||
"bio" varchar NOT NULL,
|
||||
"system" boolean NOT NULL,
|
||||
"nsfw_allowed" boolean NOT NULL,
|
||||
"mfa_enabled" boolean NOT NULL,
|
||||
"totp_secret" varchar,
|
||||
"totp_last_ticket" varchar,
|
||||
"created_at" datetime NOT NULL,
|
||||
"premium_since" datetime,
|
||||
"verified" boolean NOT NULL,
|
||||
"disabled" boolean NOT NULL,
|
||||
"deleted" boolean NOT NULL,
|
||||
"email" varchar,
|
||||
"flags" varchar NOT NULL,
|
||||
"public_flags" integer NOT NULL,
|
||||
"rights" bigint NOT NULL,
|
||||
"data" text NOT NULL,
|
||||
"fingerprints" text NOT NULL,
|
||||
"settings" text NOT NULL,
|
||||
"extended_settings" text NOT NULL,
|
||||
"notes" text NOT NULL
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "users"(
|
||||
"id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes"
|
||||
)
|
||||
SELECT "id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes"
|
||||
FROM "temporary_users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "temporary_users"
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,459 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class CodeCleanup41660260539853 implements MigrationInterface {
|
||||
name = 'CodeCleanup41660260539853'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "temporary_users" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"username" varchar NOT NULL,
|
||||
"discriminator" varchar NOT NULL,
|
||||
"avatar" varchar,
|
||||
"accent_color" integer,
|
||||
"banner" varchar,
|
||||
"phone" varchar,
|
||||
"desktop" boolean NOT NULL,
|
||||
"mobile" boolean NOT NULL,
|
||||
"premium" boolean NOT NULL,
|
||||
"premium_type" integer NOT NULL,
|
||||
"bot" boolean NOT NULL,
|
||||
"bio" varchar NOT NULL,
|
||||
"system" boolean NOT NULL,
|
||||
"nsfw_allowed" boolean NOT NULL,
|
||||
"mfa_enabled" boolean NOT NULL,
|
||||
"totp_secret" varchar,
|
||||
"totp_last_ticket" varchar,
|
||||
"created_at" datetime NOT NULL,
|
||||
"premium_since" datetime,
|
||||
"verified" boolean NOT NULL,
|
||||
"disabled" boolean NOT NULL,
|
||||
"deleted" boolean NOT NULL,
|
||||
"email" varchar,
|
||||
"flags" varchar NOT NULL,
|
||||
"public_flags" integer NOT NULL,
|
||||
"rights" bigint NOT NULL,
|
||||
"data" text NOT NULL,
|
||||
"fingerprints" text NOT NULL,
|
||||
"extended_settings" text NOT NULL,
|
||||
"notes" text NOT NULL,
|
||||
"settingsId" varchar,
|
||||
CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId")
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "temporary_users"(
|
||||
"id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes"
|
||||
)
|
||||
SELECT "id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes"
|
||||
FROM "users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "temporary_users"
|
||||
RENAME TO "users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "temporary_users" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"username" varchar NOT NULL,
|
||||
"discriminator" varchar NOT NULL,
|
||||
"avatar" varchar,
|
||||
"accent_color" integer,
|
||||
"banner" varchar,
|
||||
"phone" varchar,
|
||||
"desktop" boolean NOT NULL,
|
||||
"mobile" boolean NOT NULL,
|
||||
"premium" boolean NOT NULL,
|
||||
"premium_type" integer NOT NULL,
|
||||
"bot" boolean NOT NULL,
|
||||
"bio" varchar NOT NULL,
|
||||
"system" boolean NOT NULL,
|
||||
"nsfw_allowed" boolean NOT NULL,
|
||||
"mfa_enabled" boolean NOT NULL,
|
||||
"totp_secret" varchar,
|
||||
"totp_last_ticket" varchar,
|
||||
"created_at" datetime NOT NULL,
|
||||
"premium_since" datetime,
|
||||
"verified" boolean NOT NULL,
|
||||
"disabled" boolean NOT NULL,
|
||||
"deleted" boolean NOT NULL,
|
||||
"email" varchar,
|
||||
"flags" varchar NOT NULL,
|
||||
"public_flags" integer NOT NULL,
|
||||
"rights" bigint NOT NULL,
|
||||
"data" text NOT NULL,
|
||||
"fingerprints" text NOT NULL,
|
||||
"extended_settings" text NOT NULL,
|
||||
"notes" text NOT NULL,
|
||||
"settingsId" varchar,
|
||||
CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId"),
|
||||
CONSTRAINT "FK_76ba283779c8441fd5ff819c8cf" FOREIGN KEY ("settingsId") REFERENCES "user_settings" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "temporary_users"(
|
||||
"id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes",
|
||||
"settingsId"
|
||||
)
|
||||
SELECT "id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes",
|
||||
"settingsId"
|
||||
FROM "users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "temporary_users"
|
||||
RENAME TO "users"
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "users"
|
||||
RENAME TO "temporary_users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "users" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"username" varchar NOT NULL,
|
||||
"discriminator" varchar NOT NULL,
|
||||
"avatar" varchar,
|
||||
"accent_color" integer,
|
||||
"banner" varchar,
|
||||
"phone" varchar,
|
||||
"desktop" boolean NOT NULL,
|
||||
"mobile" boolean NOT NULL,
|
||||
"premium" boolean NOT NULL,
|
||||
"premium_type" integer NOT NULL,
|
||||
"bot" boolean NOT NULL,
|
||||
"bio" varchar NOT NULL,
|
||||
"system" boolean NOT NULL,
|
||||
"nsfw_allowed" boolean NOT NULL,
|
||||
"mfa_enabled" boolean NOT NULL,
|
||||
"totp_secret" varchar,
|
||||
"totp_last_ticket" varchar,
|
||||
"created_at" datetime NOT NULL,
|
||||
"premium_since" datetime,
|
||||
"verified" boolean NOT NULL,
|
||||
"disabled" boolean NOT NULL,
|
||||
"deleted" boolean NOT NULL,
|
||||
"email" varchar,
|
||||
"flags" varchar NOT NULL,
|
||||
"public_flags" integer NOT NULL,
|
||||
"rights" bigint NOT NULL,
|
||||
"data" text NOT NULL,
|
||||
"fingerprints" text NOT NULL,
|
||||
"extended_settings" text NOT NULL,
|
||||
"notes" text NOT NULL,
|
||||
"settingsId" varchar,
|
||||
CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId")
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "users"(
|
||||
"id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes",
|
||||
"settingsId"
|
||||
)
|
||||
SELECT "id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes",
|
||||
"settingsId"
|
||||
FROM "temporary_users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "temporary_users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "users"
|
||||
RENAME TO "temporary_users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "users" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"username" varchar NOT NULL,
|
||||
"discriminator" varchar NOT NULL,
|
||||
"avatar" varchar,
|
||||
"accent_color" integer,
|
||||
"banner" varchar,
|
||||
"phone" varchar,
|
||||
"desktop" boolean NOT NULL,
|
||||
"mobile" boolean NOT NULL,
|
||||
"premium" boolean NOT NULL,
|
||||
"premium_type" integer NOT NULL,
|
||||
"bot" boolean NOT NULL,
|
||||
"bio" varchar NOT NULL,
|
||||
"system" boolean NOT NULL,
|
||||
"nsfw_allowed" boolean NOT NULL,
|
||||
"mfa_enabled" boolean NOT NULL,
|
||||
"totp_secret" varchar,
|
||||
"totp_last_ticket" varchar,
|
||||
"created_at" datetime NOT NULL,
|
||||
"premium_since" datetime,
|
||||
"verified" boolean NOT NULL,
|
||||
"disabled" boolean NOT NULL,
|
||||
"deleted" boolean NOT NULL,
|
||||
"email" varchar,
|
||||
"flags" varchar NOT NULL,
|
||||
"public_flags" integer NOT NULL,
|
||||
"rights" bigint NOT NULL,
|
||||
"data" text NOT NULL,
|
||||
"fingerprints" text NOT NULL,
|
||||
"extended_settings" text NOT NULL,
|
||||
"notes" text NOT NULL
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "users"(
|
||||
"id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes"
|
||||
)
|
||||
SELECT "id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes"
|
||||
FROM "temporary_users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "temporary_users"
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,459 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class CodeCleanup41660260672914 implements MigrationInterface {
|
||||
name = 'CodeCleanup41660260672914'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "temporary_users" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"username" varchar NOT NULL,
|
||||
"discriminator" varchar NOT NULL,
|
||||
"avatar" varchar,
|
||||
"accent_color" integer,
|
||||
"banner" varchar,
|
||||
"phone" varchar,
|
||||
"desktop" boolean NOT NULL,
|
||||
"mobile" boolean NOT NULL,
|
||||
"premium" boolean NOT NULL,
|
||||
"premium_type" integer NOT NULL,
|
||||
"bot" boolean NOT NULL,
|
||||
"bio" varchar NOT NULL,
|
||||
"system" boolean NOT NULL,
|
||||
"nsfw_allowed" boolean NOT NULL,
|
||||
"mfa_enabled" boolean NOT NULL,
|
||||
"totp_secret" varchar,
|
||||
"totp_last_ticket" varchar,
|
||||
"created_at" datetime NOT NULL,
|
||||
"premium_since" datetime,
|
||||
"verified" boolean NOT NULL,
|
||||
"disabled" boolean NOT NULL,
|
||||
"deleted" boolean NOT NULL,
|
||||
"email" varchar,
|
||||
"flags" varchar NOT NULL,
|
||||
"public_flags" integer NOT NULL,
|
||||
"rights" bigint NOT NULL,
|
||||
"data" text NOT NULL,
|
||||
"fingerprints" text NOT NULL,
|
||||
"extended_settings" text NOT NULL,
|
||||
"notes" text NOT NULL,
|
||||
"settingsId" varchar,
|
||||
CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId")
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "temporary_users"(
|
||||
"id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes"
|
||||
)
|
||||
SELECT "id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes"
|
||||
FROM "users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "temporary_users"
|
||||
RENAME TO "users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "temporary_users" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"username" varchar NOT NULL,
|
||||
"discriminator" varchar NOT NULL,
|
||||
"avatar" varchar,
|
||||
"accent_color" integer,
|
||||
"banner" varchar,
|
||||
"phone" varchar,
|
||||
"desktop" boolean NOT NULL,
|
||||
"mobile" boolean NOT NULL,
|
||||
"premium" boolean NOT NULL,
|
||||
"premium_type" integer NOT NULL,
|
||||
"bot" boolean NOT NULL,
|
||||
"bio" varchar NOT NULL,
|
||||
"system" boolean NOT NULL,
|
||||
"nsfw_allowed" boolean NOT NULL,
|
||||
"mfa_enabled" boolean NOT NULL,
|
||||
"totp_secret" varchar,
|
||||
"totp_last_ticket" varchar,
|
||||
"created_at" datetime NOT NULL,
|
||||
"premium_since" datetime,
|
||||
"verified" boolean NOT NULL,
|
||||
"disabled" boolean NOT NULL,
|
||||
"deleted" boolean NOT NULL,
|
||||
"email" varchar,
|
||||
"flags" varchar NOT NULL,
|
||||
"public_flags" integer NOT NULL,
|
||||
"rights" bigint NOT NULL,
|
||||
"data" text NOT NULL,
|
||||
"fingerprints" text NOT NULL,
|
||||
"extended_settings" text NOT NULL,
|
||||
"notes" text NOT NULL,
|
||||
"settingsId" varchar,
|
||||
CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId"),
|
||||
CONSTRAINT "FK_76ba283779c8441fd5ff819c8cf" FOREIGN KEY ("settingsId") REFERENCES "user_settings" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "temporary_users"(
|
||||
"id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes",
|
||||
"settingsId"
|
||||
)
|
||||
SELECT "id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes",
|
||||
"settingsId"
|
||||
FROM "users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "temporary_users"
|
||||
RENAME TO "users"
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "users"
|
||||
RENAME TO "temporary_users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "users" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"username" varchar NOT NULL,
|
||||
"discriminator" varchar NOT NULL,
|
||||
"avatar" varchar,
|
||||
"accent_color" integer,
|
||||
"banner" varchar,
|
||||
"phone" varchar,
|
||||
"desktop" boolean NOT NULL,
|
||||
"mobile" boolean NOT NULL,
|
||||
"premium" boolean NOT NULL,
|
||||
"premium_type" integer NOT NULL,
|
||||
"bot" boolean NOT NULL,
|
||||
"bio" varchar NOT NULL,
|
||||
"system" boolean NOT NULL,
|
||||
"nsfw_allowed" boolean NOT NULL,
|
||||
"mfa_enabled" boolean NOT NULL,
|
||||
"totp_secret" varchar,
|
||||
"totp_last_ticket" varchar,
|
||||
"created_at" datetime NOT NULL,
|
||||
"premium_since" datetime,
|
||||
"verified" boolean NOT NULL,
|
||||
"disabled" boolean NOT NULL,
|
||||
"deleted" boolean NOT NULL,
|
||||
"email" varchar,
|
||||
"flags" varchar NOT NULL,
|
||||
"public_flags" integer NOT NULL,
|
||||
"rights" bigint NOT NULL,
|
||||
"data" text NOT NULL,
|
||||
"fingerprints" text NOT NULL,
|
||||
"extended_settings" text NOT NULL,
|
||||
"notes" text NOT NULL,
|
||||
"settingsId" varchar,
|
||||
CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId")
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "users"(
|
||||
"id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes",
|
||||
"settingsId"
|
||||
)
|
||||
SELECT "id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes",
|
||||
"settingsId"
|
||||
FROM "temporary_users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "temporary_users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "users"
|
||||
RENAME TO "temporary_users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "users" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"username" varchar NOT NULL,
|
||||
"discriminator" varchar NOT NULL,
|
||||
"avatar" varchar,
|
||||
"accent_color" integer,
|
||||
"banner" varchar,
|
||||
"phone" varchar,
|
||||
"desktop" boolean NOT NULL,
|
||||
"mobile" boolean NOT NULL,
|
||||
"premium" boolean NOT NULL,
|
||||
"premium_type" integer NOT NULL,
|
||||
"bot" boolean NOT NULL,
|
||||
"bio" varchar NOT NULL,
|
||||
"system" boolean NOT NULL,
|
||||
"nsfw_allowed" boolean NOT NULL,
|
||||
"mfa_enabled" boolean NOT NULL,
|
||||
"totp_secret" varchar,
|
||||
"totp_last_ticket" varchar,
|
||||
"created_at" datetime NOT NULL,
|
||||
"premium_since" datetime,
|
||||
"verified" boolean NOT NULL,
|
||||
"disabled" boolean NOT NULL,
|
||||
"deleted" boolean NOT NULL,
|
||||
"email" varchar,
|
||||
"flags" varchar NOT NULL,
|
||||
"public_flags" integer NOT NULL,
|
||||
"rights" bigint NOT NULL,
|
||||
"data" text NOT NULL,
|
||||
"fingerprints" text NOT NULL,
|
||||
"extended_settings" text NOT NULL,
|
||||
"notes" text NOT NULL
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "users"(
|
||||
"id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes"
|
||||
)
|
||||
SELECT "id",
|
||||
"username",
|
||||
"discriminator",
|
||||
"avatar",
|
||||
"accent_color",
|
||||
"banner",
|
||||
"phone",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"premium",
|
||||
"premium_type",
|
||||
"bot",
|
||||
"bio",
|
||||
"system",
|
||||
"nsfw_allowed",
|
||||
"mfa_enabled",
|
||||
"totp_secret",
|
||||
"totp_last_ticket",
|
||||
"created_at",
|
||||
"premium_since",
|
||||
"verified",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"email",
|
||||
"flags",
|
||||
"public_flags",
|
||||
"rights",
|
||||
"data",
|
||||
"fingerprints",
|
||||
"extended_settings",
|
||||
"notes"
|
||||
FROM "temporary_users"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "temporary_users"
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user