chrono_model 0.9.1 → 0.9.2
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 +4 -4
- data/.travis.yml +3 -3
- data/README.md +0 -4
- data/chrono_model.gemspec +1 -1
- data/lib/chrono_model.rb +5 -27
- data/lib/chrono_model/schema_format.rake +17 -16
- data/lib/chrono_model/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e2c2ec8b0a57f2078ffabc946175c86b70b7201
|
4
|
+
data.tar.gz: 6ad882f7558a940c9e3766e5abf6a6101107ffd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92eff9be8173deeb5092553a23403ff87918b5c993338825a79783470b74ec0988419ecc5f3c62075da785954e353f0d1f9447301c8c8b21349e7f9fc312788c
|
7
|
+
data.tar.gz: d62529c7d3c49aae5dde87ab4304377bdc290dffa7054b2fca4c421f6a7042b001cc4cf3dd7237af45bb81210c406488491b837661f0652b4c906faac647b854
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -285,10 +285,6 @@ offers many more indexing abilities and better performance than JSON.
|
|
285
285
|
[is broken][r4-tsrange-broken] and [incomplete][r4-tsrange-incomplete]
|
286
286
|
as of now, mainly due to a [design clash with ruby][pg-tsrange-and-ruby].
|
287
287
|
|
288
|
-
* There is (yet) no upgrade path from [v0.5][chronomodel-0.5],
|
289
|
-
(PG 9.0-compatible, `box()` and hacks) to v0.6 and up (>=9.3-only, `tsrange`
|
290
|
-
and _less_ hacks).
|
291
|
-
|
292
288
|
* The triggers and temporal indexes cannot be saved in schema.rb. The AR
|
293
289
|
schema dumper is quite basic, and it isn't (currently) extensible.
|
294
290
|
As we're using many database-specific features, Chronomodel forces the
|
data/chrono_model.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
|
|
21
21
|
|
22
22
|
gem.add_development_dependency 'pry'
|
23
23
|
gem.add_development_dependency 'hirb'
|
24
|
-
gem.add_development_dependency
|
24
|
+
gem.add_development_dependency 'byebug'
|
25
25
|
gem.add_development_dependency 'rspec'
|
26
26
|
gem.add_development_dependency 'rake'
|
27
27
|
gem.add_development_dependency 'fuubar'
|
data/lib/chrono_model.rb
CHANGED
@@ -14,33 +14,11 @@ if defined?(Rails)
|
|
14
14
|
require 'chrono_model/railtie'
|
15
15
|
end
|
16
16
|
|
17
|
-
# We need to override the "scoped" method on AR::Association for temporal
|
18
|
-
# associations to work. On Ruby 2.0 and up, the Module#prepend comes in
|
19
|
-
# handy - on Ruby 1.9 we have to hack the inheritance hierarchy.
|
20
|
-
#
|
21
17
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
ActiveRecord::Relation.instance_eval do
|
28
|
-
prepend ChronoModel::Patches::Relation
|
29
|
-
end
|
30
|
-
else
|
31
|
-
ActiveSupport::Deprecation.warn 'Ruby 1.9 is deprecated. Please update your Ruby <3'
|
32
|
-
|
33
|
-
silence_warnings do
|
34
|
-
class ChronoModel::Patches::AssociationPatch < ActiveRecord::Associations::Association
|
35
|
-
include ChronoModel::Patches::Association
|
36
|
-
end
|
37
|
-
|
38
|
-
ActiveRecord::Associations::Association = ChronoModel::Patches::AssociationPatch
|
39
|
-
|
40
|
-
class ChronoModel::Patches::RelationPatch < ActiveRecord::Relation
|
41
|
-
include ChronoModel::Patches::Relation
|
42
|
-
end
|
18
|
+
ActiveRecord::Associations::Association.instance_eval do
|
19
|
+
prepend ChronoModel::Patches::Association
|
20
|
+
end
|
43
21
|
|
44
|
-
|
45
|
-
|
22
|
+
ActiveRecord::Relation.instance_eval do
|
23
|
+
prepend ChronoModel::Patches::Relation
|
46
24
|
end
|
@@ -6,20 +6,21 @@ namespace :db do
|
|
6
6
|
task :dump => :environment do
|
7
7
|
config = PG.config!
|
8
8
|
target = ENV['DB_STRUCTURE'] || Rails.root.join('db', 'structure.sql')
|
9
|
-
|
9
|
+
schema = config[:schema_search_path]
|
10
10
|
|
11
|
-
|
12
|
-
# add
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
if schema.present?
|
12
|
+
# If a schema search path is configured, add also the ChronoModel schemas to the dump.
|
13
|
+
#
|
14
|
+
schema = schema.split /\s*,\s*/
|
15
|
+
schema = schema.concat [ ChronoModel::Adapter::TEMPORAL_SCHEMA, ChronoModel::Adapter::HISTORY_SCHEMA ]
|
16
|
+
schema = schema.map {|name| "--schema=#{name}" }
|
17
|
+
else
|
18
|
+
schema = [ ]
|
18
19
|
end
|
19
|
-
|
20
|
+
|
20
21
|
PG.make_dump target,
|
21
22
|
*config.values_at(:username, :database),
|
22
|
-
'-
|
23
|
+
'-x', '-s', '-O', *schema
|
23
24
|
|
24
25
|
# Add migration information, after resetting the schema to the default one
|
25
26
|
File.open(target, 'a') do |f|
|
@@ -27,13 +28,13 @@ namespace :db do
|
|
27
28
|
f.puts ActiveRecord::Base.connection.dump_schema_information
|
28
29
|
end
|
29
30
|
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
|
31
|
+
# The structure.sql includes CREATE SCHEMA statements, but as these are executed
|
32
|
+
# when the connection to the database is established, a db:structure:load fails.
|
33
|
+
# This code adds the IF NOT EXISTS clause to CREATE SCHEMA statements as long as
|
34
|
+
# it is not already present.
|
35
|
+
#
|
35
36
|
sql = File.read(target)
|
36
|
-
sql.gsub!(/CREATE SCHEMA /, '
|
37
|
+
sql.gsub!(/CREATE SCHEMA (?!IF NOT EXISTS)/, '\&IF NOT EXISTS ')
|
37
38
|
File.open(target, "w") { |file| file << sql }
|
38
39
|
end
|
39
40
|
|
data/lib/chrono_model/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chrono_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcello Barnaba
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|