mirror of
https://github.com/owncast/owncast.git
synced 2024-11-22 04:40:37 +03:00
2ccd3aad87
* It builds with the new user repository * fix(test): fix broken test * fix(api): fix registration endpoint that was broken after the change * fix(test): update test to reflect new user repository * fix: use interface type instead of concrete type * fix: restore commented out code
33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
package tables
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
"github.com/owncast/owncast/utils"
|
|
)
|
|
|
|
// CreateMessagesTable will create the chat messages table if needed.
|
|
func CreateMessagesTable(db *sql.DB) {
|
|
createTableSQL := `CREATE TABLE IF NOT EXISTS messages (
|
|
"id" string NOT NULL,
|
|
"user_id" TEXT,
|
|
"body" TEXT,
|
|
"eventType" TEXT,
|
|
"hidden_at" DATETIME,
|
|
"timestamp" DATETIME,
|
|
"title" TEXT,
|
|
"subtitle" TEXT,
|
|
"image" TEXT,
|
|
"link" TEXT,
|
|
PRIMARY KEY (id)
|
|
);`
|
|
utils.MustExec(createTableSQL, db)
|
|
|
|
// Create indexes
|
|
utils.MustExec(`CREATE INDEX IF NOT EXISTS user_id_hidden_at_timestamp ON messages (id, user_id, hidden_at, timestamp);`, db)
|
|
utils.MustExec(`CREATE INDEX IF NOT EXISTS idx_id ON messages (id);`, db)
|
|
utils.MustExec(`CREATE INDEX IF NOT EXISTS idx_user_id ON messages (user_id);`, db)
|
|
utils.MustExec(`CREATE INDEX IF NOT EXISTS idx_hidden_at ON messages (hidden_at);`, db)
|
|
utils.MustExec(`CREATE INDEX IF NOT EXISTS idx_timestamp ON messages (timestamp);`, db)
|
|
utils.MustExec(`CREATE INDEX IF NOT EXISTS idx_messages_hidden_at_timestamp on messages(hidden_at, timestamp);`, db)
|
|
}
|