/// <summary>
        /// Returns a name that can be used as an index identifier name.
        /// </summary>
        /// <param name="objectFactory">The introspection object factory</param>
        /// <param name="databaseServices">The database services</param>
        /// <param name="tableName">Name of the table for which we want to create a trigger</param>
        /// <param name="columns">Columns that will compose the index</param>
        /// <returns>A name that can be used as a sql identifier name</returns>
        public static string GetNewIndexName(this IPlatformDatabaseObjectFactory objectFactory, IDatabaseServices databaseServices, string tableName, IEnumerable <IPlatformTableSourceColumnInfo> columns)
        {
            string baseName = PlatformDatabaseObjectConstants.IndexPrefix +
                              tableName + "_" + columns.Select(c => c.Name.Length + c.Name).StrCat("_");

            return(objectFactory.GetNewUniqueIdentifer(databaseServices, baseName));
        }
 public MySQLPlatformDatabaseServices(IRuntimeDatabaseConfiguration databaseConfiguration) : base(databaseConfiguration)
 {
     objectFactory        = new MySQLPlatformDatabaseObjectFactory(this);
     executionService     = new ExecutionService.MySQLPlatformExecutionService(this);
     dmlService           = new DMLService.MySQLPlatformDMLService(this);
     introspectionService = new MySQLPlatformIntrospectionService(this);
     ddlService           = new DDLService.MySQLDDLService(this);
     sessionService       = new Session.MySQLPlatformSessionService(this);
 }
        /// <summary>
        /// Returns a name that can be used as a primary key identifier name.
        /// </summary>
        /// <param name="objectFactory">The introspection object factory</param>
        /// <param name="databaseServices">The database services</param>
        /// <param name="tableName">Name of the table for which we want to create a primary key</param>
        /// <returns>A name that can be used as a sql identifier name</returns>
        public static string GetNewPrimaryKeyName(this IPlatformDatabaseObjectFactory objectFactory,
                                                  IDatabaseServices databaseServices, string tableName)
        {
            string baseName = (IsSystemTable(tableName)
                ? PlatformDatabaseObjectConstants.PrimarySysConstPrefix
                : PlatformDatabaseObjectConstants.PrimaryConstPrefix) + tableName;

            return(objectFactory.GetNewUniqueIdentifer(databaseServices, baseName));
        }
        /// <summary>
        /// Returns a name that can be used as a foreign key identifier name.
        /// </summary>
        /// <param name="objectFactory">The introspection object factory</param>
        /// <param name="databaseServices">The database services</param>
        /// <param name="tableName">Name of the table for which we want to create a foreign key</param>
        /// <param name="referencedTableName">Name of the referenced table</param>
        /// <param name="columnName">Name of the column</param>
        /// <returns>A name that can be used as a sql identifier name</returns>
        public static string GetNewForeignKeyName(this IPlatformDatabaseObjectFactory objectFactory,
                                                  IDatabaseServices databaseServices, string tableName, string referencedTableName,
                                                  string columnName)
        {
            string baseName = PlatformDatabaseObjectConstants.ForeignConstPrefix +
                              tableName + "_" + referencedTableName + "_" + columnName;

            return(objectFactory.GetNewUniqueIdentifer(databaseServices, baseName));
        }
        /// <summary>
        /// Returns a name that can be used as an event trigger identifier name.
        /// </summary>
        /// <param name="objectFactory">The introspection object factory</param>
        /// <param name="databaseServices">The database services</param>
        /// <param name="tableName">Name of the table for which we want to create a trigger</param>
        /// <returns>A name that can be used as a sql identifier name</returns>
        public static string GetNewEventTriggerName(this IPlatformDatabaseObjectFactory objectFactory, IDatabaseServices databaseServices, string tableName)
        {
            string baseName = PlatformDatabaseObjectConstants.EventTriggerPrefix + "_" + tableName;

            return(objectFactory.GetNewUniqueIdentifer(databaseServices, baseName));
        }
 /// <summary>
 /// Returns an object that contains information about a table source index.
 /// </summary>
 /// <param name="objectFactory">The introspection object factory</param>
 /// <param name="tableSource">Table source that owns the index.</param>
 /// <param name="columns">Columns used in the index.</param>
 /// <param name="foreignKeys">Foreign keys that use the indexed columns</param>
 /// <param name="isUnique">True if the index is a unique index, false otherwise.</param>
 /// <param name="isPrimaryKey">True if the index is a primary key index, false otherwise.</param>
 /// <returns>Database-specific object that implements the ITableSourceIndexInfo interface</returns>
 public static IPlatformTableSourceIndexInfo CreateIndexInfo(this IPlatformDatabaseObjectFactory objectFactory, ITableSourceInfo tableSource,
                                                             IEnumerable <IPlatformTableSourceColumnInfo> columns, IEnumerable <ITableSourceForeignKeyInfo> foreignKeys, bool isUnique,
                                                             bool isPrimaryKey)
 {
     return(objectFactory.CreateIndexInfo(tableSource, null, columns, foreignKeys, isUnique, isPrimaryKey));
 }
 /// <summary>
 /// Returns an object that contains information about a table source foreign key.
 /// </summary>
 /// <param name="objectFactory">The introspection object factory</param>
 /// <param name="tableSource">Table source that owns the foreign key.</param>
 /// <param name="columnName">Name of the column.</param>
 /// <param name="referencedTableSource">Table source that owns the referenced column.</param>
 /// <param name="referencedColumnName">Name of the referenced column.</param>
 /// <param name="isCascadeDelete">True if the delete rule of the foreign key is CASCADE DELETE.</param>
 /// <returns>Database-specific object that implements the ITableSourceForeignKeyInfo interface</returns>
 public static ITableSourceForeignKeyInfo CreateForeignKeyInfo(this IPlatformDatabaseObjectFactory objectFactory,
                                                               ITableSourceInfo tableSource, string columnName, ITableSourceInfo referencedTableSource, string referencedColumnName,
                                                               bool isCascadeDelete)
 {
     return(objectFactory.CreateForeignKeyInfo(tableSource, null, columnName, referencedTableSource, referencedColumnName, isCascadeDelete));
 }