-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#patch added
/subscribe updates
cmd, reduced api db data, added upd…
…ate announcements - added data comparison functionality - `NewCampaigns`, `NewEvents`, `WonPlanets`, `LostPlanets` and (unused) `NewMajorOrder?` - updated db schema to include `prev_data` table for war updates functionality - added new cron schedule for comparing data (for updates announcements) - added new config var to centralise img urls - updated `/subscribe` responses to now be entirely ephemeral - updated `/subscribe` to test perms via sending messages, rather than responses
- Loading branch information
Showing
25 changed files
with
1,625 additions
and
194 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,15 +1,13 @@ | ||
import 'dotenv/config'; | ||
// eslint-disable-next-line node/no-unpublished-import | ||
import {defineConfig} from 'drizzle-kit'; | ||
import type {Config} from 'drizzle-kit'; | ||
import * as dotenv from 'dotenv'; | ||
dotenv.config(); | ||
|
||
export default defineConfig({ | ||
export default { | ||
schema: './src/db/schema.ts', | ||
out: './drizzle', | ||
driver: 'pg', | ||
dbCredentials: { | ||
connectionString: process.env.DATABASE_URL as string, | ||
ssl: true, | ||
}, | ||
verbose: true, | ||
strict: true, | ||
}); | ||
} satisfies Config; |
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,6 @@ | ||
CREATE TABLE IF NOT EXISTS "prev_data" ( | ||
"time" integer PRIMARY KEY NOT NULL, | ||
"war_id" integer NOT NULL, | ||
"data" json NOT NULL, | ||
"created_at" timestamp DEFAULT now() NOT NULL | ||
); |
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,17 @@ | ||
/* | ||
Unfortunately in current drizzle-kit version we can't automatically get name for primary key. | ||
We are working on making it available! | ||
Meanwhile you can: | ||
1. Check pk name in your database, by running | ||
SELECT constraint_name FROM information_schema.table_constraints | ||
WHERE table_schema = 'public' | ||
AND table_name = 'prev_data' | ||
AND constraint_type = 'PRIMARY KEY'; | ||
2. Uncomment code below and paste pk name manually | ||
Hope to release this update as soon as possible | ||
*/ | ||
|
||
-- ALTER TABLE "prev_data" DROP CONSTRAINT "<constraint_name>";--> statement-breakpoint | ||
ALTER TABLE "prev_data" ADD PRIMARY KEY ("war_id"); |
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 @@ | ||
ALTER TABLE "prev_data" ALTER COLUMN "created_at" DROP DEFAULT; |
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,200 @@ | ||
{ | ||
"id": "54752ae7-26c6-4f6c-98f7-c66ec6f498bb", | ||
"prevId": "e0fd70b8-3890-4740-a5fe-17b7396d4969", | ||
"version": "5", | ||
"dialect": "pg", | ||
"tables": { | ||
"announcement_channels": { | ||
"name": "announcement_channels", | ||
"schema": "", | ||
"columns": { | ||
"channel_id": { | ||
"name": "channel_id", | ||
"type": "varchar", | ||
"primaryKey": true, | ||
"notNull": true | ||
}, | ||
"type": { | ||
"name": "type", | ||
"type": "varchar", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"user_id": { | ||
"name": "user_id", | ||
"type": "varchar", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"guild_id": { | ||
"name": "guild_id", | ||
"type": "varchar", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"production": { | ||
"name": "production", | ||
"type": "boolean", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"created_at": { | ||
"name": "created_at", | ||
"type": "timestamp", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"default": "now()" | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
}, | ||
"api_data": { | ||
"name": "api_data", | ||
"schema": "", | ||
"columns": { | ||
"time": { | ||
"name": "time", | ||
"type": "integer", | ||
"primaryKey": true, | ||
"notNull": true | ||
}, | ||
"war_id": { | ||
"name": "war_id", | ||
"type": "integer", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"data": { | ||
"name": "data", | ||
"type": "json", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"created_at": { | ||
"name": "created_at", | ||
"type": "timestamp", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"default": "now()" | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
}, | ||
"persistent_messages": { | ||
"name": "persistent_messages", | ||
"schema": "", | ||
"columns": { | ||
"message_id": { | ||
"name": "message_id", | ||
"type": "varchar", | ||
"primaryKey": true, | ||
"notNull": true | ||
}, | ||
"channel_id": { | ||
"name": "channel_id", | ||
"type": "varchar", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"type": { | ||
"name": "type", | ||
"type": "varchar", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"user_id": { | ||
"name": "user_id", | ||
"type": "varchar", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"guild_id": { | ||
"name": "guild_id", | ||
"type": "varchar", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"production": { | ||
"name": "production", | ||
"type": "boolean", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"deleted": { | ||
"name": "deleted", | ||
"type": "boolean", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"default": false | ||
}, | ||
"created_at": { | ||
"name": "created_at", | ||
"type": "timestamp", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"default": "now()" | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
}, | ||
"prev_data": { | ||
"name": "prev_data", | ||
"schema": "", | ||
"columns": { | ||
"time": { | ||
"name": "time", | ||
"type": "integer", | ||
"primaryKey": true, | ||
"notNull": true | ||
}, | ||
"war_id": { | ||
"name": "war_id", | ||
"type": "integer", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"data": { | ||
"name": "data", | ||
"type": "json", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"created_at": { | ||
"name": "created_at", | ||
"type": "timestamp", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"default": "now()" | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
} | ||
}, | ||
"enums": { | ||
"user_perms": { | ||
"name": "user_perms", | ||
"values": { | ||
"admin": "admin", | ||
"officer": "officer" | ||
} | ||
} | ||
}, | ||
"schemas": {}, | ||
"_meta": { | ||
"columns": {}, | ||
"schemas": {}, | ||
"tables": {} | ||
} | ||
} |
Oops, something went wrong.