clickhouse-activerecord 0.3.9 → 0.3.11
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03776772df850312a0cb6994a9797aee37fdf537eb8839d53e358fe78924b844
|
4
|
+
data.tar.gz: b97fce3acd8c2f8b06cc50bd262c96db6d7355ff1317d4cab5e6271999f38098
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0580fd619a922e91c09173d86c9a207a334d66e88d3876da2838f6ea7e3db92925b289591f8b15cb624ff7f7e5098aa9790c26f7a6ff475b537f2efd27b79fb7'
|
7
|
+
data.tar.gz: 6dc95a06b6b0a079985b9863d41a5f1611ad479dd922449d7a612ec757b513b568d570c9272b80428398934aa958b5eecfb5c43ee4432667d5b938b5338e0319
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
### Version 0.3.10 (Dec 20, 2019)
|
2
|
+
|
3
|
+
* Support structure dump/load [@StoneGod](https://github.com/StoneGod)
|
4
|
+
|
1
5
|
### Version 0.3.6 (Sep 2, 2019)
|
2
6
|
|
3
7
|
* Support Rails 6.0
|
@@ -5,18 +9,18 @@
|
|
5
9
|
|
6
10
|
### Version 0.3.4 (Jun 28, 2019)
|
7
11
|
|
8
|
-
* Fix DateTime sql format without microseconds for Rails 5.2
|
12
|
+
* Fix DateTime sql format without microseconds for Rails 5.2
|
9
13
|
* Support ssl connection
|
10
14
|
* Migration support
|
11
15
|
* Rake tasks for create / drop database
|
12
|
-
|
16
|
+
|
13
17
|
### Version 0.3.0 (Nov 27, 2018)
|
14
18
|
|
15
19
|
* Support materialized view
|
16
20
|
* Aggregated functions for view
|
17
21
|
* Schema dumper with SQL create table
|
18
22
|
* Added migrations support [@Bugagazavr](https://github.com/Bugagazavr)
|
19
|
-
|
23
|
+
|
20
24
|
### Version 0.2.0 (Oct 3, 2017)
|
21
25
|
|
22
26
|
* Support Rails 5.0
|
@@ -24,7 +28,7 @@
|
|
24
28
|
### Version 0.1.2 (Sep 27, 2017)
|
25
29
|
|
26
30
|
* Fix Big Int type
|
27
|
-
|
31
|
+
|
28
32
|
### Version 0.1.0 (Aug 31, 2017)
|
29
33
|
|
30
34
|
* Initial release
|
data/README.md
CHANGED
@@ -107,6 +107,10 @@ Migration:
|
|
107
107
|
|
108
108
|
Rollback migration not supported!
|
109
109
|
|
110
|
+
### Dump / Load for multiple using databases
|
111
|
+
|
112
|
+
If you using multiple databases, for example: PostgreSQL, Clickhouse.
|
113
|
+
|
110
114
|
Schema dump to `db/clickhouse_schema.rb` file:
|
111
115
|
|
112
116
|
$ rake clickhouse:schema:dump
|
@@ -114,9 +118,24 @@ Schema dump to `db/clickhouse_schema.rb` file:
|
|
114
118
|
Schema load from `db/clickhouse_schema.rb` file:
|
115
119
|
|
116
120
|
$ rake clickhouse:schema:load
|
117
|
-
|
121
|
+
|
118
122
|
We use schema for emulate development or tests environment on PostgreSQL adapter.
|
119
123
|
|
124
|
+
Structure dump to `db/clickhouse_structure.sql` file:
|
125
|
+
|
126
|
+
$ rake clickhouse:structure:dump
|
127
|
+
|
128
|
+
Structure load from `db/clickhouse_structure.sql` file:
|
129
|
+
|
130
|
+
$ rake clickhouse:structure:load
|
131
|
+
|
132
|
+
### Dump / Load for only Clickhouse database using
|
133
|
+
|
134
|
+
$ rake db:schema:dump
|
135
|
+
$ rake db:schema:load
|
136
|
+
$ rake db:structure:dump
|
137
|
+
$ rake db:structure:load
|
138
|
+
|
120
139
|
### Insert and select data
|
121
140
|
|
122
141
|
```ruby
|
@@ -31,13 +31,27 @@ module ClickhouseActiverecord
|
|
31
31
|
create
|
32
32
|
end
|
33
33
|
|
34
|
+
def structure_dump(*args)
|
35
|
+
tables = connection.execute("SHOW TABLES FROM #{@configuration['database']}")['data'].flatten
|
36
|
+
|
37
|
+
File.open(args.first, 'w:utf-8') do |file|
|
38
|
+
tables.each do |table|
|
39
|
+
next if table.match(/\.inner/)
|
40
|
+
file.puts connection.execute("SHOW CREATE TABLE #{table}")['data'].try(:first).try(:first).gsub("#{@configuration['database']}.", '') + ";\n\n"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def structure_load(*args)
|
46
|
+
File.read(args.first).split(";\n\n").each { |sql| connection.execute(sql) }
|
47
|
+
end
|
48
|
+
|
34
49
|
def migrate
|
35
50
|
check_target_version
|
36
51
|
|
37
52
|
verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] != "false" : true
|
38
53
|
scope = ENV["SCOPE"]
|
39
54
|
verbose_was, ActiveRecord::Migration.verbose = ActiveRecord::Migration.verbose, verbose
|
40
|
-
binding.pry
|
41
55
|
connection.migration_context.migrate(target_version) do |migration|
|
42
56
|
scope.blank? || scope == migration.scope
|
43
57
|
end
|
data/lib/tasks/clickhouse.rake
CHANGED
@@ -27,6 +27,18 @@ namespace :clickhouse do
|
|
27
27
|
|
28
28
|
end
|
29
29
|
|
30
|
+
namespace :structure do
|
31
|
+
desc 'Load database structure'
|
32
|
+
task load: [:load_config, 'db:check_protected_environments'] do
|
33
|
+
ClickhouseActiverecord::Tasks.new(ActiveRecord::Base.configurations["#{Rails.env}_clickhouse"]).structure_load("#{Rails.root}/db/clickhouse_structure.sql")
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'Dump database structure'
|
37
|
+
task dump: [:load_config, 'db:check_protected_environments'] do
|
38
|
+
ClickhouseActiverecord::Tasks.new(ActiveRecord::Base.configurations["#{Rails.env}_clickhouse"]).structure_dump("#{Rails.root}/db/clickhouse_structure.sql")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
30
42
|
desc 'Creates the database from DATABASE_URL or config/database.yml'
|
31
43
|
task create: [:load_config] do
|
32
44
|
ActiveRecord::Tasks::DatabaseTasks.create(ActiveRecord::Base.configurations["#{Rails.env}_clickhouse"])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clickhouse-activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Odintsov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|