squasher 0.3.1 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbcde2fe7af3cc7854dfa744fc92bbe03ea5657c
4
- data.tar.gz: 5859b87e2dd11e1edffcb09aa8b070b2bf7fdaf2
3
+ metadata.gz: 32c691bc42a70dbb727f6c865fc4ed20fccdaa5b
4
+ data.tar.gz: 44f0be362840e69d663491d6596adf24bd45e541
5
5
  SHA512:
6
- metadata.gz: 608e982702c3c8de252fbaad554a094fd072a322de12ad957bed80b6928860c1a1d94ca5257ff13f7eee43a6b0b1c458e735a7177baf861f97f1afca2988099f
7
- data.tar.gz: 809912cb74e444f34b6fe534c961c23f03f9194bd554087172bea39560e2aa7d8e03afdeb32916be0ec4dfef6e5b2a222ce944b3c6b1d5044d6b04f4a5e7d066
6
+ metadata.gz: 69f6385a5155b6eb0c6893822ec8aedf055fdd566fb6cc10a35482cdc5f9dbf26c4234b2a7679b255ebb2784cae0190ede0d7daf7192d069fcb05ef5a06ac0b4
7
+ data.tar.gz: 378315cdd0c0e263611fee16c32b4e2952f89333550b8698232eac8e3485163ab08b67873c247e215a3d267bb6f5dced5ce02ccbd6fb234653b312a6f62e20c7
data/README.md CHANGED
@@ -19,13 +19,13 @@ 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.3.0'
22
+ gem 'squasher', '>= 0.3.0'
23
23
  gem 'capistrano'
24
24
  gem 'rubocop'
25
25
  end
26
26
  ```
27
27
 
28
- Don't forget to run `bundle`.
28
+ Don't forget to run `bundle`.
29
29
 
30
30
  To integrate `squasher` with your app even more do the below:
31
31
 
@@ -71,12 +71,18 @@ squasher will not need to create the db schema and all data from the previous mi
71
71
 
72
72
  `-e` - tell squasher that you are squashing a Rails engine. To squash migrations you need to configure a dummy app. If your dummy app located outside the engine's folder provide path to it as the next argument `squasher -e ../my-engine-app 2016`
73
73
 
74
+ `-m` - for correct work with Rails 5 specify a migration version like `squasher -m 5.0 ...`
75
+
74
76
  ## Requirements
75
77
 
76
78
  It works and was tested on Ruby 2.0+ and Rails 3.1+. It also requires a valid development configuration in `config/database.yml` and using Ruby format in `db/schema.rb` (default Rails use-case).
77
79
  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).
78
80
 
79
81
  ## Changelog
82
+ - 0.4.0
83
+ - Support rails versioned migrations which were introduced in Rails 5
84
+ - 0.3.1
85
+ - fix init migration generation
80
86
  - 0.3.0
81
87
  - **rails engines support** ([@JakeTheSnake3p0](https://github.com/JakeTheSnake3p0))
82
88
  - move messages from JSON file to YAML
@@ -4,7 +4,7 @@ require 'erb'
4
4
 
5
5
  module Squasher
6
6
  class Config
7
- OPTIONS = [:d, :r, :e].freeze
7
+ OPTIONS = [:d, :r, :e, :m].freeze
8
8
 
9
9
  module Render
10
10
  extend self
@@ -35,7 +35,7 @@ module Squasher
35
35
  end
36
36
  end
37
37
 
38
- attr_reader :schema_file
38
+ attr_reader :schema_file, :migration_version
39
39
 
40
40
  def initialize
41
41
  @root_path = Dir.pwd.freeze
@@ -56,6 +56,9 @@ module Squasher
56
56
  else
57
57
  Squasher.error(:multi_dummy_case, base: base)
58
58
  end
59
+ elsif key == :m
60
+ Squasher.error(:invalid_migration_version, value: value) unless value.to_s =~ /\A\d.\d\z/
61
+ @migration_version = "[#{value}]"
59
62
  else
60
63
  @flags << key
61
64
  end
@@ -23,8 +23,10 @@ usage:
23
23
  - " :yellow<-d> => execute in :blue<`dry`> mode - test a squashing process without removing old migrations"
24
24
  - " :yellow<-r> => reuse a database from the previous squashing"
25
25
  - " :yellow<-e> [dummy-root] => execute in :blue<`engine`> mode - requires a dummy app"
26
+ - " :yellow<-m> 5.0 => specify the rails migration version (added in Rails 5)"
26
27
  wrong_option: "You provided a wrong option :red<%{arg}>\n\n"
27
28
  invalid_param: "You provided a wrong param :red<%{arg}>\n\n"
28
29
  dry_mode_finished: "The `dry` mode is finished. Below the init schema's content:"
29
30
  cannot_find_dummy: "Squasher can't find a dummy app inside :yellow<%{base}>"
30
31
  multi_dummy_case: "Squasher found a few config/application.rb inside :yellow<%{base}>. Please specify the path more precisely"
32
+ invalid_migration_version: The provided rails migration version `%{value}` is invalid. It should be like `5.0`
@@ -1,4 +1,4 @@
1
- class InitSchema < ActiveRecord::Migration
1
+ class InitSchema < ActiveRecord::Migration<%= @config.migration_version %>
2
2
  def up
3
3
  <%- each_schema_line do |line| -%>
4
4
  <%= line.strip.empty? ? '' : " #{line}" %>
@@ -1,4 +1,4 @@
1
- class SquasherClean < ActiveRecord::Migration
1
+ class SquasherClean < ActiveRecord::Migration<%= @config.migration_version %>
2
2
  class SchemaMigration < ActiveRecord::Base
3
3
  end
4
4
 
@@ -55,4 +55,11 @@ describe Squasher::Config do
55
55
  end
56
56
 
57
57
  specify { expect(config.migration_file(1230, :sample)).to eq(File.join(fake_root, 'db', 'migrate', '1230_sample.rb')) }
58
+
59
+ specify "generate versioned migrations" do
60
+ config = Squasher::Config.new
61
+ config.set(:m, '5.1')
62
+ content = Squasher::Render.render(:init_schema, config)
63
+ expect(content).to include('ActiveRecord::Migration[5.1]')
64
+ end
58
65
  end
@@ -1,13 +1,13 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
 
3
3
  lib = File.expand_path('../lib', __FILE__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "squasher"
8
- spec.version = "0.3.1"
8
+ spec.version = "0.4.0"
9
9
  spec.authors = ["Sergey Pchelintsev"]
10
- spec.email = ["mail@sergeyp.me"]
10
+ spec.email = ["linz.sergey@gmail.com"]
11
11
  spec.description = %q{Squash your old migrations}
12
12
  spec.summary = %q{Squash your old migrations}
13
13
  spec.homepage = "https://github.com/jalkoby/squasher"
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.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Pchelintsev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-22 00:00:00.000000000 Z
11
+ date: 2017-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 3.3.0
55
55
  description: Squash your old migrations
56
56
  email:
57
- - mail@sergeyp.me
57
+ - linz.sergey@gmail.com
58
58
  executables:
59
59
  - squasher
60
60
  extensions: []