bob-el-bot / BobTheBot

The discord bot for 🎲 RNG, 🖊️ quoting, 📜 fonts, 🔒 encryption, and ✨ more!
https://bobthebot.net
Other
2 stars 0 forks source link

Ensure DB Migration is Up to Date in Runtime #77

Closed Quantam-Studios closed 9 months ago

Quantam-Studios commented 9 months ago

Either in main.cs or databases/Databases.cs a check should be done to ensure that the DB context is up to date with the most recent migrations.

Quantam-Studios commented 9 months ago

This code attempted to accomplish this, but it often throws an exception.

From main.cs

// Ensure Database is up to date
await DB.Database.EnsureCreatedAsync();
if (DB.Database.GetAppliedMigrations() != DB.Database.GetPendingMigrations())
{
await DB.Database.MigrateAsync();
}