Skip to content

Commit

Permalink
Fix change_column functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
cbisnett committed Jul 26, 2024
1 parent 1582b50 commit 85c60d7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
10 changes: 10 additions & 0 deletions spec/fixtures/migrations/dsl_change_column/1_create_some_table.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

class CreateSomeTable < ActiveRecord::Migration[7.1]
def up
create_table :some, options: 'MergeTree ORDER BY id' do |t|
t.integer :col, limit: 4, null: false
end
end
end

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class AlterColColumn < ActiveRecord::Migration[7.1]
def up
change_column :some, :col, :int64, null: false
end
end
15 changes: 15 additions & 0 deletions spec/single/migration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,21 @@
end
end

describe 'alter column' do
let(:directory) { 'dsl_change_column' }
it 'alters the column' do
subject

current_schema = schema(model)

expect(current_schema.keys.count).to eq(2)
expect(current_schema).to have_key('id')
expect(current_schema).to have_key('col')
expect(current_schema['id'].sql_type).to eq('UInt32')
expect(current_schema['col'].sql_type).to eq('Int64')
end
end

context 'function creation' do
after do
ActiveRecord::Base.connection.drop_functions
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
host: 'localhost',
port: ENV['CLICKHOUSE_PORT'] || 8123,
database: ENV['CLICKHOUSE_DATABASE'] || 'test',
username: nil,
password: nil,
username: 'default',
password: 'docker',
use_metadata_table: false,
cluster_name: ENV['CLICKHOUSE_CLUSTER'],
}
Expand Down

0 comments on commit 85c60d7

Please sign in to comment.