communard 0.1.0 → 0.1.1

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
2
  SHA256:
3
- metadata.gz: 94f9d91890f50281fc8ce1d4678153cf2aff2c2068c00166774aeeafe80dfb16
4
- data.tar.gz: cd21196d14631a2e3eda1435e16c4fd4afdabc1da2ab16d0d198290c1275e153
3
+ metadata.gz: 9d160711820fe427786947a0718c53cb73a2167df5fb714196ffc81e77fe148a
4
+ data.tar.gz: 5642f174554fbbdbf006726823d34e582f5b0791fa1e5ee86541fd69f3ec8c3e
5
5
  SHA512:
6
- metadata.gz: 4968eb2fb22782695eb7335028f0d8fb76d58a3bb4fe437ec3e3da75fb8b1edc74cc66a8b2fceeabbad8c6c44aa7adf8c206566ba08fed93552ec8fe356521ae
7
- data.tar.gz: 55000cbc291e4ca20050c1fff461b709f689aeea3a17f28d922ec8c69220d042dbd22ff628f5be8ce2889594ab9c0d8fa652ac82b9b60c6113d16d3e278e7101
6
+ metadata.gz: 0a5811b7dd25ef9aba12a113b12b8b50b22a176c7023ed190356eee6e874840ec0c6a99476252401bef88a06eddc158bb875c4beed249036ebb5286c52544af8
7
+ data.tar.gz: b098d85743d78519bcb4e57e08dfedc0c574237e3600d97af023524b2ec0a2740c511c153de01681d1cc6c4efe49caa619aa6c7045cb714d72cfe63e693ab692
@@ -50,11 +50,16 @@ module Communard
50
50
  end
51
51
 
52
52
  def rollback(step: 1)
53
- target = applied_migrations[-step - 1]
54
- if target
55
- migrate(target: target.split(/_/, 2).first)
53
+ available = applied_migrations
54
+ if available.size == 1
55
+ migrate(target: 0)
56
56
  else
57
- fail ArgumentError, "Cannot roll back to #{step}"
57
+ target = available[-step - 1]
58
+ if target
59
+ migrate(target: target.split(/_/, 2).first)
60
+ else
61
+ fail ArgumentError, "Cannot roll back to #{step}"
62
+ end
58
63
  end
59
64
  end
60
65
 
@@ -75,7 +80,7 @@ module Communard
75
80
  results = Hash.new { |h, k| h[k] = Status.new(k, false, false) }
76
81
  available = Pathname.glob(migrations_dir.join("*.rb")).map(&:basename).map(&:to_s)
77
82
  available.each { |migration| results[migration].available = true }
78
- applied_migrations(available).each { |migration| results[migration].applied = true }
83
+ applied_migrations.each { |migration| results[migration].applied = true }
79
84
 
80
85
  $stdout.puts
81
86
  $stdout.puts "database: #{connection.opts.fetch(:database)}"
@@ -101,12 +106,13 @@ module Communard
101
106
 
102
107
  private
103
108
 
104
- def applied_migrations(available)
109
+ def applied_migrations
110
+ available = Pathname.glob(migrations_dir.join("*.rb")).map(&:basename).map(&:to_s)
105
111
  m = migrator(allow_missing_migration_files: true)
106
112
  if m.is_a?(Sequel::IntegerMigrator)
107
113
  available.select { |f| f.split("_", 2).first.to_i <= m.current }
108
114
  else
109
- instance.applied_migrations
115
+ m.applied_migrations
110
116
  end
111
117
  end
112
118
 
@@ -1,5 +1,5 @@
1
1
  module Communard
2
2
 
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
 
5
5
  end
@@ -6,6 +6,10 @@ RSpec.describe "Integration", type: :aruba do
6
6
  run_tests("sqlite://db/test.sqlite3")
7
7
  end
8
8
 
9
+ example "SQLite with timestamps" do
10
+ run_tests("sqlite://db/test.sqlite3", timestamps: true)
11
+ end
12
+
9
13
  example "PostgreSQL" do
10
14
  run_tests("postgresql://localhost:5432/communard_test")
11
15
  end
@@ -14,7 +18,7 @@ RSpec.describe "Integration", type: :aruba do
14
18
  run_tests("mysql2://root@localhost:3306/communard_test")
15
19
  end
16
20
 
17
- def run_tests(database_config)
21
+ def run_tests(database_config, options = {})
18
22
  write_file "Rakefile", <<-FILE.gsub(/^\s{6}/, "")
19
23
  $LOAD_PATH.unshift(File.expand_path("../../../lib", __FILE__))
20
24
  require "communard/rake"
@@ -23,7 +27,11 @@ RSpec.describe "Integration", type: :aruba do
23
27
  end
24
28
  FILE
25
29
 
26
- run_simple "bundle exec communard migration create_posts"
30
+ if options[:timestamps]
31
+ run_simple "bundle exec communard migration create_posts --timestamps"
32
+ else
33
+ run_simple "bundle exec communard migration create_posts"
34
+ end
27
35
 
28
36
  glob = Dir[expand_path("db/migrate/*_create_posts.rb")]
29
37
  file = glob.first
@@ -46,6 +54,8 @@ RSpec.describe "Integration", type: :aruba do
46
54
  run_simple "bundle exec rake db:create"
47
55
 
48
56
  run_simple "bundle exec rake db:migrate"
57
+
58
+ run_simple "bundle exec rake db:migrate:redo"
49
59
  end
50
60
 
51
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: communard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - iain