squasher 0.6.1 → 0.7.0
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 +5 -5
- data/CHANGELOG.md +2 -0
- data/README.md +3 -0
- data/bin/squasher +4 -0
- data/lib/squasher/cleaner.rb +1 -1
- data/lib/squasher/config.rb +4 -0
- data/lib/squasher/render.rb +8 -4
- data/lib/squasher/version.rb +1 -1
- data/lib/squasher.rb +1 -1
- data/spec/fake_app/config/database.yml +4 -0
- data/spec/lib/cleaner_spec.rb +1 -1
- data/spec/lib/config_spec.rb +14 -0
- data/spec/lib/squasher_spec.rb +8 -0
- data/spec/lib/worker_spec.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b1881315f750432477c45c63915b6118af4f165ba9c00fcf2b253d34d14bf49d
|
4
|
+
data.tar.gz: 22a3270dafb3aafae0b4eabe0720cb069a2aef9718f30150953295bdcd36084b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54a095db328fdbf39dac24d7d509271a14e7765d313b36fccdfefc43d6a20d5eb36659884ed90b6fec0fcc901f10182c8ded4bb33bcc37835674107e28a81a93
|
7
|
+
data.tar.gz: 722b7b612648974304e842405b980f628d2939aa8816d918fda4bc0c2ea27209e9ed5dab769d909bbfcc9f825cdae276527c9db90593a33bc742715daca57229
|
data/CHANGELOG.md
CHANGED
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!
|
data/lib/squasher/cleaner.rb
CHANGED
data/lib/squasher/config.rb
CHANGED
@@ -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
|
data/lib/squasher/render.rb
CHANGED
@@ -49,13 +49,17 @@ module Squasher
|
|
49
49
|
def stream_schema(stream)
|
50
50
|
inside_schema = false
|
51
51
|
|
52
|
-
stream.each_line do |
|
52
|
+
stream.each_line do |raw_line|
|
53
53
|
if inside_schema
|
54
54
|
# reach the end of schema
|
55
|
-
break if
|
56
|
-
|
55
|
+
break if raw_line.index("end") == 0
|
56
|
+
line = raw_line.gsub(/\A\s{,2}(.*)\s+\z/, '\1')
|
57
|
+
if line.include?('create_table')
|
58
|
+
line.gsub!(/(create_table.*),.* do/, '\1 do')
|
59
|
+
end
|
60
|
+
yield line
|
57
61
|
else
|
58
|
-
inside_schema = true if
|
62
|
+
inside_schema = true if raw_line.include?("ActiveRecord::Schema")
|
59
63
|
end
|
60
64
|
end
|
61
65
|
end
|
data/lib/squasher/version.rb
CHANGED
data/lib/squasher.rb
CHANGED
data/spec/lib/cleaner_spec.rb
CHANGED
@@ -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.
|
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
|
|
data/spec/lib/config_spec.rb
CHANGED
@@ -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
|
data/spec/lib/squasher_spec.rb
CHANGED
data/spec/lib/worker_spec.rb
CHANGED
@@ -46,7 +46,7 @@ describe Squasher::Worker do
|
|
46
46
|
File.open(new_migration_path) do |stream|
|
47
47
|
content = stream.read
|
48
48
|
expect(content).to include("InitSchema")
|
49
|
-
expect(content).to include('create_table "managers"
|
49
|
+
expect(content).to include('create_table "managers" do |t|')
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
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.
|
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:
|
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
|
-
|
115
|
-
|
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:
|