backend/config/setup/tables/guilds/channels.ts
creations 93ed37b3e9
All checks were successful
Code quality checks / biome (push) Successful in 10s
- better reading of avalable routes
- add name validation for channel names and catagories
- add create, delete, move for channels
2025-05-11 10:51:48 -04:00

37 lines
888 B
TypeScript

import { cassandra } from "@lib/cassandra";
async function createTable() {
const client = cassandra.getClient();
await client.execute(`
CREATE TABLE IF NOT EXISTS channels (
id TEXT PRIMARY KEY,
guild_id TEXT,
name TEXT,
type TEXT,
topic TEXT,
position INT,
category_id TEXT,
created_at TIMESTAMP,
updated_at TIMESTAMP
);
`);
await client.execute(`
CREATE INDEX IF NOT EXISTS channels_guild_id_idx ON channels (guild_id);
`);
await client.execute(`
CREATE INDEX IF NOT EXISTS channels_category_id_idx ON channels (category_id);
`);
}
async function dropTable() {
const client = cassandra.getClient();
await client.execute("DROP TABLE IF EXISTS channels;");
await client.execute("DROP INDEX IF EXISTS channels_guild_id_idx;");
await client.execute("DROP INDEX IF EXISTS channels_category_id_idx;");
}
export { createTable, dropTable };