activerecord_views 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_record_views/version.rb +1 -1
- data/lib/tasks/active_record_views.rake +19 -5
- data/spec/tasks_spec.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 777d910ae40ada55060df98887059878cc8ddb8ec65f6d49a890d2de9164810f
|
4
|
+
data.tar.gz: d905c23880139d85f0fb9ec3c00318670a1638351fc8e42bab05656c8d097d2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed3ac3d78b82bf20501936c0c3f4a30815300da89d2516d9149d37723d977638f06f0c6414a62d1460239da7e94478110bb89ec13459d656d28cbe37ca94e254
|
7
|
+
data.tar.gz: 0f6f5bf130436bc8fcf1a9fd1ad383044bc4a0373dd1f18a56c5691ee20a1eb55d38476e8af294c9daeb740182b520aff7202c4c6b75cc638d46dd12cda26dff
|
@@ -52,12 +52,26 @@ Rake::Task[schema_rake_task].enhance do
|
|
52
52
|
pg_tasks = tasks.send(:class_for_adapter, adapter).new(config)
|
53
53
|
pg_tasks.send(:set_psql_env)
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
begin
|
56
|
+
active_record_views_dump = Tempfile.open("active_record_views_dump.sql")
|
57
|
+
require 'shellwords'
|
58
|
+
system("pg_dump --data-only --no-owner --table=active_record_views #{Shellwords.escape database} >> #{Shellwords.escape active_record_views_dump.path}")
|
59
|
+
raise 'active_record_views metadata dump failed' unless $?.success?
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
+
if Gem::Version.new(Rails.version) >= Gem::Version.new("5.1")
|
62
|
+
pg_tasks.send(:remove_sql_header_comments, active_record_views_dump.path)
|
63
|
+
end
|
64
|
+
|
65
|
+
File.open filename, 'a' do |io|
|
66
|
+
# Seek to the end to ensure we don't overwrite the existing content
|
67
|
+
io.seek(0, IO::SEEK_END)
|
68
|
+
IO.copy_stream active_record_views_dump, io
|
69
|
+
|
70
|
+
io.puts 'UPDATE public.active_record_views SET refreshed_at = NULL WHERE refreshed_at IS NOT NULL;'
|
71
|
+
end
|
72
|
+
ensure
|
73
|
+
active_record_views_dump.close
|
74
|
+
active_record_views_dump.unlink
|
61
75
|
end
|
62
76
|
end
|
63
77
|
end
|
data/spec/tasks_spec.rb
CHANGED
@@ -77,6 +77,8 @@ describe 'rake tasks' do
|
|
77
77
|
|
78
78
|
expect(File.exist?('spec/internal/db/schema.rb')).to eq false
|
79
79
|
sql = File.read('spec/internal/db/structure.sql')
|
80
|
+
expect(sql).to match(/CREATE TABLE public\.schema_migrations/)
|
81
|
+
expect(sql).to match(/CREATE VIEW public\.test_view/)
|
80
82
|
expect(sql).to match(/COPY public\.active_record_views.+test_view\tTestView/m)
|
81
83
|
expect(sql).to match(/UPDATE public\.active_record_views SET refreshed_at = NULL/)
|
82
84
|
end
|
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.1
|
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-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|