public string[] GenerateSql(IStructureSchema structureSchema, IndexesTableNames names, IndexesTableStatuses statuses)
		{
			if(statuses.AllExists)
				return new string[0];

			var structureTableName = structureSchema.GetStructureTableName();
			var sqlTemplateNameSuffix = GetSqlTemplateNameSuffix(structureSchema.IdAccessor.IdType);
			var generators = new Func<string>[]
			{
				() => !statuses.IntegersTableExists 
					? GenerateSqlFor("CreateIntegersIndexes", sqlTemplateNameSuffix, structureTableName, names.IntegersTableName) 
					: string.Empty,
				() => !statuses.FractalsTableExists 
					? GenerateSqlFor("CreateFractalsIndexes", sqlTemplateNameSuffix, structureTableName, names.FractalsTableName) 
					: string.Empty,
				() => !statuses.BooleansTableExists 
					? GenerateSqlFor("CreateBooleansIndexes", sqlTemplateNameSuffix, structureTableName, names.BooleansTableName) 
					: string.Empty,
				() => !statuses.DatesTableExists 
					? GenerateSqlFor("CreateDatesIndexes", sqlTemplateNameSuffix, structureTableName, names.DatesTableName) 
					: string.Empty,
				() => !statuses.GuidsTableExists 
					? GenerateSqlFor("CreateGuidsIndexes", sqlTemplateNameSuffix, structureTableName, names.GuidsTableName) 
					: string.Empty,
				() => !statuses.StringsTableExists 
					? GenerateSqlFor("CreateStringsIndexes", sqlTemplateNameSuffix, structureTableName, names.StringsTableName) 
					: string.Empty,
				() => !statuses.TextsTableExists 
					? GenerateSqlFor("CreateTextsIndexes", sqlTemplateNameSuffix, structureTableName, names.TextsTableName) 
					: string.Empty
			};

			return generators.Select(generator => generator()).Where(s => !string.IsNullOrWhiteSpace(s)).ToArray();
		}
        public ModelTableStatuses(bool structureTableExists, bool uniquesTableExists, IndexesTableStatuses indexesTableStatuses)
        {
            Ensure.That(indexesTableStatuses, "indexesTableStatuses").IsNotNull();

            StructureTableExists = structureTableExists;
            UniquesTableExists = uniquesTableExists;
            IndexesTableStatuses = indexesTableStatuses;

            AllExists = StructureTableExists
                        && UniquesTableExists
                        && IndexesTableStatuses.AllExists;
        }
        public ModelTableStatuses(bool structureTableExists, bool spatialTableExists, bool uniquesTableExists, IndexesTableStatuses indexesTableStatuses)
        {
            Ensure.That(indexesTableStatuses, "indexesTableStatuses").IsNotNull();

            StructureTableExists = structureTableExists;
            SpatialTableExists   = spatialTableExists;
            UniquesTableExists   = uniquesTableExists;
            IndexesTableStatuses = indexesTableStatuses;

            AllExists = StructureTableExists &&
                        UniquesTableExists &&
                        IndexesTableStatuses.AllExists;
        }
        private void DropIndexesTables(IDbCommand cmd, IndexesTableStatuses statuses, IndexesTableNames names)
        {
            var sqlDropTableFormat = SqlStatements.GetSql("DropTable");

            if (statuses.IntegersTableExists)
            {
                cmd.CommandText = sqlDropTableFormat.Inject(names.IntegersTableName);
                cmd.ExecuteNonQuery();
            }

            if (statuses.FractalsTableExists)
            {
                cmd.CommandText = sqlDropTableFormat.Inject(names.FractalsTableName);
                cmd.ExecuteNonQuery();
            }

            if (statuses.BooleansTableExists)
            {
                cmd.CommandText = sqlDropTableFormat.Inject(names.BooleansTableName);
                cmd.ExecuteNonQuery();
            }

            if (statuses.DatesTableExists)
            {
                cmd.CommandText = sqlDropTableFormat.Inject(names.DatesTableName);
                cmd.ExecuteNonQuery();
            }

            if (statuses.GuidsTableExists)
            {
                cmd.CommandText = sqlDropTableFormat.Inject(names.GuidsTableName);
                cmd.ExecuteNonQuery();
            }

            if (statuses.StringsTableExists)
            {
                cmd.CommandText = sqlDropTableFormat.Inject(names.StringsTableName);
                cmd.ExecuteNonQuery();
            }

            if (statuses.TextsTableExists)
            {
                cmd.CommandText = sqlDropTableFormat.Inject(names.TextsTableName);
                cmd.ExecuteNonQuery();
            }
        }
        public string[] GenerateSql(IStructureSchema structureSchema, IndexesTableNames names, IndexesTableStatuses statuses)
        {
            if (statuses.AllExists)
            {
                return(new string[0]);
            }

            var structureTableName    = structureSchema.GetStructureTableName();
            var sqlTemplateNameSuffix = GetSqlTemplateNameSuffix(structureSchema.IdAccessor.IdType);
            var generators            = new Func <string>[]
            {
                () => !statuses.IntegersTableExists
                                        ? GenerateSqlFor("CreateIntegersIndexes", sqlTemplateNameSuffix, structureTableName, names.IntegersTableName)
                                        : string.Empty,
                () => !statuses.FractalsTableExists
                                        ? GenerateSqlFor("CreateFractalsIndexes", sqlTemplateNameSuffix, structureTableName, names.FractalsTableName)
                                        : string.Empty,
                () => !statuses.BooleansTableExists
                                        ? GenerateSqlFor("CreateBooleansIndexes", sqlTemplateNameSuffix, structureTableName, names.BooleansTableName)
                                        : string.Empty,
                () => !statuses.DatesTableExists
                                        ? GenerateSqlFor("CreateDatesIndexes", sqlTemplateNameSuffix, structureTableName, names.DatesTableName)
                                        : string.Empty,
                () => !statuses.GuidsTableExists
                                        ? GenerateSqlFor("CreateGuidsIndexes", sqlTemplateNameSuffix, structureTableName, names.GuidsTableName)
                                        : string.Empty,
                () => !statuses.StringsTableExists
                                        ? GenerateSqlFor("CreateStringsIndexes", sqlTemplateNameSuffix, structureTableName, names.StringsTableName)
                                        : string.Empty,
                () => !statuses.TextsTableExists
                                        ? GenerateSqlFor("CreateTextsIndexes", sqlTemplateNameSuffix, structureTableName, names.TextsTableName)
                                        : string.Empty
            };

            return(generators.Select(generator => generator()).Where(s => !string.IsNullOrWhiteSpace(s)).ToArray());
        }
        private static ModelTableStatuses CreateStatuses(
            bool structureTableExists = true,
            bool uniquesTableExists = true,
            bool integersTableExists = true,
            bool fractalsTableExists = true,
            bool datesTableExists = true,
            bool booleansTableExists = true,
            bool guidsTableExists = true,
            bool stringsTableExists = true,
            bool textsTableExists = true)
        {
            var indexesStatuses = new IndexesTableStatuses(
                integersTableExists,
                fractalsTableExists,
                datesTableExists,
                booleansTableExists,
                guidsTableExists,
                stringsTableExists,
                textsTableExists);

            return new ModelTableStatuses(structureTableExists, uniquesTableExists, indexesStatuses);
        }