sequel-rails 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +10 -1
- data/README.md +4 -0
- data/lib/sequel_rails/migrations.rb +24 -0
- data/lib/sequel_rails/railties/database.rake +11 -0
- data/lib/sequel_rails/version.rb +1 -1
- data/spec/lib/sequel_rails/railties/database_rake_spec.rb +29 -3
- data/spec/spec_helper.rb +5 -1
- 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: b6d26dfaf8ce3dc258c5310ecc590fa8ef164de5
|
4
|
+
data.tar.gz: 82495e78e217391ca5a50ab5ea6f45ec77516890
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7d5d6dce632081523febcbe316f6cfbbb922febf43607f076649844c931ca68abbba550a8bfb9515925bafe24640cd32b887b47da50d6bb475e55b9a054f84c
|
7
|
+
data.tar.gz: b5f3c6394d30180d2476e4057aa3f0930990e479632a65c033eea8a2461d181f94198bcac651121e2fcf04fc4e186b633141bd6433d34042100d7b2460db59df
|
data/History.md
CHANGED
@@ -1,7 +1,16 @@
|
|
1
|
+
0.9.4 (2014-07-24)
|
2
|
+
==================
|
3
|
+
|
4
|
+
* Put a note in README about plugins which could not be added to `Sequel::Model`
|
5
|
+
(Thanks to Dave Myron) [#68](https://github.com/TalentBox/sequel-rails/issues/68)
|
6
|
+
* Implements `rake db:rollback` and fix `rake db:migrate:redo`
|
7
|
+
[#67](https://github.com/TalentBox/sequel-rails/issues/67)
|
8
|
+
|
1
9
|
0.9.3 (2014-05-18)
|
2
10
|
==================
|
3
11
|
|
4
|
-
* Use `ENV['DATABASE_URL']` for connection if set
|
12
|
+
* Use `ENV['DATABASE_URL']` for connection if set
|
13
|
+
[#66](https://github.com/TalentBox/sequel-rails/issues/66)
|
5
14
|
|
6
15
|
0.9.2 (2014-02-11)
|
7
16
|
==================
|
data/README.md
CHANGED
@@ -231,6 +231,10 @@ loaded. Loading plugins into `Sequel::Model` after subclasses are already
|
|
231
231
|
created is not supported by Sequel. You can also load extensions in
|
232
232
|
`after_connect` or perform any custom actions that you need.
|
233
233
|
|
234
|
+
Please note: some plugins require a `dataset` to work, which means they can't
|
235
|
+
be added via `Sequel::Model.plugin`, they need to be added to a `Sequel::Model`
|
236
|
+
subclass whose underlying table exists.
|
237
|
+
|
234
238
|
Using the `SequelStore` to store session in database
|
235
239
|
====================================================
|
236
240
|
|
@@ -43,6 +43,30 @@ module SequelRails
|
|
43
43
|
Rails.root.join('db/migrate')
|
44
44
|
end
|
45
45
|
|
46
|
+
def current_migration
|
47
|
+
return unless available_migrations?
|
48
|
+
|
49
|
+
migrator_class = ::Sequel::Migrator.send(:migrator_class, migrations_dir)
|
50
|
+
migrator = migrator_class.new ::Sequel::Model.db, migrations_dir
|
51
|
+
if migrator.respond_to?(:applied_migrations)
|
52
|
+
migrator.applied_migrations.last
|
53
|
+
elsif migrator.respond_to?(:current_version)
|
54
|
+
migrator.current_version
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def previous_migration
|
59
|
+
return unless available_migrations?
|
60
|
+
|
61
|
+
migrator_class = ::Sequel::Migrator.send(:migrator_class, migrations_dir)
|
62
|
+
migrator = migrator_class.new ::Sequel::Model.db, migrations_dir
|
63
|
+
if migrator.respond_to?(:applied_migrations)
|
64
|
+
migrator.applied_migrations[-2] || '0'
|
65
|
+
elsif migrator.respond_to?(:current_version)
|
66
|
+
migrator.current_version - 1
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
46
70
|
def available_migrations?
|
47
71
|
File.exist?(migrations_dir) && Dir[File.join(migrations_dir, '*')].any?
|
48
72
|
end
|
@@ -163,6 +163,17 @@ namespace :db do
|
|
163
163
|
Rake::Task['db:dump'].invoke if SequelRails.configuration.schema_dump
|
164
164
|
end
|
165
165
|
|
166
|
+
desc 'Rollback the latest migration file or down to specified VERSION=x'
|
167
|
+
task :rollback => 'migrate:load' do
|
168
|
+
version = if ENV['VERSION']
|
169
|
+
ENV['VERSION'].to_i
|
170
|
+
else
|
171
|
+
SequelRails::Migrations.previous_migration
|
172
|
+
end
|
173
|
+
SequelRails::Migrations.migrate_down! version
|
174
|
+
Rake::Task['db:dump'].invoke if SequelRails.configuration.schema_dump
|
175
|
+
end
|
176
|
+
|
166
177
|
desc 'Load the seed data from db/seeds.rb'
|
167
178
|
task :seed => :abort_if_pending_migrations do
|
168
179
|
seed_file = File.join(Rails.root, 'db', 'seeds.rb')
|
data/lib/sequel_rails/version.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'Database rake tasks' do
|
3
|
+
describe 'Database rake tasks', :no_transaction => true do
|
4
4
|
|
5
5
|
let(:app) { Combustion::Application }
|
6
6
|
let(:app_root) { app.root }
|
7
|
+
let(:schema) { "#{app_root}/db/schema.rb" }
|
7
8
|
|
8
9
|
around do |example|
|
9
10
|
begin
|
@@ -15,8 +16,6 @@ describe 'Database rake tasks' do
|
|
15
16
|
end
|
16
17
|
|
17
18
|
describe 'db:schema:dump' do
|
18
|
-
let(:schema) { "#{app_root}/db/schema.rb" }
|
19
|
-
|
20
19
|
it "dumps the schema in 'db/schema.rb'" do
|
21
20
|
Dir.chdir app_root do
|
22
21
|
`rake db:schema:dump`
|
@@ -62,4 +61,31 @@ EOS
|
|
62
61
|
end
|
63
62
|
end
|
64
63
|
end
|
64
|
+
|
65
|
+
describe 'db:rollback' do
|
66
|
+
it 'revert latest migration' do
|
67
|
+
Dir.chdir app_root do
|
68
|
+
begin
|
69
|
+
expect do
|
70
|
+
`rake db:rollback`
|
71
|
+
end.to change { SequelRails::Migrations.current_migration }.from(
|
72
|
+
'1273253849_add_twitter_handle_to_users.rb'
|
73
|
+
).to(nil)
|
74
|
+
ensure
|
75
|
+
SequelRails::Migrations.migrate_up!
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe 'db:migrate:redo' do
|
82
|
+
it 'run down then up of the latest migration' do
|
83
|
+
Dir.chdir app_root do
|
84
|
+
SequelRails::Migrations.migrate_up!
|
85
|
+
expect do
|
86
|
+
`rake db:migrate:redo`
|
87
|
+
end.not_to change { SequelRails::Migrations.current_migration }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
65
91
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -22,8 +22,12 @@ RSpec.configure do |config|
|
|
22
22
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
23
23
|
config.filter_run_excluding rspec_exclusions
|
24
24
|
config.around :each do |example|
|
25
|
-
|
25
|
+
if example.metadata[:no_transaction]
|
26
26
|
example.run
|
27
|
+
else
|
28
|
+
Sequel::Model.db.transaction(:rollback => :always) do
|
29
|
+
example.run
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brasten Sager (brasten)
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -259,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
259
|
version: '0'
|
260
260
|
requirements: []
|
261
261
|
rubyforge_project:
|
262
|
-
rubygems_version: 2.2.
|
262
|
+
rubygems_version: 2.2.1
|
263
263
|
signing_key:
|
264
264
|
specification_version: 4
|
265
265
|
summary: Use Sequel with Rails (3.x and 4.x)
|