pgslice 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/pgslice.rb +17 -15
- data/lib/pgslice/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a07db7bfb2579474dfc22c97f654eeb0753c67f
|
4
|
+
data.tar.gz: 31147f793f011cee930c989d40429087f9ceab4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a474711ac629c19dca856e11b028e89a5d2b38732aa451b2fe531628b2c54c74b6bef628c0c279bbf0b88ffc5d0ce53e25705e3f43bc959999c50c85f5cf26a4
|
7
|
+
data.tar.gz: a2e83881771c76b3ac4676eea176f64e0384534f2a0d71f4c00c412da2b21945ca274c78caa2265e5bf1df84df05fb95a890b6a76a054e653aecc47eafa758a3
|
data/CHANGELOG.md
CHANGED
data/lib/pgslice.rb
CHANGED
@@ -76,20 +76,20 @@ CREATE TABLE #{intermediate_table} (LIKE #{table} INCLUDING ALL);
|
|
76
76
|
unless options[:no_partition]
|
77
77
|
sql_format = SQL_FORMAT[period.to_sym]
|
78
78
|
queries << <<-SQL
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
79
|
+
CREATE FUNCTION #{trigger_name}()
|
80
|
+
RETURNS trigger AS $$
|
81
|
+
BEGIN
|
82
|
+
EXECUTE 'INSERT INTO #{table}_' || to_char(NEW.#{column}, '#{sql_format}') || ' VALUES ($1.*)' USING NEW;
|
83
|
+
RETURN NULL;
|
84
|
+
END;
|
85
|
+
$$ LANGUAGE plpgsql;
|
86
86
|
SQL
|
87
87
|
|
88
88
|
queries << <<-SQL
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
CREATE TRIGGER #{trigger_name}
|
90
|
+
BEFORE INSERT ON #{intermediate_table}
|
91
|
+
FOR EACH ROW EXECUTE PROCEDURE #{trigger_name}();
|
92
|
+
SQL
|
93
93
|
end
|
94
94
|
|
95
95
|
run_queries(queries)
|
@@ -160,11 +160,13 @@ CREATE TABLE #{partition_name}
|
|
160
160
|
|
161
161
|
abort "Usage: pgslice fill <table>" if arguments.length != 1
|
162
162
|
|
163
|
+
source_table = options[:source_table]
|
164
|
+
|
163
165
|
if options[:swapped]
|
164
|
-
source_table
|
166
|
+
source_table ||= retired_name(table)
|
165
167
|
dest_table = table
|
166
168
|
else
|
167
|
-
source_table
|
169
|
+
source_table ||= table
|
168
170
|
dest_table = intermediate_name(table)
|
169
171
|
end
|
170
172
|
|
@@ -281,7 +283,6 @@ INSERT INTO #{dest_table} (#{fields})
|
|
281
283
|
opts = Slop.parse(args) do |o|
|
282
284
|
o.boolean "--intermediate"
|
283
285
|
o.boolean "--swapped"
|
284
|
-
o.boolean "--debug"
|
285
286
|
o.float "--sleep"
|
286
287
|
o.integer "--future", default: 0
|
287
288
|
o.integer "--past", default: 0
|
@@ -290,6 +291,7 @@ INSERT INTO #{dest_table} (#{fields})
|
|
290
291
|
o.boolean "--no-partition", default: false
|
291
292
|
o.integer "--start"
|
292
293
|
o.string "--url"
|
294
|
+
o.string "--source-table"
|
293
295
|
o.on "-v", "--version", "print the version" do
|
294
296
|
log PgSlice::VERSION
|
295
297
|
@exit = true
|
@@ -342,7 +344,7 @@ INSERT INTO #{dest_table} (#{fields})
|
|
342
344
|
|
343
345
|
def run_queries(queries)
|
344
346
|
connection.transaction do
|
345
|
-
execute("SET client_min_messages TO warning")
|
347
|
+
execute("SET client_min_messages TO warning") unless options[:dry_run]
|
346
348
|
log_sql "BEGIN;"
|
347
349
|
log_sql
|
348
350
|
queries.each do |query|
|
data/lib/pgslice/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pgslice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slop
|
@@ -102,9 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
104
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.
|
105
|
+
rubygems_version: 2.5.1
|
106
106
|
signing_key:
|
107
107
|
specification_version: 4
|
108
108
|
summary: Postgres partitioning as easy as pie
|
109
109
|
test_files: []
|
110
|
-
has_rdoc:
|