feat: Add a large collection of emoji and other frontend assets, including a sound file, and a backend package.json.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.join(__dirname, '../.env') });
|
||||
const db = require('../db');
|
||||
|
||||
async function initDb() {
|
||||
@@ -7,18 +8,33 @@ async function initDb() {
|
||||
const schemaPath = path.join(__dirname, '../schema.sql');
|
||||
const schemaSql = fs.readFileSync(schemaPath, 'utf8');
|
||||
|
||||
console.log('Dropping existing tables...');
|
||||
await db.query(`
|
||||
DROP TABLE IF EXISTS invites CASCADE;
|
||||
DROP TABLE IF EXISTS messages CASCADE;
|
||||
DROP TABLE IF EXISTS channel_keys CASCADE;
|
||||
DROP TABLE IF EXISTS roles CASCADE;
|
||||
DROP TABLE IF EXISTS channels CASCADE;
|
||||
DROP TABLE IF EXISTS users CASCADE;
|
||||
`);
|
||||
|
||||
console.log('Applying schema...');
|
||||
await db.query(schemaSql);
|
||||
|
||||
// Seed Channels
|
||||
const channels = ['general', 'random'];
|
||||
for (const name of channels) {
|
||||
await db.query(
|
||||
`INSERT INTO channels (name) VALUES ($1) ON CONFLICT (name) DO NOTHING`,
|
||||
[name]
|
||||
);
|
||||
}
|
||||
console.log('Channels seeded.');
|
||||
console.log('Schema applied successfully.');
|
||||
|
||||
console.log('Seeding Default Roles...');
|
||||
// 1. @everyone (Limited)
|
||||
await db.query(`
|
||||
INSERT INTO roles (name, color, position, is_hoist, permissions)
|
||||
VALUES ('@everyone', '#99aab5', 0, false, '{"manage_channels": false, "manage_roles": false, "create_invite": false, "embed_links": true, "attach_files": true}')
|
||||
`);
|
||||
|
||||
// 2. Owner (All Permissions)
|
||||
await db.query(`
|
||||
INSERT INTO roles (name, color, position, is_hoist, permissions)
|
||||
VALUES ('Owner', '#ED4245', 100, true, '{"manage_channels": true, "manage_roles": true, "create_invite": true, "embed_links": true, "attach_files": true}')
|
||||
`);
|
||||
|
||||
console.log('Schema applied successfully.');
|
||||
process.exit(0);
|
||||
|
||||
17
Backend/scripts/migrate_voice.js
Normal file
17
Backend/scripts/migrate_voice.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.join(__dirname, '../.env') });
|
||||
const db = require('../db');
|
||||
|
||||
async function migrate() {
|
||||
try {
|
||||
console.log('Running migration...');
|
||||
await db.query("ALTER TABLE channels ADD COLUMN IF NOT EXISTS type TEXT DEFAULT 'text' CHECK (type IN ('text', 'voice'))");
|
||||
console.log('Migration complete: Added type column to channels.');
|
||||
process.exit(0);
|
||||
} catch (err) {
|
||||
console.error('Migration failed:', err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
migrate();
|
||||
Reference in New Issue
Block a user