Skip to content

Conversation

@DGoel1602
Copy link
Contributor

Why

Getting good data into our DB to be used for deving has been a pain forever so we needed a seeding script.

What

This introduces a seeding script and cron job that backs up the prod db (minus all sensitive information) and makes a backup sql file to insert those rows into our local db and saves it on our minio client. The seeding script can then pull this sql script and then fill the local rows with prod data that is fine for the dev team to have.

Test Plan

Idk man there's too many moving parts to take a video or screenshot just ask me lowk 🙏 Ofc feel free to lmk if the usage is too confusing I'll improve the docs and stuff

Copy link
Contributor

@DVidal1205 DVidal1205 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work, just can never fully trust Discord

Comment on lines 223 to 245
for (const role of prodRoles) {
const hash = role.name + " " + role.permissions;
if (devRoles[hash]) {
roleIdMappings[role.id] = devRoles[hash].id;
} else {
const newRole = (await discord.post(
Routes.guildRoles(DEV_KNIGHTHACKS_GUILD_ID),
{
body: {
name: role.name,
permissions: role.permissions,
color: role.color,
hoist: role.hoist,
mentionable: role.mentionable,
},
},
)) as DiscordRole;
roleIdMappings[role.id] = newRole.id;
}
}

console.log(roleIdMappings);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implement a rate limit backoff here. Discord gets pesky. for discord logic have either a set 0.10s delay per operation, or wrap in a try catch block that will check for a 429 and retry after a longer 5 second window. whichever you'd like.

Comment on lines 283 to 307
for (const event of prodEvents) {
const hash = event.name + " " + event.scheduled_start_time;
if (devEvents[hash]) {
eventIdMappings[event.id] = devEvents[hash].id;
} else {
const newEvent = (await discord.post(
Routes.guildScheduledEvents(DEV_KNIGHTHACKS_GUILD_ID),
{
body: {
name: event.name,
description: event.description,
scheduled_start_time: event.scheduled_start_time,
scheduled_end_time: event.scheduled_end_time,
privacy_level: event.privacy_level,
entity_type: event.entity_type,
entity_metadata: event.entity_metadata,
},
},
)) as DiscordGuildScheduledEvent;
eventIdMappings[event.id] = newEvent.id;
}
}

console.log(eventIdMappings);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing as role map

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants