clickhouse-rails 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53465e63150b708d9a01b7508e09a91e6ed599e6a9436d56b65576499984d483
4
- data.tar.gz: fb517f02559a4f1d8d7140a4e0842f8c634941dadc73bcb67dff9d8de773a5de
3
+ metadata.gz: d7f0fc0991b11eab9bacb6ae43c87f5cbefefe1bdb35144fdb599753017e884a
4
+ data.tar.gz: df7b20d8b908a66ee5622025a3f3407a5902d502eb9f56b25869732571403a75
5
5
  SHA512:
6
- metadata.gz: 45503b480904734621b91fd5a3177f045998aedcd8712b3144351cfdad0f56c7dba68797c7cc2139760d8bd3ac0247d0e2337568fbc1a46ab2181ffd1fd5c9e7
7
- data.tar.gz: ddfa5b82e2e061de0ace2786f140bf1c5d00637e10fff34e1230304ddba52a74fa1e2e8a0a39ca2ba84f62844b969d1c57c3adbc3b74c25010a2d188bd0f39b4
6
+ metadata.gz: 1bcfb1c9b9ca2a208ad148cdf0ace5b951d26bd09d79d2c7b92ab2570493c90da886cfac9d5b8568d16373f23c1cc50d0af536e0e2bcb7e906e1a7331fb777f8
7
+ data.tar.gz: e230acf543be8220bfbd0ce150e1831f65a9e59bb9d13efb1d1feab48f0f3a590fbf80b21d7f33213d6abebd4f5c2cee4476c73fb7c7fb0535791336b8dba936
@@ -18,15 +18,14 @@ module Clickhouse
18
18
  @migrations_list.each do |migration|
19
19
  next if migration.passed?
20
20
 
21
- migration.up
22
- migration.add_version
21
+ run_migration(migration)
23
22
  end
24
23
  end
25
24
 
26
25
  def passed?
27
26
  return false unless table_exists?(MIGRATION_TABLE)
28
27
 
29
- @rows ||= connection.select_row(select: 'version', from: MIGRATION_TABLE)
28
+ @rows ||= connection.select_rows(select: 'version', from: MIGRATION_TABLE).flatten
30
29
  @rows.include?(name)
31
30
  rescue Clickhouse::QueryError
32
31
  false
@@ -35,8 +34,8 @@ module Clickhouse
35
34
  def up; end
36
35
 
37
36
  def add_version
38
- connection.insert_rows(MIGRATION_TABLE) do |row|
39
- row << { version: name }
37
+ connection.insert_rows(MIGRATION_TABLE, names: ['version']) do |row|
38
+ row << [name]
40
39
  end
41
40
  end
42
41
 
@@ -79,6 +78,17 @@ module Clickhouse
79
78
  connection.execute("ALTER TABLE #{@table_name} ADD COLUMN #{column} #{type}")
80
79
  end
81
80
 
81
+ def run_migration(migration)
82
+ puts "# >========== #{migration.name} ==========="
83
+ migration.up
84
+ migration.add_version
85
+ rescue Clickhouse::QueryError => e
86
+ puts "# Error #{e.class}:"
87
+ puts "# #{e.message}"
88
+ ensure
89
+ puts "# <========== #{migration.name} ===========\n\n"
90
+ end
91
+
82
92
  def connection
83
93
  Clickhouse.connection
84
94
  end
@@ -1,5 +1,5 @@
1
1
  module Clickhouse
2
2
  module Rails
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.1.1'.freeze
4
4
  end
5
5
  end
@@ -4,7 +4,7 @@ require_relative '../../../clickhouse/rails/migrations/base'
4
4
  namespace :clickhouse do
5
5
  namespace :db do
6
6
  desc 'Migrate clickhouse migrations'
7
- task :migrate do
7
+ task migrate: :environment do
8
8
  path_to_migrations = './db/clickhouse/migrate/*.rb'
9
9
  Dir[path_to_migrations].sort.each { |file| require file }
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clickhouse-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vsevolod Avramov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-20 00:00:00.000000000 Z
11
+ date: 2019-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clickhouse