Update package, sync migrations

This commit is contained in:
TheArcaneBrony
2022-08-15 07:16:41 +02:00
parent fcef1f4d27
commit 551fa530cf
9 changed files with 4895 additions and 4527 deletions
BIN
View File
Binary file not shown.
+3 -3
View File
@@ -41,7 +41,7 @@
"@types/jsonwebtoken": "^8.5.8",
"@types/morgan": "^1.9.3",
"@types/multer": "^1.4.7",
"@types/node": "^18.0.6",
"@types/node": "^18.7.3",
"@types/node-os-utils": "^1.3.0",
"@types/ws": "^8.5.3",
"jest": "^28.1.3",
@@ -68,11 +68,11 @@
"canvas": "^2.9.3",
"cheerio": "^1.0.0-rc.10",
"dotenv": "^16.0.1",
"exif-be-gone": "^1.3.0",
"exif-be-gone": "^1.3.1",
"express": "^4.17.1",
"file-type": "16.5",
"form-data": "^4.0.0",
"i18next": "^21.8.14",
"i18next": "^21.9.0",
"i18next-http-middleware": "^3.1.3",
"i18next-node-fs-backend": "^2.1.3",
"image-size": "^1.0.0",
+1 -6
View File
@@ -15,7 +15,7 @@ Arguments:
exit(0);
}
let steps = 3, i = 0;
let steps = 1, i = 0;
if (argv.includes("clean")) steps++;
const verbose = argv.includes("verbose") || argv.includes("v");
@@ -34,11 +34,6 @@ if (argv.includes("clean")) {
}
}
console.log(`[${++i}/${steps}] Checking if dependencies were installed correctly...`);
//exif-be-gone v1.3.0 doesnt build js, known bug
if(!fs.existsSync(path.join(__dirname, "..", "node_modules", "exif-be-gone", "index.js")))
execIn("npm run build", path.join(__dirname, "..", "node_modules", "exif-be-gone"));
console.log(`[${++i}/${steps}] Compiling src files ...`);
let buildFlags = ''
+7 -6
View File
@@ -9,16 +9,17 @@ else
fi
[ -f ".env" ] && (
mv .env .env.tmp
source .env.tmp
mv .env .env.tmp 2>/dev/null
source .env.tmp 2>/dev/null
)
npm run build clean logerrors pretty-errors
make_migration() {
echo "Creating migrations for $2"
mkdir "src/util/migrations/$2"
mkdir "src/util/migrations/$2" 2>/dev/null
# 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 "src/migrations/$2/$FILENAME" -d ../util/src/util/Database.ts -p
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 "src/migrations/$2/$FILENAME" -d src/util/util/Database.ts -p
npm run build clean logerrors pretty-errors
THREADS=1 DATABASE="$1" DB_MIGRATE=a npm run start:bundle
}
@@ -36,5 +37,5 @@ make_migration "database.db" "sqlite"
make_migration "$FC_DB_MARIADB" "mariadb"
)
[ -f ".env.tmp" ] && mv .env.tmp .env
[ -f ".env.tmp" ] && mv .env.tmp .env 2>/dev/null
@@ -0,0 +1,127 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class syncMigrations1660540527213 implements MigrationInterface {
name = 'syncMigrations1660540527213'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE \`invites\` DROP FOREIGN KEY \`FK_15c35422032e0b22b4ada95f48f\`
`);
await queryRunner.query(`
ALTER TABLE \`users\` CHANGE \`settings\` \`settingsId\` text NOT NULL
`);
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 \`channels\`
ADD \`flags\` int NULL
`);
await queryRunner.query(`
ALTER TABLE \`channels\`
ADD \`default_thread_rate_limit_per_user\` int NULL
`);
await queryRunner.query(`
ALTER TABLE \`guilds\`
ADD \`premium_progress_bar_enabled\` tinyint NULL
`);
await queryRunner.query(`
ALTER TABLE \`users\` DROP COLUMN \`settingsId\`
`);
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
`);
await queryRunner.query(`
ALTER TABLE \`invites\`
ADD CONSTRAINT \`FK_15c35422032e0b22b4ada95f48f\` FOREIGN KEY (\`inviter_id\`) REFERENCES \`users\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION
`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE \`invites\` DROP FOREIGN KEY \`FK_15c35422032e0b22b4ada95f48f\`
`);
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\`
`);
await queryRunner.query(`
ALTER TABLE \`users\`
ADD \`settingsId\` text NOT NULL
`);
await queryRunner.query(`
ALTER TABLE \`guilds\` DROP COLUMN \`premium_progress_bar_enabled\`
`);
await queryRunner.query(`
ALTER TABLE \`channels\` DROP COLUMN \`default_thread_rate_limit_per_user\`
`);
await queryRunner.query(`
ALTER TABLE \`channels\` DROP COLUMN \`flags\`
`);
await queryRunner.query(`
DROP TABLE \`user_settings\`
`);
await queryRunner.query(`
ALTER TABLE \`users\` CHANGE \`settingsId\` \`settings\` text NOT NULL
`);
await queryRunner.query(`
ALTER TABLE \`invites\`
ADD CONSTRAINT \`FK_15c35422032e0b22b4ada95f48f\` FOREIGN KEY (\`inviter_id\`) REFERENCES \`users\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION
`);
}
}
@@ -0,0 +1,172 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class syncMigrations1660538628956 implements MigrationInterface {
name = 'syncMigrations1660538628956'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
CREATE TABLE "temporary_channels" (
"id" varchar PRIMARY KEY NOT NULL,
"created_at" datetime NOT NULL,
"name" varchar,
"icon" text,
"type" integer NOT NULL,
"last_message_id" varchar,
"guild_id" varchar,
"parent_id" varchar,
"owner_id" varchar,
"last_pin_timestamp" integer,
"default_auto_archive_duration" integer,
"position" integer,
"permission_overwrites" text,
"video_quality_mode" integer,
"bitrate" integer,
"user_limit" integer,
"nsfw" boolean,
"rate_limit_per_user" integer,
"topic" varchar,
"retention_policy_id" varchar,
"flags" integer,
"default_thread_rate_limit_per_user" integer,
CONSTRAINT "FK_3873ed438575cce703ecff4fc7b" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT "FK_3274522d14af40540b1a883fc80" FOREIGN KEY ("parent_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT "FK_c253dafe5f3a03ec00cd8fb4581" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
)
`);
await queryRunner.query(`
INSERT INTO "temporary_channels"(
"id",
"created_at",
"name",
"icon",
"type",
"last_message_id",
"guild_id",
"parent_id",
"owner_id",
"last_pin_timestamp",
"default_auto_archive_duration",
"position",
"permission_overwrites",
"video_quality_mode",
"bitrate",
"user_limit",
"nsfw",
"rate_limit_per_user",
"topic",
"retention_policy_id"
)
SELECT "id",
"created_at",
"name",
"icon",
"type",
"last_message_id",
"guild_id",
"parent_id",
"owner_id",
"last_pin_timestamp",
"default_auto_archive_duration",
"position",
"permission_overwrites",
"video_quality_mode",
"bitrate",
"user_limit",
"nsfw",
"rate_limit_per_user",
"topic",
"retention_policy_id"
FROM "channels"
`);
await queryRunner.query(`
DROP TABLE "channels"
`);
await queryRunner.query(`
ALTER TABLE "temporary_channels"
RENAME TO "channels"
`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE "channels"
RENAME TO "temporary_channels"
`);
await queryRunner.query(`
CREATE TABLE "channels" (
"id" varchar PRIMARY KEY NOT NULL,
"created_at" datetime NOT NULL,
"name" varchar,
"icon" text,
"type" integer NOT NULL,
"last_message_id" varchar,
"guild_id" varchar,
"parent_id" varchar,
"owner_id" varchar,
"last_pin_timestamp" integer,
"default_auto_archive_duration" integer,
"position" integer,
"permission_overwrites" text,
"video_quality_mode" integer,
"bitrate" integer,
"user_limit" integer,
"nsfw" boolean,
"rate_limit_per_user" integer,
"topic" varchar,
"retention_policy_id" varchar,
CONSTRAINT "FK_3873ed438575cce703ecff4fc7b" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT "FK_3274522d14af40540b1a883fc80" FOREIGN KEY ("parent_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT "FK_c253dafe5f3a03ec00cd8fb4581" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
)
`);
await queryRunner.query(`
INSERT INTO "channels"(
"id",
"created_at",
"name",
"icon",
"type",
"last_message_id",
"guild_id",
"parent_id",
"owner_id",
"last_pin_timestamp",
"default_auto_archive_duration",
"position",
"permission_overwrites",
"video_quality_mode",
"bitrate",
"user_limit",
"nsfw",
"rate_limit_per_user",
"topic",
"retention_policy_id"
)
SELECT "id",
"created_at",
"name",
"icon",
"type",
"last_message_id",
"guild_id",
"parent_id",
"owner_id",
"last_pin_timestamp",
"default_auto_archive_duration",
"position",
"permission_overwrites",
"video_quality_mode",
"bitrate",
"user_limit",
"nsfw",
"rate_limit_per_user",
"topic",
"retention_policy_id"
FROM "temporary_channels"
`);
await queryRunner.query(`
DROP TABLE "temporary_channels"
`);
}
}
@@ -1,39 +0,0 @@
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\`
`);
}
}
@@ -1,56 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class InvitersAreDeletable1660416072362 implements MigrationInterface {
name = 'InvitersAreDeletable1660416072362'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE \`invites\` DROP FOREIGN KEY \`FK_15c35422032e0b22b4ada95f48f\`
`);
await queryRunner.query(`
DROP INDEX \`IDX_76ba283779c8441fd5ff819c8c\` ON \`users\`
`);
await queryRunner.query(`
CREATE TABLE \`plugin_config\` (
\`key\` varchar(255) NOT NULL,
\`value\` text NULL,
PRIMARY KEY (\`key\`)
) ENGINE = InnoDB
`);
await queryRunner.query(`
ALTER TABLE \`channels\`
ADD \`flags\` int NULL
`);
await queryRunner.query(`
ALTER TABLE \`channels\`
ADD \`default_thread_rate_limit_per_user\` int NULL
`);
await queryRunner.query(`
ALTER TABLE \`invites\`
ADD CONSTRAINT \`FK_15c35422032e0b22b4ada95f48f\` FOREIGN KEY (\`inviter_id\`) REFERENCES \`users\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION
`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE \`invites\` DROP FOREIGN KEY \`FK_15c35422032e0b22b4ada95f48f\`
`);
await queryRunner.query(`
ALTER TABLE \`channels\` DROP COLUMN \`default_thread_rate_limit_per_user\`
`);
await queryRunner.query(`
ALTER TABLE \`channels\` DROP COLUMN \`flags\`
`);
await queryRunner.query(`
DROP TABLE \`plugin_config\`
`);
await queryRunner.query(`
CREATE UNIQUE INDEX \`IDX_76ba283779c8441fd5ff819c8c\` ON \`users\` (\`settingsId\`)
`);
await queryRunner.query(`
ALTER TABLE \`invites\`
ADD CONSTRAINT \`FK_15c35422032e0b22b4ada95f48f\` FOREIGN KEY (\`inviter_id\`) REFERENCES \`users\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION
`);
}
}
+4585 -4417
View File
File diff suppressed because it is too large Load Diff