squasher 0.6.2 → 0.7.0

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
- SHA1:
3
- metadata.gz: cf0d8f8b39a17c546b7c41e4b1a1fd0270e48a41
4
- data.tar.gz: ef9dbd8730c1b69ba92239aee084dcfd5f29638c
2
+ SHA256:
3
+ metadata.gz: b1881315f750432477c45c63915b6118af4f165ba9c00fcf2b253d34d14bf49d
4
+ data.tar.gz: 22a3270dafb3aafae0b4eabe0720cb069a2aef9718f30150953295bdcd36084b
5
5
  SHA512:
6
- metadata.gz: ada8df65280932e7ea471d16036ec085eb0f1f5c8e608584cb9230f753347d8375c1fa4abcdaa7358f196781c65e2147157abece5005884f528979f053924199
7
- data.tar.gz: ef96d4e8bd32439cf2502af47a0ef457f2d2ea2d08a46117b44a158de8732e1232e8e15499b785fa377e37ba32f778c33f974950b2a0fb52f85175ecdf1b43e3
6
+ metadata.gz: 54a095db328fdbf39dac24d7d509271a14e7765d313b36fccdfefc43d6a20d5eb36659884ed90b6fec0fcc901f10182c8ded4bb33bcc37835674107e28a81a93
7
+ data.tar.gz: 722b7b612648974304e842405b980f628d2939aa8816d918fda4bc0c2ea27209e9ed5dab769d909bbfcc9f825cdae276527c9db90593a33bc742715daca57229
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
@@ -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.0"
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,6 +49,20 @@ 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
67
  File.exists?(File.join(fake_root, *parts))
54
68
  end
@@ -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
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.0
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: 2022-11-15 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: