| 199 | }; |
| 200 | |
| 201 | const createIndexes = async (client) => { |
| 202 | logger.info('📈 Creating indexes...'); |
| 203 | |
| 204 | const indexes = [ |
| 205 | 'CREATE INDEX IF NOT EXISTS idx_user_levels_guild ON user_levels(guild_id)', |
| 206 | 'CREATE INDEX IF NOT EXISTS idx_user_economy_guild ON user_economy(guild_id)', |
| 207 | 'CREATE INDEX IF NOT EXISTS idx_tickets_guild ON tickets(guild_id)', |
| 208 | 'CREATE INDEX IF NOT EXISTS idx_giveaways_guild ON giveaways(guild_id)', |
| 209 | 'CREATE INDEX IF NOT EXISTS idx_audit_logs_guild ON audit_logs(guild_id)', |
| 210 | ]; |
| 211 | |
| 212 | for (const index of indexes) { |
| 213 | try { |
| 214 | await client.query(index); |
| 215 | } catch (error) { |
| 216 | logger.error(`❌ Error creating index: ${error.message}`); |
| 217 | throw error; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | logger.info('✅ All indexes created successfully'); |
| 222 | }; |
| 223 | |
| 224 | const createTriggers = async (client) => { |
| 225 | logger.info('⏰ Setting up automatic timestamps...'); |