sequel_tools 0.1.3 → 0.1.4

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: 437ee89e0a2b2873e1651f948c8a89fc1a0aedf6
4
- data.tar.gz: 4ba17eb0f479f61e39fb02be3caf45598a269115
3
+ metadata.gz: fd0f583b78b874b3cfc1701a277ef182b184c66f
4
+ data.tar.gz: 980bc39cff7f7af9fcad83b4cd655d59aca0b3c3
5
5
  SHA512:
6
- metadata.gz: 3d59d32bc56d2d39f6bf378c7be5713b253162b7f48dbca61f922d23660a5137332a2070b2fec00dccebb6fd25a2a880e6fea8575c347f758f57ce3c99c5d6bd
7
- data.tar.gz: 15cce1e67d59678423f000e8ab192e4205726eb2f9939623b8f68eccaf7c80235f19e964a0f367aabc95d4af71b1e0e9e118b6cecbbbcef3666839d57784413b
6
+ metadata.gz: 912e0711195c5f895b40807d6013e899d6767f878438e2b4b173f910304e69928bf64da3c5c10db3d3ed12a9c768eb362fee42dc1b8726090278553fb86c4534
7
+ data.tar.gz: 55bfdf355d5f590e1d6ee16bd2096dce9c686ecbff614335928c96e08bb5477d1539542a1e0860919fc79ba59008c88b5d620f02522ed0d6b3aa1b9f2d1609c2
data/.gitignore CHANGED
@@ -8,6 +8,8 @@
8
8
  /tmp/
9
9
  /spec/sample_project/db/migrations/
10
10
  /spec/sample_project/db/seeds.rb
11
+ /spec/sample_project/bin/bundle
12
+ /spec/sample_project/bin/sequel
11
13
 
12
14
  # rspec failure tracking
13
15
  .rspec_status
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sequel_tools (0.1.3)
4
+ sequel_tools (0.1.4)
5
5
  sequel
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -51,7 +51,7 @@ base_config = SequelTools.base_config(
51
51
  dump_schema_on_migrate: false, # it's a good idea to enable it for the reference environment
52
52
  pg_dump: 'pg_dump', # command used to run pg_dump
53
53
  pg_dump: 'psql', # command used to run psql when calling rake db:shell if adapter is postgres
54
- db_migrations_location: 'db/migrations',
54
+ migrations_location: 'db/migrations',
55
55
  schema_location: 'db/migrations/schema.sql',
56
56
  seeds_location: 'db/seeds.rb',
57
57
  maintenancedb: 'postgres' # for tasks such as creating the database
@@ -8,7 +8,7 @@ module SequelTools
8
8
  pg_dump: 'pg_dump', # command used to run pg_dump
9
9
  psql: 'psql', # command used to run psql
10
10
  maintenancedb: 'postgres', # DB to connect to for creating/dropping databases
11
- db_migrations_location: 'db/migrations',
11
+ migrations_location: 'db/migrations',
12
12
  schema_location: 'db/migrations/schema.sql',
13
13
  seeds_location: 'db/seeds.rb',
14
14
  dbname: nil,
@@ -29,7 +29,7 @@ module SequelTools
29
29
  REQUIRED_KEYS.each do |key|
30
30
  raise MissingConfigError, "Expected value for #{key} config is missing" if config[key].nil?
31
31
  end
32
- [:db_migrations_location, :schema_location, :seeds_location].each do |k|
32
+ [:migrations_location, :schema_location, :seeds_location].each do |k|
33
33
  config[k] = File.expand_path config[k], config[:project_root]
34
34
  end
35
35
  config
@@ -0,0 +1,14 @@
1
+ # frozen-string-literal: true
2
+
3
+ require_relative '../actions_manager'
4
+
5
+ class SequelTools::ActionsManager
6
+ # TODO: this action is not currently tested automatically as it's not critical and not
7
+ # trivial to write a test for
8
+ description = "Opens an IRB session started as 'sequel uri_to_database' (DB is available to irb)"
9
+ Action.register :irb, description do |args, context|
10
+ config = context[:config]
11
+ uri = context[:uri_builder][config]
12
+ exec "bundle exec sequel #{uri}"
13
+ end
14
+ end
@@ -12,7 +12,7 @@ class SequelTools::ActionsManager
12
12
  Sequel.extension :migration unless Sequel.respond_to? :migration
13
13
  options = {}
14
14
  options[:target] = args[:version].to_i if args[:version]
15
- Sequel::Migrator.run db, config[:db_migrations_location], options
15
+ Sequel::Migrator.run db, config[:migrations_location], options
16
16
  Action[:schema_dump].run({}, context) if config[:dump_schema_on_migrate]
17
17
  end
18
18
  end
@@ -7,7 +7,7 @@ class SequelTools::ActionsManager
7
7
  Action.register :new_migration, desc, arg_names: [ :name ] do |args, context|
8
8
  (puts 'Migration name is missing - aborting'; exit 1) unless name = args[:name]
9
9
  require 'time'
10
- migrations_path = context[:config][:db_migrations_location]
10
+ migrations_path = context[:config][:migrations_location]
11
11
  filename = "#{migrations_path}/#{Time.now.strftime '%Y%m%d%H%M%S'}_#{name}.rb"
12
12
  File.write filename, <<~MIGRATIONS_TEMPLATE_END
13
13
  # documentation available at http://sequel.jeremyevans.net/rdoc/files/doc/migration_rdoc.html
@@ -1,7 +1,6 @@
1
1
  # frozen-string-literal: true
2
2
 
3
3
  require_relative '../actions_manager'
4
- require_relative '../pg_helper'
5
4
 
6
5
  class SequelTools::ActionsManager
7
6
  # TODO: this action is not currently tested automatically as it's not critical and not
@@ -8,7 +8,7 @@ class SequelTools::ActionsManager
8
8
  description = 'Show migrations status (applied and missing in migrations path vs unapplied)'
9
9
  Action.register :status, description do |args, context|
10
10
  unapplied, files_missing = MigrationUtils.migrations_differences context
11
- path = context[:config][:db_migrations_location]
11
+ path = context[:config][:migrations_location]
12
12
  unless files_missing.empty?
13
13
  puts "The following migrations were applied to the database but can't be found in #{path}:"
14
14
  puts files_missing.map{|fn| " - #{fn}" }.join("\n")
@@ -19,3 +19,4 @@ require_relative 'actions/rollback'
19
19
  require_relative 'actions/status'
20
20
  require_relative 'actions/shell_postgres'
21
21
  require_relative 'actions/shell'
22
+ require_relative 'actions/irb'
@@ -22,8 +22,8 @@ class MigrationUtils
22
22
  options = { allow_missing_migration_files: true }
23
23
  options[:target] = 0 if direction == :down
24
24
  config = context[:config]
25
- Sequel::Migrator.migrator_class(config[:db_migrations_location]).
26
- new(context[:db], config[:db_migrations_location], options)
25
+ Sequel::Migrator.migrator_class(config[:migrations_location]).
26
+ new(context[:db], config[:migrations_location], options)
27
27
  end
28
28
 
29
29
  def self.current_version(context)
@@ -32,7 +32,7 @@ class MigrationUtils
32
32
  end
33
33
 
34
34
  def self.last_found_migration(context)
35
- migrations_path = context[:config][:db_migrations_location]
35
+ migrations_path = context[:config][:migrations_location]
36
36
  migrator = find_migrator(context)
37
37
  migrator.ds.order(Sequel.desc(migrator.column)).select_map(migrator.column).find do |fn|
38
38
  File.exist?("#{migrations_path}/#{fn}")
@@ -41,7 +41,7 @@ class MigrationUtils
41
41
 
42
42
  def self.migrations_differences(context)
43
43
  config = context[:config]
44
- migrations_path = config[:db_migrations_location]
44
+ migrations_path = config[:migrations_location]
45
45
  existing = Dir["#{migrations_path}/*.rb"].map{|fn| File.basename fn }.sort
46
46
  migrator = find_migrator context
47
47
  migrated = migrator.ds.select_order_map(migrator.column)
@@ -1,5 +1,5 @@
1
1
  # frozen-string-literal: true
2
2
 
3
3
  module SequelTools
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Rosenfeld Rosas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-16 00:00:00.000000000 Z
11
+ date: 2017-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -110,6 +110,7 @@ files:
110
110
  - lib/sequel_tools/actions/create_db.rb
111
111
  - lib/sequel_tools/actions/down.rb
112
112
  - lib/sequel_tools/actions/drop_db.rb
113
+ - lib/sequel_tools/actions/irb.rb
113
114
  - lib/sequel_tools/actions/migrate.rb
114
115
  - lib/sequel_tools/actions/new_migration.rb
115
116
  - lib/sequel_tools/actions/redo.rb