squasher 0.6.2 → 0.7.1

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
- SHA1:
3
- metadata.gz: cf0d8f8b39a17c546b7c41e4b1a1fd0270e48a41
4
- data.tar.gz: ef9dbd8730c1b69ba92239aee084dcfd5f29638c
2
+ SHA256:
3
+ metadata.gz: 1c3cc21150f68603733fa84c85d9a50c6d9b08ea34f7c5724341c3b116db2274
4
+ data.tar.gz: 13d90d21f1d5770b31ed3d334535e94334e1939cb78ca48d61482aa4d312a65c
5
5
  SHA512:
6
- metadata.gz: ada8df65280932e7ea471d16036ec085eb0f1f5c8e608584cb9230f753347d8375c1fa4abcdaa7358f196781c65e2147157abece5005884f528979f053924199
7
- data.tar.gz: ef96d4e8bd32439cf2502af47a0ef457f2d2ea2d08a46117b44a158de8732e1232e8e15499b785fa377e37ba32f778c33f974950b2a0fb52f85175ecdf1b43e3
6
+ metadata.gz: 49013a339324ae6f10fcc30e39c140d989b7fa9a7a208442f46ba70cea1be57792c990972fd9cd9448b33d35b8cbd17a37945276d7472e9c5da86d1868ceed8b
7
+ data.tar.gz: 14727bb5d71d889d728fee2458479d50a5a1a4a000b4e8b7eabe6cdfca1a672251f6cfd026ad8e52666d2fe066cf80e8ba567274df697927e0847ec090e74548
data/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ - 0.7.0
2
+ - Support the presence of multiverse ([@mlohbihler](https://github.com/mlohbihler))
1
3
  - 0.6.1
2
4
  - Escape regexp in sql mode ([@mpospelov](https://github.com/mpospelov))
3
5
  - 0.6.0
data/README.md CHANGED
@@ -6,6 +6,9 @@
6
6
 
7
7
  Squasher compresses old ActiveRecord migrations. If you work on a big project with lots of migrations, every `rake db:migrate` might take a few seconds, or creating of a new database might take a few minutes. That's because ActiveRecord loads all those migration files. Squasher removes all the migrations and creates a single migration with the final database state of the specified date (the new migration will look like a schema).
8
8
 
9
+ ## Attention
10
+ Prior to 0.6.2 squasher could damage your real data as generate "force" tables. Please upgrade to 0.6.2+ & manually clean "force" tag from the init migration
11
+
9
12
  ## Installation
10
13
 
11
14
  You don't have to add it into your Gemfile. Just a standalone installation:
data/bin/squasher CHANGED
@@ -32,6 +32,10 @@ parser = OptionParser.new do |config|
32
32
  options[:engine] = value
33
33
  end
34
34
 
35
+ config.on('--databases=DB_KEY,...', 'alternate database configuration keys to be included dbconfig (for multiverse)') do |value|
36
+ options[:databases] = value&.split(",")
37
+ end
38
+
35
39
  config.on('-v', '--version', '-h', '--help', 'show this message')
36
40
  end
37
41
  parser.parse!
@@ -36,7 +36,7 @@ module Squasher
36
36
  end
37
37
 
38
38
  def now_timestamp
39
- Time.now.strftime("%Y%m%d%H%M%S")
39
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
40
40
  end
41
41
  end
42
42
  end
@@ -39,6 +39,7 @@ module Squasher
39
39
  @root_path = Dir.pwd.freeze
40
40
  @migrations_folder = File.join(@root_path, 'db', 'migrate')
41
41
  @flags = []
42
+ @databases = []
42
43
  set_app_path(@root_path)
43
44
  end
44
45
 
@@ -60,6 +61,8 @@ module Squasher
60
61
  elsif key == :sql
61
62
  @schema_file = File.join(@app_path, 'db', 'structure.sql')
62
63
  @flags << key
64
+ elsif key == :databases
65
+ @databases = value
63
66
  else
64
67
  @flags << key
65
68
  end
@@ -78,7 +81,7 @@ module Squasher
78
81
  end
79
82
 
80
83
  def migrations_folder?
81
- Dir.exists?(migrations_folder)
84
+ Dir.exist?(migrations_folder)
82
85
  end
83
86
 
84
87
  def dbconfig?
@@ -90,7 +93,7 @@ module Squasher
90
93
 
91
94
  list = [dbconfig_file, schema_file]
92
95
  list.each do |file|
93
- next unless File.exists?(file)
96
+ next unless File.exist?(file)
94
97
  FileUtils.mv file, "#{ file }.sq"
95
98
  end
96
99
 
@@ -100,7 +103,7 @@ module Squasher
100
103
 
101
104
  ensure
102
105
  list.each do |file|
103
- next unless File.exists?("#{ file }.sq")
106
+ next unless File.exist?("#{ file }.sq")
104
107
  FileUtils.mv "#{ file }.sq", file
105
108
  end
106
109
  end
@@ -115,7 +118,7 @@ module Squasher
115
118
 
116
119
  def dbconfig
117
120
  return @dbconfig if defined?(@dbconfig)
118
- return @dbconfig = nil unless File.exists?(dbconfig_file)
121
+ return @dbconfig = nil unless File.exist?(dbconfig_file)
119
122
 
120
123
  @dbconfig = nil
121
124
 
@@ -123,6 +126,7 @@ module Squasher
123
126
  content, soft_error = Render.process(dbconfig_file)
124
127
  if content.has_key?('development')
125
128
  @dbconfig = { 'development' => content['development'].merge('database' => 'squasher') }
129
+ @databases&.each { |database| @dbconfig[database] = content[database] }
126
130
  end
127
131
  rescue
128
132
  end
@@ -1,3 +1,3 @@
1
1
  module Squasher
2
- VERSION = "0.6.2"
2
+ VERSION = "0.7.1"
3
3
  end
data/lib/squasher.rb CHANGED
@@ -46,7 +46,7 @@ module Squasher
46
46
  end
47
47
 
48
48
  def print(message, options = {})
49
- puts message % options
49
+ puts options.empty? ? message : message % options
50
50
  end
51
51
 
52
52
  def error(*args)
@@ -16,3 +16,7 @@ another_test:
16
16
  database: another_test
17
17
  user: root
18
18
  password: password
19
+ multiverse-database:
20
+ database: multiverse-database
21
+ user: multiverse-user
22
+ password: multiverse-password
@@ -5,7 +5,7 @@ describe Squasher::Cleaner do
5
5
  let(:expected_file) { File.join(fake_root, 'db', 'migrate', '20140102030405_squasher_clean.rb') }
6
6
 
7
7
  before do
8
- allow(Time).to receive(:now).and_return(Time.new(2014, 1, 2, 3, 4, 5))
8
+ allow(Time).to receive(:now).and_return(Time.utc(2014, 1, 2, 3, 4, 5))
9
9
  allow(Squasher).to receive(:rake).with("db:migrate", :db_cleaning)
10
10
  end
11
11
 
@@ -49,8 +49,22 @@ describe Squasher::Config do
49
49
  end
50
50
  end
51
51
 
52
+ it 'includes other database definitions provided in the command line' do
53
+ config.set(:databases, ["multiverse-database"])
54
+ config.stub_dbconfig do
55
+ File.open(File.join(fake_root, 'config', 'database.yml')) do |stream|
56
+ content = YAML.load(stream.read)
57
+ expect(content["development"]["database"]).to eq("squasher")
58
+ expect(content["development"]["encoding"]).to eq("utf-8")
59
+ expect(content["multiverse-database"]["database"]).to eq("multiverse-database")
60
+ expect(content["multiverse-database"]["user"]).to eq("multiverse-user")
61
+ expect(content).not_to have_key("another_development")
62
+ end
63
+ end
64
+ end
65
+
52
66
  def file_exists?(*parts)
53
- File.exists?(File.join(fake_root, *parts))
67
+ File.exist?(File.join(fake_root, *parts))
54
68
  end
55
69
  end
56
70
 
@@ -46,4 +46,12 @@ describe Squasher do
46
46
  Squasher.rake('db:migrate')
47
47
  end
48
48
  end
49
+
50
+ context '.print' do
51
+ context 'when options are empty' do
52
+ it 'prints the message without error' do
53
+ Squasher.print('asdf % asdf', {})
54
+ end
55
+ end
56
+ end
49
57
  end
@@ -42,7 +42,7 @@ describe Squasher::Worker do
42
42
 
43
43
  worker.process
44
44
 
45
- expect(File.exists?(new_migration_path)).to be_truthy
45
+ expect(File.exist?(new_migration_path)).to be_truthy
46
46
  File.open(new_migration_path) do |stream|
47
47
  content = stream.read
48
48
  expect(content).to include("InitSchema")
@@ -69,7 +69,7 @@ describe Squasher::Worker do
69
69
  expect(Squasher).to receive(:ask).with(:apply_clean).and_return(false)
70
70
  worker.process
71
71
 
72
- expect(File.exists?(new_migration_path)).to be_truthy
72
+ expect(File.exist?(new_migration_path)).to be_truthy
73
73
  File.open(new_migration_path) do |stream|
74
74
  content = stream.read
75
75
  expect(content.strip).to eq(%q{
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squasher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Pchelintsev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-06 00:00:00.000000000 Z
11
+ date: 2023-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,7 +96,7 @@ homepage: https://github.com/jalkoby/squasher
96
96
  licenses:
97
97
  - MIT
98
98
  metadata: {}
99
- post_install_message:
99
+ post_install_message:
100
100
  rdoc_options: []
101
101
  require_paths:
102
102
  - lib
@@ -111,9 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  requirements: []
114
- rubyforge_project:
115
- rubygems_version: 2.6.13
116
- signing_key:
114
+ rubygems_version: 3.2.32
115
+ signing_key:
117
116
  specification_version: 4
118
117
  summary: Squash your old migrations
119
118
  test_files: