|
311 | 311 |
|
312 | 312 | ActiveRecord::Base.connection.clear_index('some', 'idx2') |
313 | 313 | end |
| 314 | + |
| 315 | + it 'schema dumps and restores column indexes' do |
| 316 | + require 'clickhouse-activerecord/schema_dumper' |
| 317 | + |
| 318 | + quietly { migration_context.up(4) } |
| 319 | + |
| 320 | + current_schema = StringIO.new |
| 321 | + ClickhouseActiverecord::SchemaDumper.dump(ActiveRecord::Base.connection, current_schema) |
| 322 | + |
| 323 | + ActiveRecord::Base.connection.drop_table('some', sync: true) |
| 324 | + quietly { eval(current_schema.string) } |
| 325 | + |
| 326 | + expect(ActiveRecord::Base.connection.show_create_table('some')).to include('INDEX idx4 date TYPE minmax GRANULARITY 1') |
| 327 | + end |
| 328 | + |
| 329 | + it 'schema dumps and restores multi-column indexes' do |
| 330 | + require 'clickhouse-activerecord/schema_dumper' |
| 331 | + |
| 332 | + quietly { migration_context.up(1) } |
| 333 | + |
| 334 | + current_schema = StringIO.new |
| 335 | + ClickhouseActiverecord::SchemaDumper.dump(ActiveRecord::Base.connection, current_schema) |
| 336 | + |
| 337 | + ActiveRecord::Base.connection.drop_table('some', sync: true) |
| 338 | + quietly { eval(current_schema.string) } |
| 339 | + |
| 340 | + expect(ActiveRecord::Base.connection.show_create_table('some')).to include('INDEX idx (int1 * int2, date) TYPE minmax GRANULARITY 3') |
| 341 | + end |
| 342 | + |
| 343 | + it 'schema dumps and restores expression indexes' do |
| 344 | + require 'clickhouse-activerecord/schema_dumper' |
| 345 | + |
| 346 | + quietly { migration_context.up(3) } |
| 347 | + |
| 348 | + current_schema = StringIO.new |
| 349 | + ClickhouseActiverecord::SchemaDumper.dump(ActiveRecord::Base.connection, current_schema) |
| 350 | + |
| 351 | + ActiveRecord::Base.connection.drop_table('some', sync: true) |
| 352 | + quietly { eval(current_schema.string) } |
| 353 | + |
| 354 | + expect(ActiveRecord::Base.connection.show_create_table('some')).to include('INDEX idx2 int1 * int2 TYPE set(10) GRANULARITY 4') |
| 355 | + end |
314 | 356 | end |
315 | 357 | end |
316 | 358 | end |
|
0 commit comments