MCPcopy Create free account
hub / github.com/CasparCG/client / createDatabase

Method createDatabase

src/Core/DatabaseManager.cpp:37–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37void DatabaseManager::createDatabase()
38{
39 QFile file(":/Scripts/Sql/Schema.sql");
40 if (file.open(QFile::ReadOnly))
41 {
42 QStringList queries = QString(file.readAll()).split(";");
43
44 file.close();
45
46 QSqlQuery sql;
47 foreach (QString query, queries)
48 {
49 if (query.trimmed().isEmpty())
50 continue;
51
52 if (!sql.exec(query))
53 qFatal("Failed to execute sql query: %s, Error: %s", qPrintable(sql.lastQuery()), qPrintable(sql.lastError().text()));
54 }
55
56#if defined(Q_OS_WIN)
57 if (!sql.exec("INSERT INTO Device (Name, Address, Port, Username, Password, Description, Version, Shadow, Channels, ChannelFormats, PreviewChannel, LockedChannel) VALUES('Localhost', '127.0.0.1', 5250, '', '', '', '', 'No', 0, '', 0, 0)"))
58 qFatal("Failed to execute sql query: %s, Error: %s", qPrintable(sql.lastQuery()), qPrintable(sql.lastError().text()));
59#endif
60
61 sql.prepare("UPDATE Configuration SET Value = :Value "
62 "WHERE Name = 'DatabaseVersion'");
63 sql.bindValue(":Value", DATABASE_VERSION);
64
65 if (!sql.exec())
66 qFatal("Failed to execute sql query: %s, Error: %s", qPrintable(sql.lastQuery()), qPrintable(sql.lastError().text()));
67 }
68}
69
70void DatabaseManager::upgradeDatabase()
71{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected