/// <summary> /// Creates a database for the stackhash data with the specified name. /// Selects the database. /// Creates the tables in the database. /// </summary> /// <param name="sqlUtils"></param> /// <param name="databaseFolder">Folder where the database is to be stored.</param> /// <param name="databaseName">Name of the database.</param> /// <returns>True - database was created. False - already exists.</returns> public static bool CreateStackHashDatabase(SqlUtils sqlUtils, String databaseFolder, String databaseName, bool createIndexInDefaultLocation) { DbConnection connection = sqlUtils.CreateConnection(true); try { // Check if the database exists first. if (sqlUtils.DatabaseExists(databaseName, connection)) { // Select the new database as the active one. sqlUtils.SelectDatabase(databaseName, connection); // Do upgrades here. UpdateBeta95(sqlUtils, databaseName, connection); Update1_20(sqlUtils, databaseName, connection); // Deselect the database. sqlUtils.SelectDatabase("MASTER", connection); return(false); } // Create the database itself. sqlUtils.CreateDatabase(databaseFolder, databaseName, connection, createIndexInDefaultLocation); // Select the new database as the active one. sqlUtils.SelectDatabase(databaseName, connection); // Create the control table. This table contains general global information. sqlUtils.ExecuteNonQuery(s_ControlTable, connection); // Create the product control table. This table contains general control information for each product. sqlUtils.ExecuteNonQuery(s_ProductControlTable, connection); // Create the task status table. This table contains general global information about tasks being run. sqlUtils.ExecuteNonQuery(s_TaskControlTable, connection); // Create the operating system table. sqlUtils.ExecuteNonQuery(s_OperatingSystemTable, connection); // Create the locales table. sqlUtils.ExecuteNonQuery(s_LocalesTable, connection); // Create the event types table. sqlUtils.ExecuteNonQuery(s_EventTypesTable, connection); // Create the products table. sqlUtils.ExecuteNonQuery(s_ProductsTable, connection); // Create the files table. sqlUtils.ExecuteNonQuery(s_FilesTable, connection); // Create the product files table. sqlUtils.ExecuteNonQuery(s_ProductFilesTable, connection); // Create the events table. sqlUtils.ExecuteNonQuery(s_EventsTable, connection); // Create the file events table. sqlUtils.ExecuteNonQuery(s_FileEventsTable, connection); // Create the event infos table. sqlUtils.ExecuteNonQuery(s_EventInfoTable, connection); // Create the cabs table. sqlUtils.ExecuteNonQuery(s_CabsTable, connection); // Create the cab notes table. sqlUtils.ExecuteNonQuery(s_CabNotesTable, connection); // Create the users table. sqlUtils.ExecuteNonQuery(s_UsersTable, connection); // Create the source table. sqlUtils.ExecuteNonQuery(s_SourceTable, connection); // Create the event notes table. sqlUtils.ExecuteNonQuery(s_EventNotesTable, connection); // Add the Locale summary table. sqlUtils.ExecuteNonQuery(s_LocaleSummaryTable, connection); // Add the operating system summary table. sqlUtils.ExecuteNonQuery(s_OperatingSystemSummaryTable, connection); // Add the hit date summary table. sqlUtils.ExecuteNonQuery(s_HitDateSummaryTable, connection); // Additions for Beta95. UpdateBeta95(sqlUtils, databaseName, connection); // Additions for 1.20. Update1_20(sqlUtils, databaseName, connection); // Deselect the database. sqlUtils.SelectDatabase("MASTER", connection); return(true); } finally { if (connection != null) { sqlUtils.ReleaseConnection(connection); } } }
public bool DatabaseExists() { return(m_SqlUtils.DatabaseExists(m_DatabaseName, m_DbConnection)); }