Ejemplo n.º 1
0
        public static void DatabaseUserInitialization()
        {
            // Make sure a database exists.
            int databaseExists = SQLiteData.InitDatabase(Settings.ConnectionString, Settings.DatabasePath);

            Settings.DatabaseVersion = VersionDataAccess.GetCurrentDatabaseVersion();
            DeleteTableMigration();             // Checks if the loaded database version can support the Delete functions
            if (Settings.DatabaseVersion < 3 && databaseExists == 1)
            {
                // Execute a migration to make sure the renaming of the tables Services to ServiceTemplates and ServiceInstances to Services is Executed.
                // One this is done, the database version will be upgraded to 3.
                ServiceTemplateMigration();
            }

            if (Settings.DatabaseVersion >= 3 && Settings.DatabaseVersion < 5)
            {
                // You need ServiceClasses table end the Time Eventstable pus their data initialization.
                SQLiteData.CreateTable("SQL\\UpdateToVersion5.sql");
                Settings.DatabaseVersion = VersionDataAccess.GetCurrentDatabaseVersion();
            }

            if (Settings.UseDemoData && databaseExists == 0)
            {
                DemoDataSetup();
            }
        }