-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1dea128
commit 8ff4803
Showing
11 changed files
with
617 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
# Install Data | ||
node_modules | ||
|
||
# Build | ||
dist/ | ||
|
||
# Logs | ||
logs/ | ||
|
||
#Webserver stuff | ||
images/ | ||
|
||
#Docker | ||
# Install Data | ||
node_modules | ||
|
||
# Build | ||
dist/ | ||
|
||
# Logs | ||
logs/ | ||
|
||
#Webserver stuff | ||
images/ | ||
|
||
#Docker | ||
docker_env/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const mysqldump = require('mysqldump') | ||
|
||
//@ts-check | ||
|
||
const exec = require('child_process').exec; | ||
|
||
const fs = require('fs') | ||
const JSON5 = require('json5') | ||
const path = require('path') | ||
|
||
const content = fs.readFileSync(path.join(__dirname, "../config/config.json5"), {encoding: "utf-8"}) | ||
const config = JSON5.parse(content) | ||
|
||
let opts = {} | ||
|
||
async function main() { | ||
|
||
if (config.database.type == "mysql" || config.database.type == "mariadb"){ | ||
opts = { | ||
host: process.env.DB_HOST || config.database.host, | ||
database: process.env.DB_NAME|| config.database.name, | ||
user: process.env.DB_USER ||config.database.user, | ||
password: process.env.DB_PASS || config.database.pass, | ||
} | ||
|
||
const fileName = "sqlBackups/" + new Date(Date.now()).getTime() + ".sql" | ||
|
||
await mysqldump({connection: opts, dumpToFile: fileName, compressFile: false}) | ||
|
||
exec(`cat ${fileName} | curl -F 'sprunge=<-' http://sprunge.us`, function (error, stdout, stderr) { | ||
console.log('stdout: ' + stdout); | ||
console.log('stderr: ' + stderr); | ||
if (error !== null) { | ||
console.log('exec error: ' + error); | ||
} | ||
}) | ||
} | ||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
npm run typeorm migration:generate -- -n Snowflake19 | ||
|
||
npm run typeorm schema:log | ||
|
||
npm run typeorm query "SELECT * from advanced_builders" | ||
|
||
npm run typeorm query "DESCRIBE advanced_builders" | ||
|
||
apk --no-cache add curl | ||
|
||
cd src | ||
node scripts/backup.cjs | ||
|
||
cd migrations | ||
npm run typeorm query "source ./sqlScripts/Snowflake191658519013499_UP.sql" | ||
|
||
cat *-Snowflake19*.ts | curl -F 'sprunge=<-' http://sprunge.us | ||
npm run typeorm query "DESCRIBE advanced_builders" | ||
|
||
echo done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//@ts-check | ||
const _ = require('lodash'); | ||
|
||
const ts = require("typescript") | ||
|
||
const fs = require("fs") | ||
|
||
function exitLog(text) { | ||
console.log(text) | ||
process.exit(-1) | ||
} | ||
|
||
const file = process.argv[2] | ||
|
||
if (!file) exitLog("I need a file dum dum") | ||
|
||
if (!(_.endsWith(file, "cts") || _.endsWith(file, "ts"))) exitLog("How about you give me a typescript file!") | ||
|
||
const sourceCode = fs.readFileSync(file, 'utf-8') | ||
|
||
if (!sourceCode) exitLog("invalid source code") | ||
|
||
let tsSourceFile = ts.createSourceFile( | ||
__filename, | ||
sourceCode, | ||
ts.ScriptTarget.Latest | ||
); | ||
|
||
let filename = "err" | ||
|
||
try { | ||
//@ts-ignore | ||
if (!(['1', '2'].every(key => Object.keys(tsSourceFile.statements[1].members).includes(key)))) return exitLog("Tree invalid") | ||
//@ts-ignore | ||
console.log(`Found ${tsSourceFile.statements[1].name.escapedText}`) | ||
|
||
//@ts-ignore | ||
filename = tsSourceFile.statements[1].name.escapedText | ||
|
||
} catch { | ||
exitLog("Tree invalid") | ||
} | ||
|
||
function getStatements(member) { | ||
let finalSql = "" | ||
const keys = Object.keys(member.body.statements).slice(0, -4) | ||
|
||
for (const key of keys) { | ||
const currNode = member.body.statements[key].expression.expression.arguments['0'].rawText | ||
finalSql += currNode + ";\n" | ||
} | ||
|
||
return finalSql | ||
|
||
} | ||
//@ts-ignore | ||
const up = getStatements(tsSourceFile.statements[1].members['1']) | ||
//@ts-ignore | ||
const down = getStatements(tsSourceFile.statements[1].members['2']) | ||
|
||
fs.writeFileSync(`sqlScripts/${filename}_UP.sql`, up) | ||
|
||
fs.writeFileSync(`sqlScripts/${filename}_DOWN.sql`, down) | ||
|
||
console.log(`Wrote sqlScripts/${filename}_UP.sql and sqlScripts/${filename}_DOWN.sql!`) | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Backup dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
ALTER TABLE "moderation_menus" RENAME TO "temporary_moderation_menus"; | ||
CREATE TABLE "moderation_menus" ("member" varchar(18) PRIMARY KEY NOT NULL, "message" varchar(18) NOT NULL, "message_text" varchar(2000) NOT NULL, "punishments" text NOT NULL, "offenses" integer NOT NULL, "current_word" varchar NOT NULL); | ||
INSERT INTO "moderation_menus"("member", "message", "message_text", "punishments", "offenses", "current_word") SELECT "member", "message", "message_text", "punishments", "offenses", "current_word" FROM "temporary_moderation_menus"; | ||
DROP TABLE "temporary_moderation_menus"; | ||
ALTER TABLE "action_logs" RENAME TO "temporary_action_logs"; | ||
CREATE TABLE "action_logs" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "action" varchar NOT NULL, "member" varchar(18) NOT NULL, "executor" varchar(18) NOT NULL, "reason" varchar(1024) NOT NULL, "reason_image" varchar, "length" integer, "channel" varchar(18) NOT NULL, "message" varchar(18) NOT NULL, "notification" varchar(18), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "deleted_at" datetime, "deleter" varchar(18), "delete_reason" varchar(1024), "punishment_id" integer, CONSTRAINT "REL_1b2ce2a6f60a2cea07c0c73e9a" UNIQUE ("punishment_id"), CONSTRAINT "FK_1b2ce2a6f60a2cea07c0c73e9a0" FOREIGN KEY ("punishment_id") REFERENCES "timed_punishments" ("id") ON DELETE SET NULL ON UPDATE NO ACTION); | ||
INSERT INTO "action_logs"("id", "action", "member", "executor", "reason", "reason_image", "length", "channel", "message", "notification", "created_at", "deleted_at", "deleter", "delete_reason", "punishment_id") SELECT "id", "action", "member", "executor", "reason", "reason_image", "length", "channel", "message", "notification", "created_at", "deleted_at", "deleter", "delete_reason", "punishment_id" FROM "temporary_action_logs"; | ||
DROP TABLE "temporary_action_logs"; | ||
ALTER TABLE "reminders" RENAME TO "temporary_reminders"; | ||
CREATE TABLE "reminders" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "channel" varchar(18) NOT NULL, "message" varchar(1024) NOT NULL, "interval" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "next_fire_date" integer NOT NULL); | ||
INSERT INTO "reminders"("id", "channel", "message", "interval", "created_at", "next_fire_date") SELECT "id", "channel", "message", "interval", "created_at", "next_fire_date" FROM "temporary_reminders"; | ||
DROP TABLE "temporary_reminders"; | ||
ALTER TABLE "timed_punishments" RENAME TO "temporary_timed_punishments"; | ||
CREATE TABLE "timed_punishments" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "member" varchar(18) NOT NULL, "type" varchar NOT NULL, "length" integer NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now'))); | ||
INSERT INTO "timed_punishments"("id", "member", "type", "length", "created_at") SELECT "id", "member", "type", "length", "created_at" FROM "temporary_timed_punishments"; | ||
DROP TABLE "temporary_timed_punishments"; | ||
ALTER TABLE "teampoint_users" RENAME TO "temporary_teampoint_users"; | ||
CREATE TABLE "teampoint_users" ("userId" varchar(18) PRIMARY KEY NOT NULL, "commandUsagesToday" integer NOT NULL DEFAULT (0)); | ||
INSERT INTO "teampoint_users"("userId", "commandUsagesToday") SELECT "userId", "commandUsagesToday" FROM "temporary_teampoint_users"; | ||
DROP TABLE "temporary_teampoint_users"; | ||
ALTER TABLE "advanced_builders" RENAME TO "temporary_advanced_builders"; | ||
CREATE TABLE "advanced_builders" ("builder" varchar(18) PRIMARY KEY NOT NULL, "given_at" datetime NOT NULL DEFAULT (datetime('now')), "role_name" varchar NOT NULL DEFAULT ('ADVANCED_BUILDER')); | ||
INSERT INTO "advanced_builders"("builder", "given_at", "role_name") SELECT "builder", "given_at", "role_name" FROM "temporary_advanced_builders"; | ||
DROP TABLE "temporary_advanced_builders"; | ||
ALTER TABLE "suspicious_users" RENAME TO "temporary_suspicious_users"; | ||
CREATE TABLE "suspicious_users" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "userId" varchar(18) NOT NULL, "submitterId" varchar(18) NOT NULL, "messageId" varchar(18) NOT NULL, "denied" boolean NOT NULL DEFAULT (0), "approved" boolean NOT NULL DEFAULT (0), "moderatorId" varchar(18), "reason" text, "evidence" text NOT NULL, "deletedAt" datetime, "threadId" varchar(18)); | ||
INSERT INTO "suspicious_users"("id", "userId", "submitterId", "messageId", "denied", "approved", "moderatorId", "reason", "evidence", "deletedAt", "threadId") SELECT "id", "userId", "submitterId", "messageId", "denied", "approved", "moderatorId", "reason", "evidence", "deletedAt", "threadId" FROM "temporary_suspicious_users"; | ||
DROP TABLE "temporary_suspicious_users"; | ||
ALTER TABLE "teampoint_permissions" RENAME TO "temporary_teampoint_permissions"; | ||
CREATE TABLE "teampoint_permissions" ("roleId" varchar(18) PRIMARY KEY NOT NULL, "maxPoints" float NOT NULL DEFAULT (0), "minPoints" float NOT NULL DEFAULT (0), "maxUsagesPerDay" integer NOT NULL DEFAULT (10)); | ||
INSERT INTO "teampoint_permissions"("roleId", "maxPoints", "minPoints", "maxUsagesPerDay") SELECT "roleId", "maxPoints", "minPoints", "maxUsagesPerDay" FROM "temporary_teampoint_permissions"; | ||
DROP TABLE "temporary_teampoint_permissions"; | ||
ALTER TABLE "banned_words" RENAME TO "temporary_banned_words"; | ||
CREATE TABLE "banned_words" ("word" varchar(18) PRIMARY KEY NOT NULL, "punishment_type" varchar, "reason" varchar(1024), "duration" integer, "exception" boolean NOT NULL DEFAULT (0)); | ||
INSERT INTO "banned_words"("word", "punishment_type", "reason", "duration", "exception") SELECT "word", "punishment_type", "reason", "duration", "exception" FROM "temporary_banned_words"; | ||
DROP TABLE "temporary_banned_words"; | ||
ALTER TABLE "moderation_notes" RENAME TO "temporary_moderation_notes"; | ||
CREATE TABLE "moderation_notes" ("member" varchar(18) PRIMARY KEY NOT NULL, "body" varchar(1024) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "updated_at" datetime NOT NULL DEFAULT (datetime('now')), "updaters" text NOT NULL); | ||
INSERT INTO "moderation_notes"("member", "body", "created_at", "updated_at", "updaters") SELECT "member", "body", "created_at", "updated_at", "updaters" FROM "temporary_moderation_notes"; | ||
DROP TABLE "temporary_moderation_notes"; | ||
ALTER TABLE "tasks" RENAME TO "temporary_tasks"; | ||
CREATE TABLE "tasks" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar NOT NULL, "description" varchar(2048) NOT NULL, "creator" varchar(18) NOT NULL, "assignees" text NOT NULL, "status" varchar); | ||
INSERT INTO "tasks"("id", "title", "description", "creator", "assignees", "status") SELECT "id", "title", "description", "creator", "assignees", "status" FROM "temporary_tasks"; | ||
DROP TABLE "temporary_tasks"; | ||
ALTER TABLE "suggestions" RENAME TO "temporary_suggestions"; | ||
CREATE TABLE "suggestions" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "number" integer, "extends" integer, "author" varchar(18) NOT NULL, "anonymous" boolean NOT NULL, "title" varchar NOT NULL, "body" varchar(2048) NOT NULL, "teams" varchar, "status" varchar, "status_updater" varchar(18), "status_reason" varchar(1024), "message" varchar(18) NOT NULL, "thread" varchar(18), "staff" boolean NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "deleted_at" datetime, "deleter" varchar(18)); | ||
INSERT INTO "suggestions"("id", "number", "extends", "author", "anonymous", "title", "body", "teams", "status", "status_updater", "status_reason", "message", "thread", "staff", "created_at", "deleted_at", "deleter") SELECT "id", "number", "extends", "author", "anonymous", "title", "body", "teams", "status", "status_updater", "status_reason", "message", "thread", "staff", "created_at", "deleted_at", "deleter" FROM "temporary_suggestions"; | ||
DROP TABLE "temporary_suggestions"; | ||
ALTER TABLE "blunder_tracker" RENAME TO "temporary_blunder_tracker"; | ||
CREATE TABLE "blunder_tracker" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "description" varchar NOT NULL, "role" varchar(18), "last_blunder" date, "message" varchar(18) NOT NULL, "channel" varchar(18) NOT NULL); | ||
INSERT INTO "blunder_tracker"("id", "description", "role", "last_blunder", "message", "channel") SELECT "id", "description", "role", "last_blunder", "message", "channel" FROM "temporary_blunder_tracker"; | ||
DROP TABLE "temporary_blunder_tracker"; |
Oops, something went wrong.