clickhouse-rails 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7f0fc0991b11eab9bacb6ae43c87f5cbefefe1bdb35144fdb599753017e884a
|
4
|
+
data.tar.gz: df7b20d8b908a66ee5622025a3f3407a5902d502eb9f56b25869732571403a75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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 <<
|
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
|
@@ -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 :
|
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.
|
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-
|
11
|
+
date: 2019-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clickhouse
|