Skip to content

Commit c1ee41f

Browse files
authored
Merge pull request cequel#398 from ilanusse/drop-column
Can now drop columns
2 parents 6d830d1 + 462838f commit c1ee41f

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

cequel.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99
'Ilya Bazylchuk', 'Dan Cardamore', 'Kei Kusakari', 'Oleh Novosad',
1010
'John Smart', 'Angelo Lakra', 'Olivier Lance', 'Tomohiro Nishimura',
1111
'Masaki Takahashi', 'G Gordon Worley III', 'Clark Bremer', 'Tamara Temple',
12-
'Long On', 'Lucas Mundim', 'William Flanagan'
12+
'Long On', 'Lucas Mundim', 'William Flanagan', 'Inaki Lanusse'
1313
]
1414
s.homepage = "https://github.com/cequel/cequel"
1515
s.email = '[email protected]'

lib/cequel/schema/table_updater.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ def rename_column(old_name, new_name)
9797
add_stmt %Q|ALTER TABLE "#{table_name}" RENAME "#{old_name}" TO "#{new_name}"|
9898
end
9999

100+
# Remove a column
101+
#
102+
# @param name [Symbol] the name of the column to remove
103+
# @return [void]
104+
#
105+
def drop_column(name)
106+
add_stmt %Q|ALTER TABLE "#{table_name}" DROP "#{name}"|
107+
end
108+
100109
#
101110
# Change one or more table storage properties
102111
#

lib/cequel/schema/update_table_dsl.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ def initialize(updater)
6767
#
6868
def_delegator :@updater, :rename_column
6969

70+
# @!method drop_column(name)
71+
# (see Cequel::Schema::TableUpdater#drop_column)
72+
#
73+
def_delegator :@updater, :drop_column
74+
alias_method :remove_column, :drop_column
75+
7076
#
7177
# @!method change_properties(options)
7278
# (see Cequel::Schema::TableUpdater#change_properties)

spec/examples/schema/table_updater_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@
151151

152152
describe '#drop_column' do
153153
before do
154-
pending 'Support in a future Cassandra version'
155154
cequel.schema.alter_table(table_name) do
156155
drop_column :body
157156
end

0 commit comments

Comments
 (0)