activerecord_views 0.1.1 → 0.1.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/lib/active_record_views/version.rb +1 -1
- data/lib/tasks/active_record_views.rake +20 -5
- data/spec/tasks_spec.rb +19 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f6181c027be63e47f0f891651ef16dc6732baf4000d196709d2cbb80f0c8aa2
|
4
|
+
data.tar.gz: f9a5c359c72123e6555cf023ba8aca2b6509f6341d60d239297ebf84a28bde3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53c430bb26f03dad6cab94335ae927fefe3a4111dee9b2e322985e6eca85dc68f9c15091199c63f5e4983e36c3e4b906967166e2431f470c46574f55cc8ee990
|
7
|
+
data.tar.gz: 3548136a4b337bc8331a51b150c23bd72548ffb0b114a0dae7c148f000f5faea5cd24e1998e027ff9eca2b8073f234100af3afc3bacb6ae140c80d01ca2f513e
|
@@ -62,12 +62,27 @@ Rake::Task[schema_rake_task].enhance do
|
|
62
62
|
pg_tasks.send(:remove_sql_header_comments, active_record_views_dump.path)
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
# Substitute out any timestamps that were dumped from the active_record_views table
|
66
|
+
#
|
67
|
+
# Before:
|
68
|
+
#
|
69
|
+
# COPY public.active_record_views (name, class_name, checksum, options, refreshed_at) FROM stdin;
|
70
|
+
# test_view TestView 42364a017b73ef516a0eca9827e6fa00623257ee {"dependencies":[]} 2021-10-26 02:49:12.247494
|
71
|
+
# \.
|
72
|
+
#
|
73
|
+
# After:
|
74
|
+
#
|
75
|
+
# COPY public.active_record_views (name, class_name, checksum, options, refreshed_at) FROM stdin;
|
76
|
+
# test_view TestView 42364a017b73ef516a0eca9827e6fa00623257ee {"dependencies":[]} \N
|
77
|
+
# \.
|
78
|
+
active_record_views_dump_content = active_record_views_dump.read
|
79
|
+
if active_record_views_dump_content !~ /^COPY public.active_record_views \(.+, refreshed_at\) FROM stdin;$/
|
80
|
+
raise 'refreshed_at is not final column'
|
81
|
+
end
|
82
|
+
active_record_views_dump_content.gsub!(/\t\d\d\d\d-\d\d-\d\d.*$/, "\t\\N")
|
69
83
|
|
70
|
-
|
84
|
+
File.open filename, 'a' do |io|
|
85
|
+
io.puts active_record_views_dump_content
|
71
86
|
end
|
72
87
|
ensure
|
73
88
|
active_record_views_dump.close
|
data/spec/tasks_spec.rb
CHANGED
@@ -79,8 +79,25 @@ describe 'rake tasks' do
|
|
79
79
|
sql = File.read('spec/internal/db/structure.sql')
|
80
80
|
expect(sql).to match(/CREATE TABLE public\.schema_migrations/)
|
81
81
|
expect(sql).to match(/CREATE VIEW public\.test_view/)
|
82
|
-
expect(sql).to match(/COPY public\.active_record_views.+test_view\tTestView
|
83
|
-
|
82
|
+
expect(sql).to match(/COPY public\.active_record_views.+test_view\tTestView\t.*\t.*\t\\N$/m)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'clears refreshed_at values' do
|
86
|
+
ActiveRecord::Base.connection.execute "UPDATE active_record_views SET refreshed_at = current_timestamp AT TIME ZONE 'UTC' WHERE name = 'test_view';"
|
87
|
+
|
88
|
+
rake schema_rake_task
|
89
|
+
|
90
|
+
ActiveRecord::Base.clear_all_connections!
|
91
|
+
|
92
|
+
system 'dropdb activerecord_views_test'
|
93
|
+
raise unless $?.success?
|
94
|
+
system 'createdb activerecord_views_test'
|
95
|
+
raise unless $?.success?
|
96
|
+
system 'psql -X -q -o /dev/null -f spec/internal/db/structure.sql activerecord_views_test'
|
97
|
+
raise unless $?.success?
|
98
|
+
|
99
|
+
refreshed_ats = ActiveRecord::Base.connection.select_values("SELECT refreshed_at FROM active_record_views WHERE name = 'test_view'")
|
100
|
+
expect(refreshed_ats).to eq [nil]
|
84
101
|
end
|
85
102
|
|
86
103
|
it 'does not write structure.sql when `schema_format = :ruby`', if: schema_rake_task != 'db:structure:dump' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_views
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Weathered
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
|
-
rubygems_version: 3.0.3
|
188
|
+
rubygems_version: 3.0.3
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: Automatic database view creation for ActiveRecord
|