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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b5f6975bd8ac6e9a10d0f9655a0b8a93f5ce1c1
4
- data.tar.gz: 56f8ba1e389e723fa02aea9a2fdde9c39b64ea32
3
+ metadata.gz: 9a07db7bfb2579474dfc22c97f654eeb0753c67f
4
+ data.tar.gz: 31147f793f011cee930c989d40429087f9ceab4a
5
5
  SHA512:
6
- metadata.gz: 636dde577a3aaad53bccff51443f7ee82c0b72515af5db714c14c093bc8643a0715ae5fb3915535cc12a4eeed0baba6d988b47b5084b9ef5d3c69fe95d1ff5f6
7
- data.tar.gz: 254f7d242c475accd162c2aa8143283cb9aae1f402b72ee9f168c4ab11b8538aabdf29fd2439d261f78ad69636b0304f682f575d321e2eecdb3497979f027e0d
6
+ metadata.gz: a474711ac629c19dca856e11b028e89a5d2b38732aa451b2fe531628b2c54c74b6bef628c0c279bbf0b88ffc5d0ce53e25705e3f43bc959999c50c85f5cf26a4
7
+ data.tar.gz: a2e83881771c76b3ac4676eea176f64e0384534f2a0d71f4c00c412da2b21945ca274c78caa2265e5bf1df84df05fb95a890b6a76a054e653aecc47eafa758a3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.7
2
+
3
+ - Added `--source-table` option to `fill`
4
+
1
5
  ## 0.1.6
2
6
 
3
7
  - Added `--no-partition` option to `prep`
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
- 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;
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
- CREATE TRIGGER #{trigger_name}
90
- BEFORE INSERT ON #{intermediate_table}
91
- FOR EACH ROW EXECUTE PROCEDURE #{trigger_name}();
92
- SQL
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 = retired_name(table)
166
+ source_table ||= retired_name(table)
165
167
  dest_table = table
166
168
  else
167
- source_table = 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|
@@ -1,3 +1,3 @@
1
1
  module PgSlice
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
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.6
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-08-05 00:00:00.000000000 Z
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.6.1
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: