squasher 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/README.md +15 -12
- data/lib/squasher/render.rb +2 -2
- data/lib/squasher/version.rb +1 -1
- data/spec/fake_app/db/structure.sql +2 -1
- data/spec/lib/worker_spec.rb +6 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58e6842c01fedd8c3d14952de14c3cdfe58dcbeb
|
4
|
+
data.tar.gz: c2ec95df798554cc3af0d238ffd5178cf980e789
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63bd6a06a4b0e3c241d097ce3b96d84d908f3d0ee5ca84aaa8a06139b6b81864b4bb167f8aca9a8134707da98e9bb6ee8cc27d8c8b30be9225192764ae38fb78
|
7
|
+
data.tar.gz: b398fc389ccb9b873e11f75ce94512ae7678c1d94ac47d2bae63ae0415e3d2b3075403eee9cafcb987757d2669f83c95677aeef9278d242e68c6bc4aafd0da4e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[![Code Climate](https://codeclimate.com/github/jalkoby/squasher.svg)](https://codeclimate.com/github/jalkoby/squasher)
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/squasher.svg)](http://badge.fury.io/rb/squasher)
|
6
6
|
|
7
|
-
Squasher compresses old migrations
|
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
9
|
## Installation
|
10
10
|
|
@@ -19,7 +19,7 @@ If you want to share it with your rails/sinatra/etc app add the below:
|
|
19
19
|
```ruby
|
20
20
|
# Yep, the missing group in most Gemfiles where all utilities should be!
|
21
21
|
group :tools do
|
22
|
-
gem 'squasher', '>= 0.
|
22
|
+
gem 'squasher', '>= 0.6.0'
|
23
23
|
gem 'capistrano'
|
24
24
|
gem 'rubocop'
|
25
25
|
end
|
@@ -39,23 +39,24 @@ To integrate `squasher` with your app even more do the below:
|
|
39
39
|
|
40
40
|
Suppose your application was created a few years ago. `%app_root%/db/migrate` folder looks like this:
|
41
41
|
```bash
|
42
|
-
|
43
|
-
|
42
|
+
2012...._first_migration.rb
|
43
|
+
2012...._another_migration.rb
|
44
44
|
# and a lot of other files
|
45
|
-
|
45
|
+
2013...._adding_model_foo.rb
|
46
46
|
# few years later
|
47
|
-
|
47
|
+
2016...._removing_model_foo.rb
|
48
48
|
# and so on
|
49
49
|
```
|
50
50
|
|
51
|
-
Storing these atomic changes over time is painful and useless. It's time to archive
|
51
|
+
Storing these atomic changes over time is painful and useless. It's time to archive this history. Once you install the gem you can run the `squasher` command. For example, you want to compress all migrations which were created prior to the year 2017:
|
52
52
|
|
53
|
-
$ squasher
|
53
|
+
$ squasher 2017 # rails 3 & 4
|
54
|
+
$ squasher 2017 -m 5.0 # rails 5+
|
54
55
|
|
55
56
|
You can tell `squasher` a more detailed date, for example:
|
56
57
|
|
57
|
-
$ squasher
|
58
|
-
$ squasher
|
58
|
+
$ squasher 2016/12 # prior to December 2016
|
59
|
+
$ squasher 2016/12/19 # prior to 19 December 2016
|
59
60
|
|
60
61
|
### Options
|
61
62
|
|
@@ -69,10 +70,12 @@ Run `squasher -h` or just `squasher` to see how you can use squasher:
|
|
69
70
|
|
70
71
|
## Requirements
|
71
72
|
|
72
|
-
It works and was tested on Ruby 2.0+ and
|
73
|
+
It works and was tested on Ruby 2.0+ and ActiveRecord 3.1+. It also requires a valid development configuration in `config/database.yml`.
|
73
74
|
If an old migration inserted data (created ActiveRecord model records) you will lose this code in the squashed migration, **BUT** `squasher` will ask you to leave a tmp database which will have all data that was inserted while migrating. Using this database you could add that data as another migration, or into `config/seed.rb` (the expected place for this stuff).
|
74
75
|
|
75
|
-
##
|
76
|
+
## Changelog
|
77
|
+
|
78
|
+
All changes are located in [the changelog file](CHANGELOG.md) with contribution notes
|
76
79
|
|
77
80
|
## Contributing
|
78
81
|
|
data/lib/squasher/render.rb
CHANGED
@@ -30,7 +30,7 @@ module Squasher
|
|
30
30
|
private
|
31
31
|
|
32
32
|
def stream_structure(stream)
|
33
|
-
yield 'execute
|
33
|
+
yield 'execute %q{'
|
34
34
|
skip_mode = false
|
35
35
|
ignored_table = ['ar_internal_metadata', 'schema_migrations']
|
36
36
|
stream.each_line do |line|
|
@@ -43,7 +43,7 @@ module Squasher
|
|
43
43
|
|
44
44
|
yield line.gsub(/\A\s{,2}(.*)\s+\z/, '\1')
|
45
45
|
end
|
46
|
-
yield '
|
46
|
+
yield '}'
|
47
47
|
end
|
48
48
|
|
49
49
|
def stream_schema(stream)
|
data/lib/squasher/version.rb
CHANGED
@@ -10,7 +10,8 @@ CREATE TABLE managers (
|
|
10
10
|
email character varying,
|
11
11
|
password_digest character varying,
|
12
12
|
created_at timestamp without time zone NOT NULL,
|
13
|
-
updated_at timestamp without time zone NOT NULL
|
13
|
+
updated_at timestamp without time zone NOT NULL,
|
14
|
+
CONSTRAINT email_format CHECK (email ~* '^.+@.+\..+')
|
14
15
|
);
|
15
16
|
|
16
17
|
CREATE TABLE offices (
|
data/spec/lib/worker_spec.rb
CHANGED
@@ -72,10 +72,10 @@ describe Squasher::Worker do
|
|
72
72
|
expect(File.exists?(new_migration_path)).to be_truthy
|
73
73
|
File.open(new_migration_path) do |stream|
|
74
74
|
content = stream.read
|
75
|
-
expect(content).to eq(
|
75
|
+
expect(content.strip).to eq(%q{
|
76
76
|
class InitSchema < ActiveRecord::Migration
|
77
77
|
def up
|
78
|
-
execute
|
78
|
+
execute %q{
|
79
79
|
CREATE TABLE cities (
|
80
80
|
id integer NOT NULL,
|
81
81
|
name character varying,
|
@@ -87,7 +87,8 @@ class InitSchema < ActiveRecord::Migration
|
|
87
87
|
email character varying,
|
88
88
|
password_digest character varying,
|
89
89
|
created_at timestamp without time zone NOT NULL,
|
90
|
-
updated_at timestamp without time zone NOT NULL
|
90
|
+
updated_at timestamp without time zone NOT NULL,
|
91
|
+
CONSTRAINT email_format CHECK (email ~* '^.+@.+\..+')
|
91
92
|
);
|
92
93
|
CREATE TABLE offices (
|
93
94
|
id integer NOT NULL,
|
@@ -101,14 +102,14 @@ class InitSchema < ActiveRecord::Migration
|
|
101
102
|
created_at timestamp without time zone NOT NULL,
|
102
103
|
updated_at timestamp without time zone NOT NULL
|
103
104
|
);
|
104
|
-
|
105
|
+
}
|
105
106
|
end
|
106
107
|
|
107
108
|
def down
|
108
109
|
raise ActiveRecord::IrreversibleMigration, "The initial migration is not revertable"
|
109
110
|
end
|
110
111
|
end
|
111
|
-
|
112
|
+
}.strip
|
112
113
|
)
|
113
114
|
end
|
114
115
|
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.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Pchelintsev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.6.
|
115
|
+
rubygems_version: 2.6.13
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Squash your old migrations
|