capistrano-db_sync 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 560f9902b7556b03a2206f1b3125d68d906000ed
4
- data.tar.gz: fc422d26be8a12e80bae35f88e9918286439a3ec
3
+ metadata.gz: 2ac7a777e216b28b76c7d74495c2ac24ac043d7a
4
+ data.tar.gz: 7f6dce31e24ddf589319d52f4b1a92f4d3830386
5
5
  SHA512:
6
- metadata.gz: 001d12a9c6bbfce2689c49d47d6c9c8752d7792fa28355149b120306da264a33e40f4047ca41255067fb57ec4080832611006699619bed491dd009abbc2d2ca8
7
- data.tar.gz: 1b0d4fdfd2210b57bedba454ef62446c952196462e5affd89effece893ba10d6fcf3b531d704b573ecfe837b72b1b60bc07ec0111c0ba3aaa3bccda5f9141909
6
+ metadata.gz: c4cfb9da1b149eed3247badcde9fdde382b6204063cb284acb011fbdbc592a2343933e92e218c4c795fa80c8b3db1e9512882695ffca70f4104a9e13b6a9d24c
7
+ data.tar.gz: 809713ff8d936873c98aab1bec2b8046f19e353f3e21bc89f12a0d39892391c6633fcd89d515666d0187d041cf3e4b25196b697b71f0acc5e5e56ec2eaa831a1
data/README.md CHANGED
@@ -1,10 +1,13 @@
1
+ [![Build Status](https://snap-ci.com/heartbits/capistrano-db_sync/branch/master/build_image)](https://snap-ci.com/heartbits/capistrano-db_sync/branch/master)
2
+
1
3
  ## Capistrano::DBSync
2
4
 
3
5
  Fast and sophisticated remote database import using the best of **Postgres 9.2.x**
4
6
 
5
7
  ### Features
6
8
 
7
- * Allows dump data selectively - partial table data or no data
9
+ * Allows dumping data selectively - choose between entire, partial or no data
10
+ * No downtime on restore - it uses a temporary database while restoring
8
11
  * Uses Postgres parallel restore
9
12
  * Uses Postgres custom dump format that is automatically compressed
10
13
 
@@ -20,10 +23,10 @@ Fast and sophisticated remote database import using the best of **Postgres 9.2.x
20
23
  1. Add this line to your application's Gemfile:
21
24
 
22
25
  ```ruby
23
- gem 'capistrano-pg_sync', require: false
26
+ gem 'capistrano-db_sync', require: false
24
27
  ```
25
28
 
26
- 2. Define your custom settings, if needed. We suggest to locate this file at `lib/capistrano/tasks/db_sync.rake`.
29
+ 2. Define your custom settings, if needed. We suggest to put this file at `lib/capistrano/tasks/db_sync.rake`.
27
30
  Capistrano 3.x should load all `*.rake` files by default in `Capfile`.
28
31
  [See the complete configuration reference](/lib/capistrano/db_sync/configuration.rb)
29
32
 
@@ -73,6 +76,9 @@ The following steps describe what happens when executing `cap production db_sync
73
76
  3. data for tables with partial data specified in configuration
74
77
  4. triggers, constraints, rules and indexes
75
78
 
79
+ ### Contributors
80
+
81
+ * Rafael Sales [@rafaelsales](http://github.com/rafaelsales) - help me not stay forever alone here :)
76
82
 
77
83
  ### Contributing
78
84
 
@@ -41,12 +41,12 @@ class Capistrano::DBSync::Postgres::CLI
41
41
  SQL
42
42
  end
43
43
 
44
- def copy_to_file(to_compressed_file, db, query)
45
- psql "\\COPY (#{query}) TO PROGRAM 'gzip > #{to_compressed_file}'", db
44
+ def copy_and_compress_to_file(to_compressed_file, db, query)
45
+ psql "\\copy (#{query}) TO PROGRAM 'gzip > #{to_compressed_file}' WITH CSV", db
46
46
  end
47
47
 
48
- def copy_from_file(from_compressed_file, db, table)
49
- psql "\\COPY #{table} FROM PROGRAM 'gunzip --to-stdout #{from_compressed_file}'", db
48
+ def copy_from_compressed_file(from_compressed_file, db, table)
49
+ psql "\\copy #{table} FROM PROGRAM 'gunzip --to-stdout #{from_compressed_file}' WITH CSV", db
50
50
  end
51
51
 
52
52
  private
@@ -52,7 +52,7 @@ module Capistrano::DBSync
52
52
 
53
53
  def dump_partial_selected_data(db, file_namer, data_selection)
54
54
  data_selection.map do |table, query|
55
- cli.copy_to_file(file_namer.next(table, :table), db, query) if query
55
+ cli.copy_and_compress_to_file(file_namer.next(table, :table), db, query) if query
56
56
  end.compact
57
57
  end
58
58
 
@@ -70,7 +70,7 @@ module Capistrano::DBSync
70
70
  files = Dir.glob(File.join(working_dir, "*.table"))
71
71
  files.map do |file|
72
72
  table_name = Postgres::FileNameGenerator.extract_name(file)
73
- cli.copy_from_file(file, to_db, table_name)
73
+ cli.copy_from_compressed_file(file, to_db, table_name)
74
74
  end
75
75
  end
76
76
 
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module DBSync
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -8,9 +8,9 @@ describe Capistrano::DBSync::Postgres::Exporter do
8
8
  describe "#dump" do
9
9
  let(:data_selection) do
10
10
  {
11
- campaigns: "SELECT * FROM campaigns WHERE date > NOW() - interval '160 days'",
12
- keywords: "SELECT * FROM keywords WHERE created_at > NOW() - interval '160 days'",
13
- phone_calls: nil
11
+ posts: "SELECT * FROM posts WHERE date > NOW() - interval '160 days'",
12
+ comments: "SELECT * FROM comments WHERE created_at > NOW() - interval '160 days'",
13
+ likes: nil
14
14
  }
15
15
  end
16
16
 
@@ -19,13 +19,13 @@ describe Capistrano::DBSync::Postgres::Exporter do
19
19
 
20
20
  # Assert dumping database schema with data except for tables specified on data_selection
21
21
  commands[0].must_match /pg_dump.* -f \/tmp\/dumps\/0001-faceburger_production\.schema/
22
- commands[0].must_match /--exclude-table-data="campaigns"/
23
- commands[0].must_match /--exclude-table-data="keywords"/
24
- commands[0].must_match /--exclude-table-data="phone_calls"/
22
+ commands[0].must_match /--exclude-table-data="posts"/
23
+ commands[0].must_match /--exclude-table-data="comments"/
24
+ commands[0].must_match /--exclude-table-data="likes"/
25
25
 
26
26
  # Assert dumping data for tables specified on data_selection
27
- commands[1].must_match /COPY.*campaigns.*\/tmp\/dumps\/0002-campaigns\.table/
28
- commands[2].must_match /COPY.*keywords.*\/tmp\/dumps\/0003-keywords\.table/
27
+ commands[1].must_match /copy.*posts.*\/tmp\/dumps\/0002-posts\.table/
28
+ commands[2].must_match /copy.*comments.*\/tmp\/dumps\/0003-comments\.table/
29
29
  end
30
30
  end
31
31
  end
@@ -11,7 +11,7 @@ describe Capistrano::DBSync::Postgres::Importer do
11
11
  .returns(["/tmp/dumps/0001-faceburger_production.schema"])
12
12
 
13
13
  Dir.stubs(:glob).with("/tmp/dumps/*.table")
14
- .returns(["/tmp/dumps/0002-campaigns.table", "/tmp/dumps/0003-keywords.table"])
14
+ .returns(["/tmp/dumps/0002-posts.table", "/tmp/dumps/0003-comments.table"])
15
15
  end
16
16
 
17
17
  it "restore dump files" do
@@ -27,8 +27,8 @@ describe Capistrano::DBSync::Postgres::Importer do
27
27
  commands[3].must_match /pg_restore.* \/tmp\/dumps\/0001-faceburger_production\.schema/
28
28
 
29
29
  # Assert import selective tables data
30
- commands[4].must_match /COPY campaigns.*\/tmp\/dumps\/0002-campaigns\.table/
31
- commands[5].must_match /COPY keywords.*\/tmp\/dumps\/0003-keywords\.table/
30
+ commands[4].must_match /copy posts.*\/tmp\/dumps\/0002-posts\.table/
31
+ commands[5].must_match /copy comments.*\/tmp\/dumps\/0003-comments\.table/
32
32
 
33
33
  # Assert restore indexes, constraints, triggers and rules
34
34
  commands[6].must_match /pg_restore.*--section=post-data --jobs=3/
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-db_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Sales
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-09 00:00:00.000000000 Z
11
+ date: 2015-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano