timescaledb 0.1.4 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -0
  3. data/.tool-versions +1 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +4 -0
  6. data/Gemfile.lock +6 -3
  7. data/Gemfile.scenic +7 -0
  8. data/Gemfile.scenic.lock +121 -0
  9. data/README.md +35 -18
  10. data/Rakefile +7 -1
  11. data/bin/console +3 -3
  12. data/bin/setup +2 -0
  13. data/bin/tsdb +7 -7
  14. data/examples/{Gemfile → all_in_one/Gemfile} +0 -0
  15. data/examples/{Gemfile.lock → all_in_one/Gemfile.lock} +0 -0
  16. data/examples/{all_in_one.rb → all_in_one/all_in_one.rb} +1 -1
  17. data/examples/ranking/.gitattributes +7 -0
  18. data/examples/ranking/.gitignore +29 -0
  19. data/examples/ranking/.ruby-version +1 -0
  20. data/examples/ranking/Gemfile +33 -0
  21. data/examples/ranking/Gemfile.lock +189 -0
  22. data/examples/ranking/README.md +166 -0
  23. data/examples/ranking/Rakefile +6 -0
  24. data/examples/ranking/app/controllers/application_controller.rb +2 -0
  25. data/examples/ranking/app/controllers/concerns/.keep +0 -0
  26. data/examples/ranking/app/jobs/application_job.rb +7 -0
  27. data/examples/ranking/app/models/application_record.rb +3 -0
  28. data/examples/ranking/app/models/concerns/.keep +0 -0
  29. data/examples/ranking/app/models/game.rb +2 -0
  30. data/examples/ranking/app/models/play.rb +7 -0
  31. data/examples/ranking/bin/bundle +114 -0
  32. data/examples/ranking/bin/rails +4 -0
  33. data/examples/ranking/bin/rake +4 -0
  34. data/examples/ranking/bin/setup +33 -0
  35. data/examples/ranking/config/application.rb +39 -0
  36. data/examples/ranking/config/boot.rb +4 -0
  37. data/examples/ranking/config/credentials.yml.enc +1 -0
  38. data/examples/ranking/config/database.yml +86 -0
  39. data/examples/ranking/config/environment.rb +5 -0
  40. data/examples/ranking/config/environments/development.rb +60 -0
  41. data/examples/ranking/config/environments/production.rb +75 -0
  42. data/examples/ranking/config/environments/test.rb +53 -0
  43. data/examples/ranking/config/initializers/cors.rb +16 -0
  44. data/examples/ranking/config/initializers/filter_parameter_logging.rb +8 -0
  45. data/examples/ranking/config/initializers/inflections.rb +16 -0
  46. data/examples/ranking/config/initializers/timescale.rb +2 -0
  47. data/examples/ranking/config/locales/en.yml +33 -0
  48. data/examples/ranking/config/puma.rb +43 -0
  49. data/examples/ranking/config/routes.rb +6 -0
  50. data/examples/ranking/config/storage.yml +34 -0
  51. data/examples/ranking/config.ru +6 -0
  52. data/examples/ranking/db/migrate/20220209120747_create_games.rb +10 -0
  53. data/examples/ranking/db/migrate/20220209120910_create_plays.rb +19 -0
  54. data/examples/ranking/db/migrate/20220209143347_create_score_per_hours.rb +5 -0
  55. data/examples/ranking/db/schema.rb +47 -0
  56. data/examples/ranking/db/seeds.rb +7 -0
  57. data/examples/ranking/db/views/score_per_hours_v01.sql +7 -0
  58. data/examples/ranking/lib/tasks/.keep +0 -0
  59. data/examples/ranking/log/.keep +0 -0
  60. data/examples/ranking/public/robots.txt +1 -0
  61. data/examples/ranking/storage/.keep +0 -0
  62. data/examples/ranking/tmp/.keep +0 -0
  63. data/examples/ranking/tmp/pids/.keep +0 -0
  64. data/examples/ranking/tmp/storage/.keep +0 -0
  65. data/examples/ranking/vendor/.keep +0 -0
  66. data/lib/{timescale → timescaledb}/acts_as_hypertable/core.rb +1 -1
  67. data/lib/{timescale → timescaledb}/acts_as_hypertable.rb +6 -6
  68. data/lib/{timescale → timescaledb}/chunk.rb +1 -1
  69. data/lib/{timescale → timescaledb}/compression_settings.rb +3 -2
  70. data/lib/{timescale → timescaledb}/continuous_aggregates.rb +5 -4
  71. data/lib/timescaledb/dimensions.rb +6 -0
  72. data/lib/{timescale → timescaledb}/hypertable.rb +5 -5
  73. data/lib/timescaledb/job.rb +10 -0
  74. data/lib/{timescale → timescaledb}/job_stats.rb +3 -4
  75. data/lib/{timescale → timescaledb}/migration_helpers.rb +51 -13
  76. data/lib/timescaledb/scenic/adapter.rb +55 -0
  77. data/lib/timescaledb/scenic/extension.rb +72 -0
  78. data/lib/timescaledb/schema_dumper.rb +91 -0
  79. data/lib/{timescale → timescaledb}/stats_report.rb +2 -2
  80. data/lib/timescaledb/version.rb +3 -0
  81. data/lib/timescaledb.rb +64 -0
  82. data/{timescale.gemspec → timescaledb.gemspec} +5 -4
  83. metadata +92 -23
  84. data/lib/timescale/dimensions.rb +0 -7
  85. data/lib/timescale/job.rb +0 -13
  86. data/lib/timescale/schema_dumper.rb +0 -24
  87. data/lib/timescale/version.rb +0 -3
  88. data/lib/timescale.rb +0 -50
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c64be262fa0fbecf13ec6b6b8820b471c9d83e6842306efc59b950a693d4755b
4
- data.tar.gz: d702011692906410bd38107d16f9f20801977deb8f4a0cc3372dc5f61aed29ae
3
+ metadata.gz: d1fef5df000abb1cc12f56397a1e18f452bf35c061260cf403809db25954451a
4
+ data.tar.gz: d00d7d94a33b52475a6e5415e7bab669be079f62b165abdb666764a907e34dc6
5
5
  SHA512:
6
- metadata.gz: bc45bab9ddc1e32c1630bb4258299ee1a74b5b7991eb9281332d7de77161e4ad76cedb0cc2ddb30dbf609b68607a2cf0d7799c11130348bda94974fd46d152c1
7
- data.tar.gz: 4b6e7da46622c902fc1960fcba1b4d41b4674a8490eef2025f835b767efd3838573befffaed7fffceb65de5e65c793453d3eacfc681a1846f13ba2b485897ce6
6
+ metadata.gz: 1b814e74e3403c5a0e12ed8d3e115aff9a44e67cf0eff46a94b396e5511c0ce7a316808b1cc563890e27892383e1d0c3358c97abb8f9f49577bc5c8b01fc3fe6
7
+ data.tar.gz: ac250f31153249745e7db4ce3b7d7bbacaa25934dd7915a5a4b2aaf02595b5332344b890d1ee7a759b193f75c554bf101b7e0c492104f539edf7fa094fba133e
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.1
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.1
data/.travis.yml CHANGED
@@ -4,3 +4,6 @@ cache: bundler
4
4
  rvm:
5
5
  - 2.7.1
6
6
  before_install: gem install bundler -v 2.1.4
7
+ gemfile:
8
+ - Gemfile
9
+ - Gemfile.scenic
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in timescale.gemspec
4
4
  gemspec
5
+
6
+ # gemika must be listed in the Gemfile rather than as a development dependency in the gemspec.
7
+ # It throws an error, otherwise.
8
+ gem "gemika"
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- timescaledb (0.1.4)
4
+ timescaledb (0.2.1)
5
5
  activerecord
6
+ activesupport
6
7
  pg (~> 1.2)
7
8
 
8
9
  GEM
@@ -27,11 +28,12 @@ GEM
27
28
  database_cleaner-core (2.0.1)
28
29
  diff-lcs (1.4.4)
29
30
  dotenv (2.7.6)
31
+ gemika (0.6.1)
30
32
  i18n (1.8.10)
31
33
  concurrent-ruby (~> 1.0)
32
34
  method_source (1.0.0)
33
35
  minitest (5.14.4)
34
- pg (1.2.3)
36
+ pg (1.3.1)
35
37
  pry (0.14.1)
36
38
  coderay (~> 1.1)
37
39
  method_source (~> 1.0)
@@ -62,6 +64,7 @@ PLATFORMS
62
64
  DEPENDENCIES
63
65
  database_cleaner-active_record
64
66
  dotenv
67
+ gemika
65
68
  pry
66
69
  rake (~> 12.0)
67
70
  rspec (~> 3.0)
@@ -69,4 +72,4 @@ DEPENDENCIES
69
72
  timescaledb!
70
73
 
71
74
  BUNDLED WITH
72
- 2.1.4
75
+ 2.2.31
data/Gemfile.scenic ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in timescale.gemspec
4
+ gemspec
5
+
6
+ gem "scenic"
7
+ gem "gemika"
@@ -0,0 +1,121 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ timescaledb (0.1.5)
5
+ activerecord
6
+ activesupport
7
+ pg (~> 1.2)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionpack (6.1.4.1)
13
+ actionview (= 6.1.4.1)
14
+ activesupport (= 6.1.4.1)
15
+ rack (~> 2.0, >= 2.0.9)
16
+ rack-test (>= 0.6.3)
17
+ rails-dom-testing (~> 2.0)
18
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
19
+ actionview (6.1.4.1)
20
+ activesupport (= 6.1.4.1)
21
+ builder (~> 3.1)
22
+ erubi (~> 1.4)
23
+ rails-dom-testing (~> 2.0)
24
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
25
+ activemodel (6.1.4.1)
26
+ activesupport (= 6.1.4.1)
27
+ activerecord (6.1.4.1)
28
+ activemodel (= 6.1.4.1)
29
+ activesupport (= 6.1.4.1)
30
+ activesupport (6.1.4.1)
31
+ concurrent-ruby (~> 1.0, >= 1.0.2)
32
+ i18n (>= 1.6, < 2)
33
+ minitest (>= 5.1)
34
+ tzinfo (~> 2.0)
35
+ zeitwerk (~> 2.3)
36
+ builder (3.2.4)
37
+ coderay (1.1.3)
38
+ concurrent-ruby (1.1.9)
39
+ crass (1.0.6)
40
+ database_cleaner-active_record (2.0.1)
41
+ activerecord (>= 5.a)
42
+ database_cleaner-core (~> 2.0.0)
43
+ database_cleaner-core (2.0.1)
44
+ diff-lcs (1.4.4)
45
+ dotenv (2.7.6)
46
+ erubi (1.10.0)
47
+ gemika (0.6.1)
48
+ i18n (1.8.11)
49
+ concurrent-ruby (~> 1.0)
50
+ loofah (2.12.0)
51
+ crass (~> 1.0.2)
52
+ nokogiri (>= 1.5.9)
53
+ method_source (1.0.0)
54
+ mini_portile2 (2.6.1)
55
+ minitest (5.14.4)
56
+ nokogiri (1.12.5)
57
+ mini_portile2 (~> 2.6.1)
58
+ racc (~> 1.4)
59
+ nokogiri (1.12.5-x86_64-darwin)
60
+ racc (~> 1.4)
61
+ pg (1.3.0)
62
+ pry (0.14.1)
63
+ coderay (~> 1.1)
64
+ method_source (~> 1.0)
65
+ racc (1.6.0)
66
+ rack (2.2.3)
67
+ rack-test (1.1.0)
68
+ rack (>= 1.0, < 3)
69
+ rails-dom-testing (2.0.3)
70
+ activesupport (>= 4.2.0)
71
+ nokogiri (>= 1.6)
72
+ rails-html-sanitizer (1.4.2)
73
+ loofah (~> 2.3)
74
+ railties (6.1.4.1)
75
+ actionpack (= 6.1.4.1)
76
+ activesupport (= 6.1.4.1)
77
+ method_source
78
+ rake (>= 0.13)
79
+ thor (~> 1.0)
80
+ rake (12.3.3)
81
+ rspec (3.10.0)
82
+ rspec-core (~> 3.10.0)
83
+ rspec-expectations (~> 3.10.0)
84
+ rspec-mocks (~> 3.10.0)
85
+ rspec-core (3.10.1)
86
+ rspec-support (~> 3.10.0)
87
+ rspec-expectations (3.10.1)
88
+ diff-lcs (>= 1.2.0, < 2.0)
89
+ rspec-support (~> 3.10.0)
90
+ rspec-its (1.3.0)
91
+ rspec-core (>= 3.0.0)
92
+ rspec-expectations (>= 3.0.0)
93
+ rspec-mocks (3.10.2)
94
+ diff-lcs (>= 1.2.0, < 2.0)
95
+ rspec-support (~> 3.10.0)
96
+ rspec-support (3.10.3)
97
+ scenic (1.5.4)
98
+ activerecord (>= 4.0.0)
99
+ railties (>= 4.0.0)
100
+ thor (1.1.0)
101
+ tzinfo (2.0.4)
102
+ concurrent-ruby (~> 1.0)
103
+ zeitwerk (2.5.1)
104
+
105
+ PLATFORMS
106
+ ruby
107
+ x86_64-darwin-20
108
+
109
+ DEPENDENCIES
110
+ database_cleaner-active_record
111
+ dotenv
112
+ gemika
113
+ pry
114
+ rake (~> 12.0)
115
+ rspec (~> 3.0)
116
+ rspec-its
117
+ scenic
118
+ timescaledb!
119
+
120
+ BUNDLED WITH
121
+ 2.2.33
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Timescale
1
+ # TimescaleDB
2
2
 
3
- Welcome to the Timescale gem! To experiment with the code, start installing the
3
+ Welcome to the TimescaleDB gem! To experiment with the code, start installing the
4
4
  gem:
5
5
 
6
6
  ```bash
@@ -29,7 +29,7 @@ tsdb postgres://<user>@localhost:5432/<dbname> --stats
29
29
  Or just check the stats:
30
30
 
31
31
  ```bash
32
- tsdb "postgres://jonatasdp@localhost:5432/timescale_test" --stats
32
+ tsdb "postgres://jonatasdp@localhost:5432/timescaledb_test" --stats
33
33
  ```
34
34
 
35
35
  These is a sample output from database example with almost no data:
@@ -89,7 +89,7 @@ continuous aggregates views.
89
89
 
90
90
  ```ruby
91
91
  Tick
92
- => Timescale::Tick(time: datetime, symbol: string, price: decimal, volume: integer)
92
+ => Timescaledb::Tick(time: datetime, symbol: string, price: decimal, volume: integer)
93
93
  ```
94
94
 
95
95
  Note that it's only created for this session and will never be cached in the
@@ -102,7 +102,7 @@ Let's start with the `.hypertable` method.
102
102
 
103
103
  ```ruby
104
104
  Tick.hypertable
105
- => #<Timescale::Hypertable:0x00007fe99c258900
105
+ => #<Timescaledb::Hypertable:0x00007fe99c258900
106
106
  hypertable_schema: "public",
107
107
  hypertable_name: "ticks",
108
108
  owner: "jonatasdp",
@@ -122,7 +122,7 @@ from the hypertable relation.
122
122
  ```ruby
123
123
  Tick.hypertable.chunks
124
124
  unknown OID 2206: failed to recognize type of 'primary_dimension_type'. It will be treated as String.
125
- => [#<Timescale::Chunk:0x00007fe99c31b068
125
+ => [#<Timescaledb::Chunk:0x00007fe99c31b068
126
126
  hypertable_schema: "public",
127
127
  hypertable_name: "ticks",
128
128
  chunk_schema: "_timescaledb_internal",
@@ -175,14 +175,14 @@ The `ohlc_1m` view is also available as an ActiveRecord:
175
175
 
176
176
  ```ruby
177
177
  Ohlc1m
178
- => Timescale::Ohlc1m(bucket: datetime, symbol: string, open: decimal, high: decimal, low: decimal, close: decimal, volume: integer)
178
+ => Timescaledb::Ohlc1m(bucket: datetime, symbol: string, open: decimal, high: decimal, low: decimal, close: decimal, volume: integer)
179
179
  ```
180
180
 
181
181
  And you can run any query as you do with regular active record queries.
182
182
 
183
183
  ```ruby
184
184
  Ohlc1m.order(bucket: :desc).last
185
- => #<Timescale::Ohlc1m:0x00007fe99c2c38e0
185
+ => #<Timescaledb::Ohlc1m:0x00007fe99c2c38e0
186
186
  bucket: 2000-01-01 00:00:00 UTC,
187
187
  symbol: "SYMBOL",
188
188
  open: 0.13e2,
@@ -211,7 +211,9 @@ Or install it yourself as:
211
211
 
212
212
  ## Usage
213
213
 
214
- You can check the [all_in_one.rb](examples/all_in_one.rb) that will:
214
+ Check the [examples/ranking](examples/ranking) to get a Rails complete example.
215
+
216
+ You can check the [all_in_one.rb](examples/all_in_one/all_in_one.rb) example that will:
215
217
 
216
218
  1. Create hypertable with compression settings
217
219
  2. Insert data
@@ -221,6 +223,11 @@ You can check the [all_in_one.rb](examples/all_in_one.rb) that will:
221
223
  6. Check chunk status
222
224
  7. Decompress a chunk
223
225
 
226
+ ### Testing
227
+
228
+ If you need some inspiration for how are you going to test your hypertables,
229
+ please check the [spec/spec_helper.rb](spec/spec_helper.rb) for inspiration.
230
+
224
231
  ### Migrations
225
232
 
226
233
  Create table is now with the `hypertable` keyword allowing to pass a few options
@@ -243,7 +250,7 @@ create_table(:events, id: false, hypertable: hypertable_options) do |t|
243
250
  end
244
251
  ```
245
252
 
246
- #### create_continuous_aggregates
253
+ #### create_continuous_aggregate
247
254
 
248
255
  This example shows a ticks table grouping ticks as OHLCV histograms for every
249
256
  minute.
@@ -287,9 +294,19 @@ options = {
287
294
  }
288
295
  }
289
296
 
290
- create_continuous_aggregates('ohlc_1m', query, **options)
297
+ create_continuous_aggregate('ohlc_1m', query, **options)
291
298
  ```
292
299
 
300
+ #### Scenic integration
301
+
302
+ The [Scenic](https://github.com/scenic-views/scenic) gem is an easy way to
303
+ manage database view definitions for a Rails application. TimescaleDB's
304
+ continuous aggregates are more complex than regular PostgreSQL views, and
305
+ the schema dumper included with Scenic can't dump a complete definition.
306
+
307
+ This gem automatically configures Scenic to use a `Timescaledb::Scenic::Adapter`
308
+ which will correctly handle schema dumping.
309
+
293
310
  ### Enable ActsAsHypertable
294
311
 
295
312
  You can declare a Rails model as a Hypertable by invoking the `acts_as_hypertable` macro. This macro extends your existing model with timescaledb-related functionality.
@@ -318,7 +335,7 @@ end
318
335
  To get all the chunks from a model's hypertable, you can use `.chunks`.
319
336
 
320
337
  ```ruby
321
- Event.chunks # => [#<Timescale::Chunk>, ...]
338
+ Event.chunks # => [#<Timescaledb::Chunk>, ...]
322
339
  ```
323
340
 
324
341
  ### Hypertable metadata
@@ -326,20 +343,20 @@ Event.chunks # => [#<Timescale::Chunk>, ...]
326
343
  To get the models' hypertable metadata, you can use `.hypertable`.
327
344
 
328
345
  ```ruby
329
- Event.hypertable # => #<Timescale::Hypertable>
346
+ Event.hypertable # => #<Timescaledb::Hypertable>
330
347
  ```
331
348
 
332
- To get hypertable metadata for all hypertables: `Timescale.hypertables`.
349
+ To get hypertable metadata for all hypertables: `Timescaledb.hypertables`.
333
350
 
334
351
  ### Compression Settings
335
352
 
336
353
  Compression settings are accessible through the hypertable.
337
354
 
338
355
  ```ruby
339
- Event.hypertable.compression_settings # => [#<Timescale::CompressionSettings>, ...]
356
+ Event.hypertable.compression_settings # => [#<Timescaledb::CompressionSettings>, ...]
340
357
  ```
341
358
 
342
- To get compression settings for all hypertables: `Timescale.compression_settings`.
359
+ To get compression settings for all hypertables: `Timescaledb.compression_settings`.
343
360
 
344
361
  ### Scopes
345
362
 
@@ -388,7 +405,7 @@ end
388
405
 
389
406
  ## Development
390
407
 
391
- After checking out the repo, run `bin/setup` to install the development dependencies. Then, `bundle exec rake test:setup` to setup the test database and tables. Finally, run `bundle exec rspec` to run the tests.
408
+ After checking out the repo, run `bin/setup` to install the development dependencies. Then, `bundle exec rake test:setup` to setup the test database and tables. Finally, run `bundle exec rake` to run the tests.
392
409
 
393
410
  You can also run `tsdb` for an interactive prompt that will allow you to experiment.
394
411
 
@@ -405,7 +422,7 @@ You can put some postgres URI directly as a parameter of
405
422
  `tsdb`. Here is an example from the console:
406
423
 
407
424
  ```bash
408
- tsdb "postgres://jonatasdp@localhost:5432/timescale_test"
425
+ tsdb "postgres://jonatasdp@localhost:5432/timescaledb_test"
409
426
  ```
410
427
 
411
428
  ## More resources
data/Rakefile CHANGED
@@ -1,9 +1,15 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
3
 
4
+ begin
5
+ require "gemika/tasks"
6
+ rescue LoadError
7
+ puts "Run `gem install gemika` for additional tasks"
8
+ end
9
+
4
10
  RSpec::Core::RakeTask.new(:spec)
5
11
 
6
- task default: :spec
12
+ task default: "matrix:spec"
7
13
 
8
14
  namespace :test do
9
15
  task :setup do
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "timescale"
4
+ require "timescaledb"
5
5
 
6
6
  def uri_from_test
7
7
  require 'dotenv'
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  ActiveRecord::Base.establish_connection(ARGV[0] || uri_from_test)
13
13
 
14
- Timescale::Hypertable.find_each do |hypertable|
14
+ Timescaledb::Hypertable.find_each do |hypertable|
15
15
  class_name = hypertable.hypertable_name.singularize.camelize
16
16
 
17
17
  model = Class.new(ActiveRecord::Base) do
@@ -21,7 +21,7 @@ Timescale::Hypertable.find_each do |hypertable|
21
21
  acts_as_hypertable
22
22
  end
23
23
 
24
- Timescale.const_set(class_name, model)
24
+ Timescaledb.const_set(class_name, model)
25
25
  end
26
26
 
27
27
  require "pry"
data/bin/setup CHANGED
@@ -7,5 +7,7 @@ set -vx
7
7
 
8
8
  bundle install
9
9
 
10
+ bundle install --gemfile Gemfile.scenic
11
+
10
12
  # For running tests it's going to use PG_URI_TEST env variable.
11
13
  # Please make sure you set it properly to a TEST database!"
data/bin/tsdb CHANGED
@@ -1,26 +1,26 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "bundler/setup"
3
- require "timescale"
3
+ require "timescaledb"
4
4
  require "pry"
5
5
 
6
6
  ActiveRecord::Base.establish_connection(ARGV[0])
7
7
 
8
- Timescale::Hypertable.find_each do |hypertable|
8
+ Timescaledb::Hypertable.find_each do |hypertable|
9
9
  class_name = hypertable.hypertable_name.singularize.camelize
10
10
  model = Class.new(ActiveRecord::Base) do
11
11
  self.table_name = hypertable.hypertable_name
12
12
  acts_as_hypertable
13
13
  end
14
- Timescale.const_set(class_name, model)
14
+ Timescaledb.const_set(class_name, model)
15
15
  end
16
16
 
17
- Timescale::ContinuousAggregates.find_each do |cagg|
17
+ Timescaledb::ContinuousAggregates.find_each do |cagg|
18
18
  class_name = cagg.view_name.singularize.camelize
19
19
  model = Class.new(ActiveRecord::Base) do
20
20
  self.table_name = cagg.view_name
21
21
  acts_as_hypertable
22
22
  end
23
- Timescale.const_set(class_name, model)
23
+ Timescaledb.const_set(class_name, model)
24
24
  end
25
25
 
26
26
  def show(obj)
@@ -28,7 +28,7 @@ def show(obj)
28
28
  end
29
29
 
30
30
  if ARGV.index("--stats")
31
- scope = Timescale::Hypertable.all
31
+ scope = Timescaledb::Hypertable.all
32
32
 
33
33
  if (only = ARGV.index("--only"))
34
34
  only_hypertables = ARGV[only+1].split(",")
@@ -40,7 +40,7 @@ if ARGV.index("--stats")
40
40
  scope = scope.where.not(hypertable_name: except_hypertables)
41
41
  end
42
42
 
43
- show(Timescale.stats(scope))
43
+ show(Timescaledb.stats(scope))
44
44
  end
45
45
 
46
46
  if ARGV.index("--console")
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  require 'bundler/setup'
2
- require 'timescale'
2
+ require 'timescaledb'
3
3
  require 'pp'
4
4
  require 'pry'
5
5
  # ruby all_in_one.rb postgres://user:pass@host:port/db_name
@@ -0,0 +1,7 @@
1
+ # See https://git-scm.com/docs/gitattributes for more about git attribute files.
2
+
3
+ # Mark the database schema as having been generated.
4
+ db/schema.rb linguist-generated
5
+
6
+ # Mark any vendored files as having been vendored.
7
+ vendor/* linguist-vendored
@@ -0,0 +1,29 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore all logfiles and tempfiles.
11
+ /log/*
12
+ /tmp/*
13
+ !/log/.keep
14
+ !/tmp/.keep
15
+
16
+ # Ignore pidfiles, but keep the directory.
17
+ /tmp/pids/*
18
+ !/tmp/pids/
19
+ !/tmp/pids/.keep
20
+
21
+ # Ignore uploaded files in development.
22
+ /storage/*
23
+ !/storage/.keep
24
+ /tmp/storage/*
25
+ !/tmp/storage/
26
+ !/tmp/storage/.keep
27
+
28
+ # Ignore master key for decrypting credentials and more.
29
+ /config/master.key
@@ -0,0 +1 @@
1
+ 2.7.1
@@ -0,0 +1,33 @@
1
+ source "https://rubygems.org"
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ ruby "2.7.1"
5
+
6
+ # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
7
+ gem "rails", "~> 7.0.2"
8
+
9
+ gem "timescaledb", path: "../../"
10
+ gem "pg", "~> 1.1"
11
+ gem "puma", "~> 5.0"
12
+ gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
13
+
14
+ # Reduces boot times through caching; required in config/boot.rb
15
+ gem "bootsnap", require: false
16
+
17
+ # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
18
+ # gem "image_processing", "~> 1.2"
19
+
20
+ # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
21
+ # gem "rack-cors"
22
+
23
+ group :development, :test do
24
+ gem "pry-rails"
25
+ end
26
+
27
+ group :development do
28
+ # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
29
+ # gem "spring"
30
+ end
31
+
32
+
33
+ gem "scenic", "~> 1.5"