mirror of
https://github.com/owncast/owncast.git
synced 2025-11-02 03:54:54 +08:00
Messages table fixes to improve query performance (#2026)
* Move to yaml sqlc config * Add util for ungraceful sql execs * Fix messages schema + add indexes * Add migration to drop+recreate messages table * Create index only if does not exist * Fix typo * Unexport function
This commit is contained in:
@ -29,6 +29,8 @@ func migrateDatabaseSchema(db *sql.DB, from, to int) error {
|
||||
migrateToSchema4(db)
|
||||
case 4:
|
||||
migrateToSchema5(db)
|
||||
case 5:
|
||||
migrateToSchema6(db)
|
||||
default:
|
||||
log.Fatalln("missing database migration step")
|
||||
}
|
||||
@ -42,6 +44,16 @@ func migrateDatabaseSchema(db *sql.DB, from, to int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func migrateToSchema6(db *sql.DB) {
|
||||
// Fix chat messages table schema. Since chat is ephemeral we can drop
|
||||
// the table and recreate it.
|
||||
// Drop the old messages table
|
||||
mustExec(`DROP TABLE messages`, db)
|
||||
|
||||
// Recreate it
|
||||
CreateMessagesTable(db)
|
||||
}
|
||||
|
||||
// nolint:cyclop
|
||||
func migrateToSchema5(db *sql.DB) {
|
||||
// Create the access tokens table.
|
||||
|
||||
Reference in New Issue
Block a user