backend/config/setup/tables/guilds/members.ts
creations 0cb7ebb245
All checks were successful
Code quality checks / biome (push) Successful in 8s
add user info, add table drop for dev env, fix invite route
2025-05-04 08:59:36 -04:00

44 lines
891 B
TypeScript

import { cassandra } from "@lib/cassandra";
async function createTable() {
const client = cassandra.getClient();
await client.execute(`
CREATE TABLE IF NOT EXISTS guild_members (
guild_id TEXT,
user_id TEXT,
roles SET<TEXT>,
joined_at TIMESTAMP,
is_banned BOOLEAN,
invite_id TEXT,
PRIMARY KEY ((guild_id), user_id)
);
`);
// reverse lookup table for all guilds a user is in
await client.execute(`
CREATE TABLE IF NOT EXISTS members_by_user (
user_id TEXT,
guild_id TEXT,
roles SET<TEXT>,
joined_at TIMESTAMP,
is_banned BOOLEAN,
invite_id TEXT,
PRIMARY KEY ((user_id), guild_id)
);
`);
}
async function dropTable() {
const client = cassandra.getClient();
await client.execute(`
DROP TABLE IF EXISTS guild_members;
`);
await client.execute(`
DROP TABLE IF EXISTS members_by_user;
`);
}
export { createTable, dropTable };