rack-app-sequel 0.4.0 → 0.5.0

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
  SHA1:
3
- metadata.gz: 914f7c22acd4f1ce23ba7f19fb6954cd8af04495
4
- data.tar.gz: 5d34c4c7622b903f18c8df1b9ea23a85ea6b4a88
3
+ metadata.gz: 2c746438bf92e9674dca0e9a68f229e220149a6a
4
+ data.tar.gz: bc7d8b3840cd24954e8399af692d03bbcfb161e0
5
5
  SHA512:
6
- metadata.gz: 540109421ffb84f45c9f4578f90e35e80e66ba48b8a93227a0908604a654b61a23775006e65999509543f142a7c5c06a06c7ab6fd227428166084a5451611ed1
7
- data.tar.gz: d56fc9162254defaa5a1a68d9927442040852b62e7f1116d0e7d4d5a08dc61686c246473589f9b27e70996035e6f6f6d18d5e2929c27760edc3b04cfd94db610
6
+ metadata.gz: 49f0a0416c0e06084e50e081bfbf4ec7e0a429119302b45ba616b894241595c957ba03f8c414d2b68b0972d5ac8a56fe0657267f27a4e0aee87626fd6da01c53
7
+ data.tar.gz: 1774794071a976d2481f61fad68618af35b52ad0c1fedcd0609f6b749037419bf35c9e576d376437bd9b01aa3f6e2fe0535ac7e24d94b7cc6efe0095414a3656
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
@@ -1,9 +1,28 @@
1
- # command 'db:rollback' do
2
- # description "Perform rollback to specified target or full rollback as default"
3
- # Rack::App::SeQueL::Runner.setup_command(self)
1
+ command 'db:rollback' do
2
+ description "Rollback the database N steps (you can specify the version with `db:rollback [STEP_COUNT]`"
4
3
 
5
- # action do
6
- # exit(Rack::App::SeQueL::Runner.new(options, migration_config).run)
7
- # end
4
+ Rack::App::SeQueL::Runner.setup_command(self, :target)
8
5
 
9
- # end
6
+ action do |step=1|
7
+ step = Integer(step)
8
+
9
+ if step == 0
10
+ migration_config[:target] = 0
11
+ end
12
+
13
+ Rack::App::SeQueL.open_connection do |connection|
14
+ row = connection[:schema_migrations]
15
+ .order(Sequel.desc(:filename))
16
+ .offset(step).first
17
+
18
+ unless row.nil?
19
+ migration_config[:target] = Integer(row[:filename].match(/^([\d]+)/)[0])
20
+ end
21
+ end unless migration_config[:target]
22
+
23
+ migration_config[:target] || abort("target version not found")
24
+
25
+ exit(Rack::App::SeQueL::Runner.new(options, migration_config).run)
26
+ end
27
+
28
+ end
@@ -1,15 +1,15 @@
1
1
  class Rack::App::SeQueL::Runner
2
2
 
3
- def self.setup_command(command)
3
+ def self.setup_command(command, *excludes)
4
4
  command.class_eval do
5
5
 
6
6
  option '-a', '--allow_missing_migration_files', 'In some cases, you may want to allow a migration in the database that does not exist in the filesystem' do
7
7
  migration_config[:allow_missing_migration_files] = true
8
- end
8
+ end unless excludes.include?(:allow_missing_migration_files)
9
9
 
10
10
  option '-c', '--current [CURRENT_VERION]', 'Set the current version of the database for the execution' do |current_database_version|
11
11
  migration_config[:current] = current_database_version
12
- end
12
+ end unless excludes.include?(:current)
13
13
 
14
14
  # option '-r', '--relative [MIGRATION_COUNT]', 'Run the given number of migrations, with a positive number being migrations to migrate up, and a negative number being migrations to migrate down (IntegerMigrator only).' do |value|
15
15
  # migration_config[:relative] = value.to_i
@@ -17,7 +17,7 @@ class Rack::App::SeQueL::Runner
17
17
 
18
18
  option '-t', '--target [TIMESTAMP]', 'The target version to which to migrate. If not given, migrates to the maximum version.' do |target_version|
19
19
  migration_config[:target] = target_version
20
- end
20
+ end unless excludes.include?(:target)
21
21
 
22
22
  option '-m', '--path-to-migration-patches [DIR_PATH]', "set to check what directory should be used for db migrations (default: #{Rack::App::SeQueL::Migration::DEFAULT_DIRECTORY})" do |new_migration_directory|
23
23
  options[:migration_directory] = new_migration_directory
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-app-sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-31 00:00:00.000000000 Z
11
+ date: 2017-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler