/// <summary> /// Rename the specified column in the targeted table only if the column exists. /// <para>IMPORTANT: In Cassandra only the Primary key can be renamed.</para> /// </summary> /// /// <param name="self">The instance of the Cassandra Fluent Migrator helper.</param> /// <param name="table">The table where we want to rename the column.</param> /// <param name="old">The column to be renamed.</param> /// <param name="target">The new column name.</param> /// <returns>The Cassandra Fluent Migrator helper.</returns> /// /// <exception cref="NullReferenceException">Thrown when one or all the specified arguments are invalid or null.</exception> /// <exception cref="ObjectNotFoundException">Thrown when the table doesn't exists.</exception> /// <exception cref="InvalidOperationException">Thrown when the Column is not a primary key or the target column name already exists.</exception> public static async Task <ICassandraFluentMigrator> RenamePrimaryColumnAsync([NotNull] this ICassandraFluentMigrator self, [NotNull] string table, [NotNull] string old, [NotNull] string target) { Check.NotNull(self, $"The argument [cassandra fluent migrator object]"); Check.NotEmptyNotNull(table, $"The argument [table]"); Check.NotEmptyNotNull(old, $"The argument [old name]"); Check.NotEmptyNotNull(target, $"The argument [new name]"); table = table.NormalizeString(); old = old.NormalizeString(); target = target.NormalizeString(); if (!self.DoesColumnExists(table, old)) { return(self); } if (self.DoesColumnExists(table, target)) { throw new InvalidOperationException(AppErrorsMessages.TYPE_COLUMN_EXISTS.NormalizeString(target)); } if (!self.IsPrimaryKey(table, old)) { throw new InvalidOperationException(AppErrorsMessages.CAN_NOT_RENAME_NONE_PRIMARY_KEY.NormalizeString(old)); } return(await self.ExecuteRenameColumnQueryAsync(table, old, target)); }