squasher 0.6.2 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- 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 +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 +15 -1
- data/spec/lib/squasher_spec.rb +8 -0
- data/spec/lib/worker_spec.rb +2 -2
- 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: 1c3cc21150f68603733fa84c85d9a50c6d9b08ea34f7c5724341c3b116db2274
|
4
|
+
data.tar.gz: 13d90d21f1d5770b31ed3d334535e94334e1939cb78ca48d61482aa4d312a65c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49013a339324ae6f10fcc30e39c140d989b7fa9a7a208442f46ba70cea1be57792c990972fd9cd9448b33d35b8cbd17a37945276d7472e9c5da86d1868ceed8b
|
7
|
+
data.tar.gz: 14727bb5d71d889d728fee2458479d50a5a1a4a000b4e8b7eabe6cdfca1a672251f6cfd026ad8e52666d2fe066cf80e8ba567274df697927e0847ec090e74548
|
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
|
@@ -78,7 +81,7 @@ module Squasher
|
|
78
81
|
end
|
79
82
|
|
80
83
|
def migrations_folder?
|
81
|
-
Dir.
|
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.
|
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.
|
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.
|
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
|
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,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.
|
67
|
+
File.exist?(File.join(fake_root, *parts))
|
54
68
|
end
|
55
69
|
end
|
56
70
|
|
data/spec/lib/squasher_spec.rb
CHANGED
data/spec/lib/worker_spec.rb
CHANGED
@@ -42,7 +42,7 @@ describe Squasher::Worker do
|
|
42
42
|
|
43
43
|
worker.process
|
44
44
|
|
45
|
-
expect(File.
|
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.
|
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.
|
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:
|
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
|
-
|
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:
|