Пример #1
0
        /// <summary>
        /// Applies the provided base file to the database. If the db is already filled with tables, this function will return false
        /// and will not execute anything.
        /// </summary>
        /// <param name="db"></param>
        /// <param name="schemaName"></param>
        /// <param name="baseFilePath"></param>
        /// <returns></returns>
        public async static Task <bool> ApplyBaseFile(this DbContext db, string schemaName, string baseFilePath, int timeOut = 60, bool debugOutput = false)
        {
            Constants.DebugOutput = debugOutput;
            Constants.SQLTimeout  = timeOut;

            if (await MySqlUpdater.GetTableCount(db, schemaName) != 0)
            {
                if (debugOutput)
                {
                    Console.WriteLine("Schema is not empty, skipping!");
                }
                return(true);
            }


            try
            {
                string content = File.ReadAllText(baseFilePath);
                await MySqlUpdater.ExecuteQuery(db, content);

                return(true);
            }
            catch
            {
                throw;
            }
        }
Пример #2
0
 /// <summary>
 /// Checks if the schema is populated or not.
 /// </summary>
 /// <param name="db"></param>
 /// <param name="schemaName"></param>
 /// <param name="debugOutput"></param>
 /// <returns></returns>
 public async static Task <bool> IsSchemaPopulated(this DbContext db, string schemaName, bool debugOutput = false)
 {
     Constants.DebugOutput = debugOutput;
     return((await MySqlUpdater.GetTableCount(db, schemaName) == 0) ? false : true);
 }