Exemplo n.º 1
0
        /// <summary>
        /// Build and execute the Drop column query statement.
        /// </summary>
        ///
        /// <param name="self">The Cassandra Fluent Migrator.</param>
        /// <param name="table">The Cassandra table name.</param>
        /// <param name="column">The Column to be deleted.</param>
        /// <returns>Cassandra Fluent Migrator.</returns>
        ///
        /// <exception cref="NullReferenceException">Thrown when the arguments are empty or null.</exception>
        internal static async Task <ICassandraFluentMigrator> ExecuteDropColumnQueryAsync([NotNull] this ICassandraFluentMigrator self, [NotNull] string table, [NotNull] string column)
        {
            Check.NotNull(self, $"The argument [cassandra fluent migrator object]");
            Check.NotEmptyNotNull(table, $"The argument [{nameof(table)}]");
            Check.NotEmptyNotNull(column, $"The argument [{nameof(column)}]");

            var query = TableCqlStatements.TABLE_DROP_COLUMN_STATEMENT.NormalizeString(table, column);

            return(await self.ExecuteStatementAsync(query, AppErrorsMessages.COLUMN_NOT_FOUND.NormalizeString(column, table)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Build and execute the Add column query statement.
        /// </summary>
        ///
        /// <param name="self">The Cassandra Fluent Migrator.</param>
        /// <param name="table">The Cassandra table name.</param>
        /// <param name="column">The column that we want to add.</param>
        /// <param name="type">The type of the columns.</param>
        /// <returns>Cassandra Fluent Migrator.</returns>
        ///
        /// <exception cref="NullReferenceException">Thrown when the arguments are empty or null.</exception>
        internal static async Task <ICassandraFluentMigrator> ExecuteCreateColumnQueryAsync([NotNull] this ICassandraFluentMigrator self, [NotNull] string table, [NotNull] string column, [NotNull] string type)
        {
            Check.NotNull(self, $"The argument [table]");
            Check.NotEmptyNotNull(column, $"The argument [{nameof(column)}]");
            Check.NotEmptyNotNull(column, $"The argument [{nameof(type)}]");

            var query = TableCqlStatements.TABLE_ADD_COLUMN_STATEMENT.NormalizeString(table, column, type);

            return(await self.ExecuteStatementAsync(query, AppErrorsMessages.COLUMN_EXISTS.NormalizeString(column)));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Build and execute the Reanme column query statement.
        /// </summary>
        ///
        /// <param name="self">The Cassandra Fluent Migrator.</param>
        /// <param name="table">The Cassandra table name.</param>
        /// <param name="column">Old Column to be renamed.</param>
        /// <param name="target">New Column name.</param>
        /// <returns>Cassandra Fluent Migrator.</returns>
        ///
        /// <exception cref="NullReferenceException">Thrown when the arguments are empty or null.</exception>
        internal static async Task <ICassandraFluentMigrator> ExecuteRenameColumnQueryAsync([NotNull] this ICassandraFluentMigrator self, [NotNull] string table, [NotNull] string column, [NotNull] string target)
        {
            Check.NotNull(self, $"The argument [cassandra fluent migrator object]");
            Check.NotEmptyNotNull(table, $"The argument [table]");
            Check.NotEmptyNotNull(column, $"The argument [old name]");
            Check.NotEmptyNotNull(target, $"The argument [new name]");

            var query = TableCqlStatements.TABLE_RENAME_COLUMN_STATEMENT.NormalizeString(table, column, target);

            return(await self.ExecuteStatementAsync(query, AppErrorsMessages.COLUMN_EXISTS_FOR_RENAME.NormalizeString(column, target, self.GetCassandraSession().Keyspace)));
        }