backend/config/setup/tables/guilds/index.ts
creations 320e2cc121
All checks were successful
Code quality checks / biome (push) Successful in 7s
Add guild routes, setup tables, validators, and update environment example
Added routes for guild creation, deletion, joining, leaving, and invites
Set up Cassandra tables for guilds, invites, and members
Added validators for guild input
Updated .env.example with required config values
2025-05-03 13:56:57 -04:00

34 lines
666 B
TypeScript

import { cassandra } from "@lib/cassandra";
async function createTable() {
const client = cassandra.getClient();
// main guilds table
await client.execute(`
CREATE TABLE IF NOT EXISTS guilds (
id TEXT PRIMARY KEY,
name TEXT,
icon TEXT,
owner_id TEXT,
system_channel_id TEXT,
rules_channel_id TEXT,
anouncements_channel_id TEXT,
created_at TIMESTAMP,
updated_at TIMESTAMP
);
`);
// lookup table to enforce unique guild names per user
await client.execute(`
CREATE TABLE IF NOT EXISTS guilds_by_owner (
owner_id TEXT,
name TEXT,
guild_id TEXT,
PRIMARY KEY ((owner_id), name)
);
`);
}
export { createTable };